func main() { fmt.Println("Enter secret seed:") seed := string(gopass.GetPasswd()) pubKey, chain, privKey := bitcoin.ComputeMastersFromSeed(seed) fmt.Println("Derived pubkey: ", pubKey) fmt.Println("Enter message to sign, ctrl-d ctrl-d when done:") message, err := ioutil.ReadAll(os.Stdin) if err != nil { panic(err) } signature := bitcoin.SignMessage(privKey, string(message), true) fmt.Printf(` -----BEGIN BITCOIN SIGNED MESSAGE----- %v -----BEGIN BITCOIN SIGNATURE----- Version: Bitcoin-qt (1.0) PublicKey: %v Chain: %v %v -----END BITCOIN SIGNATURE----- `, string(message), pubKey, chain, signature) }
func makeMasters() { pubKey, chain, mPrivKey := bitcoin.ComputeMastersFromSeed("this is a test") Info(pubKey, ", ", chain, ", ", mPrivKey) // Now create an address for path "0/1/1" privKey := bitcoin.ComputePrivateKey(mPrivKey, chain, "0/1", 1) addr := bitcoin.ComputeAddressForPrivKey("BTC", privKey) // See that the addr matches the other derivation addr2 := bitcoin.ComputeAddress("BTC", pubKey, chain, "0/1", 1) if addr == addr2 { Info("Address matches: %v", addr) } else { Warn("Address does not match: %v vs %v", addr, addr2) } }