-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
derivekey: support xpubs in addition to xprvs #179
base: master
Are you sure you want to change the base?
Conversation
This test checks that "chantools derivekey --rootkey xpriv..." works.
Added more derivation paths and corresponding public keys, check in the test that the values returned by the method match to expected values. Also added tpub (testnet xpub). To run "chantools derivekey" with xpubs, use PR lightninglabs/chantools#179
It can work with xpub and xprv to derive child xpub or xpriv and public key. It can be used when only xpub is available.
Now it is possible to derive a public key from xpub: chantools derivekey --rootkey xpub... --path "m/0/0" --neuter
if neuter { | ||
child, pubKey, err = lnd.DerivePubKey( | ||
extendedKey, path, | ||
) | ||
} else { | ||
child, pubKey, wif, err = lnd.DeriveKey( | ||
extendedKey, path, chainParams, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think pubKey
is the same in both cases. Which means we can just keep the lnd.DeriveKey
call, remove the lnd.DerivePubKey
calling clause, and then later ignore wif
if neuter == true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeriveKey
fails if an xpub is passed to it (in derivedKey.ECPrivKey
call):
Error: could not derive keys: could not derive private key: unable to create private keys from a public extended key
Added more derivation paths and corresponding public keys, check in the test that the values returned by the method match to expected values. Also added tpub (testnet xpub). To run "chantools derivekey" with xpubs, use PR lightninglabs/chantools#179
Now it is possible to derive a public key from xpub if
--neuter
is passed:Example:
Also added tests
TestDeriveKeyXprv
andTestDeriveKeyXpub
.