-
Notifications
You must be signed in to change notification settings - Fork 4
/
ccgen.go
80 lines (68 loc) · 1.35 KB
/
ccgen.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
79
80
package main
import (
"fmt"
"os"
"runtime"
"github.com/IngCr3at1on/ccgen/gen"
"github.com/codegangsta/cli"
)
var app *cli.App
func init() {
app = cli.NewApp()
app.Name = "ccgen"
app.Usage = "Cryptocoin address generator"
app.Version = "0.0.2"
var ctype string
var vanity string
var compress bool
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "type, t",
Value: "bitcoin",
Usage: "Define coin-type to generate an address for",
Destination: &ctype,
},
cli.BoolFlag{
Name: "compress, c",
Usage: "Compress the private key and address",
Destination: &compress,
},
cli.StringFlag{
Name: "vanity, V",
Value: "",
Usage: "Attempt to generate an address with the provided prefix",
Destination: &vanity,
},
}
app.Action = func(c *cli.Context) {
var wif string
var addr string
if vanity != "" {
vain := gen.NewVanityGen(ctype, vanity, compress)
vain.Start()
out:
for {
select {
case <-vain.Quit:
vain.Wg.Wait()
break out
default:
}
}
wif = vain.Wif
addr = vain.Addr
} else {
var err error
wif, addr, err = gen.GenerateAddress(ctype, compress)
if err != nil {
fmt.Println(err)
return
}
}
fmt.Printf("%s\n%s\n", wif, addr)
}
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
app.Run(os.Args)
}