master
dustoair 3 years ago
commit 0d320825a3

9
.gitignore vendored

@ -0,0 +1,9 @@
.idea
go.sum
main.exe
server.exe
log.txt
logs
*.log
uploads
gin.log

@ -0,0 +1 @@
批量生成eth地址和私钥

@ -0,0 +1,16 @@
module ETHAddress
go 1.18
require (
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/tyler-smith/go-bip39 v1.1.0
)
require (
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/ethereum/go-ethereum v1.10.4 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988 // indirect
)

@ -0,0 +1,48 @@
package main
import (
"fmt"
"github.com/miguelmota/go-ethereum-hdwallet"
"github.com/tyler-smith/go-bip39"
"log"
"time"
)
func main() {
for {
Gen()
time.Sleep(5)
}
}
func Gen() {
entropy, err := bip39.NewEntropy(128)
if err != nil {
log.Fatal(err)
}
mnemonic, _ := bip39.NewMnemonic(entropy)
//var mnemonic = "pepper hair process town say voyage exhibit over carry property follow define"
//fmt.Println("mnemonic:", mnemonic)
seed := bip39.NewSeed(mnemonic, "245eaxv7UFUE5P5OGh_M") //这里可以选择传入指定密码或者空字符串,不同密码生成的助记词不同
wallet, err := hdwallet.NewFromSeed(seed)
if err != nil {
log.Fatal(err)
}
path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0") //最后一位是同一个助记词的地址id从0开始相同助记词可以生产无限个地址
//path = hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/1") //生成id为1的钱包地址
account, err := wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}
address := account.Address.Hex()
privateKey, _ := wallet.PrivateKeyHex(account)
//publicKey, _ := wallet.PublicKeyHex(account)
fmt.Println("address0:", address) // id为0的钱包地址
fmt.Println("privateKey:", privateKey) // 私钥
//fmt.Println("publicKey:", publicKey) // 公钥
}

@ -0,0 +1,15 @@
package tests
import (
"testing"
)
//https://studygolang.com/interview/question
func TestIfcondation(tt *testing.T) {
if a := 1; false {
} else if b := 2; false {
} else {
println(a, b)
}
}
Loading…
Cancel
Save