From 48893a0c75f31ed16afc4d457d7abbac0743bfd0 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Fri, 18 Dec 2020 14:20:44 -0500 Subject: [PATCH] Example for wif to address --- examples/address_from_wif/address_from_wif.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/address_from_wif/address_from_wif.go diff --git a/examples/address_from_wif/address_from_wif.go b/examples/address_from_wif/address_from_wif.go new file mode 100644 index 0000000..89212d7 --- /dev/null +++ b/examples/address_from_wif/address_from_wif.go @@ -0,0 +1,25 @@ +package main + +import ( + "log" + + "github.com/bitcoinschema/go-bitcoin" +) + +func main() { + + // Convert the wif into a private key + privateKey, err := bitcoin.WifToPrivateKey("5KgHn2qiftW5LQgCYFtkbrLYB1FuvisDtacax8NCvumw3UTKdcP") + if err != nil { + log.Fatalf("error occurred: %s", err.Error()) + } + + // Get an address + var address string + if address, err = bitcoin.GetAddressFromPrivateKey(privateKey, true); err != nil { + log.Fatalf("error occurred: %s", err.Error()) + } + + // Success! + log.Printf("found address: %s from private key: %s", address, privateKey) +}