Bip32-Hd-Wallets

Golang如何從bip32的xpubkey中獲取地址?

  • July 6, 2018

我正在嘗試使用 Golang 導出比特幣的高畫質地址。我已經擴展了私鑰/公鑰。問題是我無法在 Golang 中找到任何可以從 xpubkey/xprivkey 生成/派生地址的庫。有什麼建議嗎?

看看<https://github.com/wemeetagain/go-hdwallet>

// Generate a random 256 bit seed
seed, err := hdwallet.GenSeed(256)

// Create a master private key
masterprv := hdwallet.MasterKey(seed)

// Convert a private key to public key
masterpub := masterprv.Pub()

// Generate new child key based on private or public key
childprv, err := masterprv.Child(0)
childpub, err := masterpub.Child(0)

// Create bitcoin address from public key
address := childpub.Address()

// Convenience string -&gt; string Child and ToAddress functions
walletstring := childpub.String()
childstring, err := hdwallet.StringChild(walletstring,0)
childaddress, err := hdwallet.StringAddress(childstring)

引用自:https://bitcoin.stackexchange.com/questions/76951