github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/tools/hdwal/hdwal.go (about)

     1  package main
     2  
     3  import (
     4  	"encoding/hex"
     5  	"fmt"
     6  
     7  	"github.com/piotrnar/gocoin/lib/btc"
     8  )
     9  
    10  // Use this tool with "Prnt" type of public master keys
    11  
    12  func main() {
    13  	hdw, er := btc.StringWallet("xpub6CmoCa2ASDeVgaXeVkWXaJ5ZmeEAvYoZFnt3EXc2dhZEMVDW8noe3wMhWyQ4kPFUFGJdVAduv5JaugCndZNghtJicQqu76UywCWDKGTz5us")
    14  	if er != nil {
    15  		println(er.Error())
    16  		return
    17  	}
    18  
    19  	hdw.Prefix = btc.PublicZ // convert to bech32 format
    20  	fmt.Println("Parent master public key:")
    21  	fmt.Println("", hdw.String())
    22  
    23  	fmt.Println("1st deposit address (e.g. m/84'/0'/0'/0/0):")
    24  	fmt.Println("", hdw.Child(0).Child(0).PubAddr().String())
    25  	fmt.Println("", hex.EncodeToString(hdw.Child(0).Child(0).Pub().Key))
    26  
    27  	fmt.Println("1st change address (e.g. m/84'/0'/0'/1/0):")
    28  	fmt.Println("", hdw.Child(1).Child(0).PubAddr().String())
    29  	fmt.Println("", hex.EncodeToString(hdw.Child(1).Child(0).Pub().Key))
    30  }