-
Notifications
You must be signed in to change notification settings - Fork 3
/
zelgen.go
52 lines (43 loc) · 1.26 KB
/
zelgen.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
package main
import (
"flag"
"log"
"fmt"
"bufio"
"os"
"github.com/TheTrunk/zelgen/zelcrypto"
)
func main() {
// var networkId zelcrypto.NetworkId
boolPtr := flag.Bool("test", false, "generate a testnet wallet")
nPtr := flag.Int("n", 1, "Number of addresses to generate up to 100")
boolPtr3 := flag.Bool("o", false, "enable output to file outputzelgen.txt")
flag.Parse()
var output bool = *boolPtr3
// Generate the wallet
wallet, err := zelcrypto.CreateWallet(!(*boolPtr), *nPtr)
if err != nil {
log.Panicln(err.Error())
}
log.Println("Wallet generated!")
fmt.Println("Passphrase:", wallet.Passphrase)
fmt.Println("Address\t\t\t\tPrivate key")
file, err := os.OpenFile("outputzelgen.txt", os.O_WRONLY|os.O_CREATE, 0666)
if err != nil && output == true {
fmt.Println("File does not exists or cannot be created")
os.Exit(1)
}
w := bufio.NewWriter(file)
if output == true {
fmt.Fprintln(w,"Passphrase:", wallet.Passphrase)
fmt.Fprintln(w,"Address\t\t\t\t\t\t\t\tPrivate key")
w.Flush()
}
for i := 0; i <= len(wallet.Addresses)-1; i++ {
fmt.Println(wallet.Addresses[i].Value, wallet.Addresses[i].PrivateKey)
if output == true {
fmt.Fprintln(w,wallet.Addresses[i].Value, wallet.Addresses[i].PrivateKey)
w.Flush()
}
}
}