-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
78 lines (70 loc) · 1.38 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"github.com/spf13/cobra"
"os"
"strconv"
)
var (
Endpoint string
)
var ethwt = &cobra.Command{
Use: "ethwt",
Short: "ethwt is a Ethereum wallet command-line tool ",
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Help()
},
}
var gen = &cobra.Command{
Use: "gen",
Short: "Generate wallet",
Run: func(cmd *cobra.Command, args []string) {
wallNum := 0
if len(args) > 0 {
var err error
wallNum, err = strconv.Atoi(args[0])
if err != nil {
fmt.Println("generate wallet failed:", err)
return
}
}
GenWallet(wallNum)
},
Args: cobra.MinimumNArgs(1),
}
var tx = &cobra.Command{
Use: "tx",
Short: "Transfer to wallets",
Run: func(cmd *cobra.Command, args []string) {
val := "0"
if len(args) > 0 {
val = args[0]
}
Transfer(val)
},
Args: cobra.MinimumNArgs(1),
}
var pa = &cobra.Command{
Use: "pa",
Short: "Print private key as json array",
Run: func(cmd *cobra.Command, args []string) {
PrintPkJsonArray()
},
}
var pl = &cobra.Command{
Use: "pl",
Short: "Print private key as line txt",
Run: func(cmd *cobra.Command, args []string) {
PrintPkLine()
},
}
func init() {
tx.Flags().StringVarP(&Endpoint, "endpoint", "e", "https://ethereum.publicnode.com", "Network rpc endpoint")
ethwt.AddCommand(tx, gen, pa, pl)
}
func main() {
if err := ethwt.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}