derivekey: add new --identity flag for lnd identity_pubkey

pull/20/head
Oliver Gugger 3 years ago
parent f78b4e07b7
commit 7a3c9a3f0b
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -21,8 +21,9 @@ Extended private key (xprv): %s
`
type deriveKeyCommand struct {
Path string
Neuter bool
Path string
Neuter bool
Identity bool
rootKey *rootKey
cmd *cobra.Command
@ -36,7 +37,9 @@ func newDeriveKeyCommand() *cobra.Command {
Long: `This command derives a single key with the given BIP32
derivation path from the root key and prints it to the console.`,
Example: `chantools derivekey --path "m/1017'/0'/5'/0/0'" \
--neuter`,
--neuter
chantools derivekey --identity`,
RunE: cc.Execute,
}
cc.cmd.Flags().StringVar(
@ -47,6 +50,10 @@ derivation path from the root key and prints it to the console.`,
&cc.Neuter, "neuter", false, "don't output private key(s), "+
"only public key(s)",
)
cc.cmd.Flags().BoolVar(
&cc.Identity, "identity", false, "derive the lnd "+
"identity_pubkey",
)
cc.rootKey = newRootKey(cc.cmd, "decrypting the backup")
@ -59,6 +66,11 @@ func (c *deriveKeyCommand) Execute(_ *cobra.Command, _ []string) error {
return fmt.Errorf("error reading root key: %v", err)
}
if c.Identity {
c.Path = lnd.IdentityPath(chainParams)
c.Neuter = true
}
return deriveKey(extendedKey, c.Path, c.Neuter)
}

@ -15,7 +15,9 @@ chantools derivekey [flags]
```
chantools derivekey --path "m/1017'/0'/5'/0/0'" \
--neuter
--neuter
chantools derivekey --identity
```
### Options
@ -23,6 +25,7 @@ chantools derivekey --path "m/1017'/0'/5'/0/0'" \
```
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
-h, --help help for derivekey
--identity derive the lnd identity_pubkey
--neuter don't output private key(s), only public key(s)
--path string BIP32 derivation path to derive; must start with "m/"
--rootkey string BIP32 HD root key of the wallet to use for decrypting the backup; leave empty to prompt for lnd 24 word aezeed

@ -133,6 +133,13 @@ func ShaChainFromPath(extendedKey *hdkeychain.ExtendedKey,
return shachain.NewRevocationProducer(*revRoot), nil
}
func IdentityPath(params *chaincfg.Params) string {
return fmt.Sprintf(
LndDerivationPath+"/0/0", params.HDCoinType,
keychain.KeyFamilyNodeKey,
)
}
func AllDerivationPaths(params *chaincfg.Params) ([]string, [][]uint32, error) {
mkPath := func(f keychain.KeyFamily) string {
return fmt.Sprintf(

Loading…
Cancel
Save