-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
66 lines (54 loc) · 1007 Bytes
/
main.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
package main
import (
"flag"
"fmt"
"github.com/stellar/go/keypair"
"runtime"
"time"
)
type Result struct {
seed string
addr string
}
var (
count = 0
)
func Run(c chan Result, in string) {
var seed string
var addr string
var prefix string
for prefix != in {
kp, _ := keypair.Random()
addr = kp.Address()
seed = kp.Seed()
prefix = string([]rune(addr)[len(addr)-len(in) : len(addr)])
count++
}
c <- Result{
seed: seed,
addr: addr,
}
}
func main() {
prefix := flag.String("p", "UNSET", "Prefix to find")
flag.Parse()
found := make(chan Result)
go func() {
for {
select {
case <-time.After(time.Second):
fmt.Printf("Running at %d hash per second\n", count)
count = 0
}
}
}()
fmt.Printf("Finding Address end with %s\n", *prefix)
for i := 0; i < runtime.NumCPU(); i++ {
fmt.Printf("Running task no. %d \n", i+1)
go Run(found, *prefix)
}
result := <-found
fmt.Println("Hash found !!")
fmt.Println(result.addr)
fmt.Println(result.seed)
}