From 868b8f2498a4295e437a1039decec78045a5642c Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Wed, 30 Sep 2020 19:23:10 -0400 Subject: [PATCH] Added example for address from private key --- .../address_from_private_key.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/address_from_private_key/address_from_private_key.go diff --git a/examples/address_from_private_key/address_from_private_key.go b/examples/address_from_private_key/address_from_private_key.go new file mode 100644 index 0000000..2a1cae0 --- /dev/null +++ b/examples/address_from_private_key/address_from_private_key.go @@ -0,0 +1,25 @@ +package main + +import ( + "log" + + "github.com/bitcoinschema/go-bitcoin" +) + +func main() { + + // Start with a private key + privateKey, err := bitcoin.CreatePrivateKeyString() + if err != nil { + log.Fatalf("error occurred: %s", err.Error()) + } + + // Get an address + var address string + if address, err = bitcoin.AddressFromPrivateKey(privateKey); err != nil { + log.Fatalf("error occurred: %s", err.Error()) + } + + // Success! + log.Printf("found addres: %s from private key: %s", address, privateKey) +}