MENU

Golang 批量生成TRON公链地址(可筛靓号)

June 19, 2023 • Read: 1024 • 程序源码

虽然所谓的“靓号”没什么用处,但是好(zhuang)看(bi)呀!代码稍微改下就行,目前里面筛选的是888结尾的地址,至于多久能跑出来心怡地址,全靠自己计算机算力了(会跑满CPU)!

package main

import (
    "encoding/hex"
    "log"
    "time"
)
import "github.com/btcsuite/btcd/btcec"
import addr "github.com/fbsobreira/gotron-sdk/pkg/address"

func main() {
    now := time.Now()
    count := 0
    for i := 0; i < 16; i++ {
        go func() {
            for {
                key, address := GenerateKey()
                if address[31:] == "888" {
                    count += 1
                    log.Printf("私钥:%s 地址: %s\n", key, address)
                }
            }
        }()
    }

    for {
        log.Println(int(time.Now().Sub(now).Seconds()), count)

        time.Sleep(time.Second)
    }
}

func GenerateKey() (string, string) {
    pri, err := btcec.NewPrivateKey(btcec.S256())
    if err != nil {
        return "", ""
    }
    if len(pri.D.Bytes()) != 32 {
        for {
            pri, err = btcec.NewPrivateKey(btcec.S256())
            if err != nil {
                continue
            }
            if len(pri.D.Bytes()) == 32 {
                break
            }
        }
    }

    address := addr.PubkeyToAddress(pri.ToECDSA().PublicKey).String()
    privateKey := hex.EncodeToString(pri.D.Bytes())

    return privateKey, address
}