Skip to content

Commit

Permalink
getPublicKey + xpubs from path
Browse files Browse the repository at this point in the history
  • Loading branch information
solipsis committed Mar 19, 2018
1 parent 1d909a4 commit a21dbbb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cmd/getPublicKey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

import (
"fmt"
"os"

"github.com/solipsis/go-keepkey/pkg/keepkey"
"github.com/spf13/cobra"
)

func init() {
getPublicKeyCmd.Flags().StringVarP(&nodePath, "nodePath", "p", "44'/0'/0'/0/0", "BIP44 node path")
getPublicKeyCmd.Flags().BoolVarP(&buttonProtection, "display", "d", false, "Display the address on the device")
rootCmd.AddCommand(getPublicKeyCmd)
}

var getPublicKeyCmd = &cobra.Command{
Use: "getPublicKey",
Short: "Get a public key for a nodePath including the XPUB",
Long: "Gets a public key for a nodePath including the XPUB",
Run: func(cmd *cobra.Command, args []string) {

// Parse path
path, err := keepkey.ParsePath(nodePath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

node, xpub, err := kk.GetPublicKey(path, "secp256k1", buttonProtection)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("XPUB: ", xpub)
//TODO: prettier node printing
fmt.Println("Node: ", node)
},
}

0 comments on commit a21dbbb

Please sign in to comment.