Esempio n. 1
0
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)

}
Esempio n. 2
0
func makeWIF() {
	privKey := "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D"
	wif := bitcoin.ComputeWIF("BTC", privKey, true)
	Info("WIF: %v", wif)

	addr := bitcoin.ComputeAddressForPrivKey("BTC", privKey)
	Info("addr: %v", addr)

	pubKey := bitcoin.PubKeyBytesFromPrivKeyBytes(hexDecode(privKey), false)
	Info("pubKey: %v", hexEncode(pubKey))

	addr = bitcoin.AddrFromPubKeyBytes("BTC", pubKey)
	Info("addr2: %v", addr)

	message := "this is a message"
	signature := bitcoin.SignMessage(privKey, message, true)
	Info("signature: %v", signature)
}