From fe1f2a470c8c2c9d363fe6943cf630f6ced2d969 Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Fri, 20 Jul 2018 00:44:36 -0700 Subject: [PATCH] update makefile --- Makefile | 8 ++++++++ example/keys.go | 21 ++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index c9c9c48..ddbd030 100644 --- a/Makefile +++ b/Makefile @@ -29,3 +29,11 @@ run/example/1: .PHONY: run/example/2 run/example/2: @go run example/sign.go + +.PHONY: run/example/3 +run/example/3: + @go run example/seed.go + +.PHONY: run/example/4 +run/example/4: + @go run example/keys.go diff --git a/example/keys.go b/example/keys.go index 45a8d40..5162ec8 100644 --- a/example/keys.go +++ b/example/keys.go @@ -9,8 +9,7 @@ import ( func main() { mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy" - fmt.Println("deriving from mnenonic") - fmt.Println(mnemonic) + wallet, err := hdwallet.NewFromMnemonic(mnemonic) if err != nil { log.Fatal(err) @@ -22,12 +21,20 @@ func main() { log.Fatal(err) } - fmt.Println("account address", account.Address.Hex()) + fmt.Printf("Account address: %s\n", account.Address.Hex()) + + privateKey, err := wallet.PrivateKeyHex(account) + if err != nil { + log.Fatal(err) + } - pk, _ := wallet.PrivateKeyHex(account) - fmt.Println("private key hex: ", pk) + fmt.Printf("Private key in hex: %s\n", privateKey) + + publicKey, _ := wallet.PublicKeyHex(account) + if err != nil { + log.Fatal(err) + } - pub, _ := wallet.PublicKeyHex(account) - fmt.Println("public key hex: ", pub) + fmt.Printf("Public key in hex: %s\n", publicKey) }