-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheth.go
More file actions
47 lines (36 loc) · 1 KB
/
eth.go
File metadata and controls
47 lines (36 loc) · 1 KB
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
package main
import (
"encoding/hex"
"strings"
"time"
"github.com/ethereum/go-ethereum/crypto"
log "github.com/sirupsen/logrus"
)
type EthCmd struct {
Pattern string `long:"pattern" default:"42" description:"match pattern"`
}
func (ec *EthCmd) Execute(args []string) error {
beginTime := time.Now()
prefix := strings.ToLower(ec.Pattern)
var numAttempts int64 = 0
addrStr := ""
keyStr := ""
for {
numAttempts++
key, _ := crypto.GenerateKey()
addr := crypto.PubkeyToAddress(key.PublicKey)
addrStr = hex.EncodeToString(addr[:])
if matchPrefix(addrStr, prefix) {
keyStr = hex.EncodeToString(crypto.FromECDSA(key))
// fmt.Println("pub:", hex.EncodeToString(crypto.FromECDSAPub(&key.PublicKey)))
break
}
}
log.Infof("\nElapsed: %s\naddr: 0x%s\npvt: 0x%s\nattempts: %d.\n",
time.Since(beginTime), addrStr, keyStr, numAttempts)
return nil
}
var ethCmd EthCmd
func init() {
parser.AddCommand("eth", "get a ETH vanity address", "The ticker command get a ETH vanity address", ðCmd)
}