Skip to content

Commit

Permalink
Example for wif to address
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Dec 18, 2020
1 parent c783d2a commit 48893a0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/address_from_wif/address_from_wif.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 48893a0

Please sign in to comment.