Bitcoin Core 钱包的助记词与公私钥

今天看到了《精通比特币》的第三章-比特币核心。
程序开发人员使用现代标准(如BIP-39和BIP-32)构建钱包。
测试了如下一段代码,果然可以产生新的助记词和公私钥。

package main

import (
  "github.com/tyler-smith/go-bip39"
  "github.com/tyler-smith/go-bip32"
  "fmt"
)

func main(){
  // Generate a mnemonic for memorization or user-friendly seeds
  entropy, _ := bip39.NewEntropy(256)
  mnemonic, _ := bip39.NewMnemonic(entropy)

  // Generate a Bip32 HD wallet for the mnemonic and a user supplied password
  seed := bip39.NewSeed(mnemonic, "Secret Passphrase")

  masterKey, _ := bip32.NewMasterKey(seed)
  publicKey := masterKey.PublicKey()

  // Display mnemonic and keys
  fmt.Println("Mnemonic: ", mnemonic)
  fmt.Println("Master private key: ", masterKey)
  fmt.Println("Master public key: ", publicKey)
}

脚本运行结果如下:

《Bitcoin Core 钱包的助记词与公私钥》 image.png

    原文作者:顾晓峰_b9c5
    原文地址: https://www.jianshu.com/p/10ed7f1323b4
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞