-
Notifications
You must be signed in to change notification settings - Fork 136
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
Infer relative derivation when parent key level > 0 #326
Comments
@Sjors just to be absolutely clear here, what you are looking for is the ability to pass a full path string, but a key that represents not the root of that path but instead a key somewhere along it? And you are proposing that the depth of the key passed in be used to skip that number of elements? Its not certain that the depth of the key passed in will always be correct with respect to the path I think, so adding a flag to use the depth may not be sufficiently robust or general. How would you feel about a A |
Yes. But only if the path starts with
This would help slightly, but it still requires me to parse the path string to see if there's an
BIP32 seems to suggest that the master key ( Let's say a wallet uses an account level xpub, but marks it as depth 0. That's not a problem, assuming that in their absolute path strings the If there are wallets that do this inconsistently, I'm inclined to think those wallets should use relative paths. A |
The problem is that there is no concept of full vs relative paths in bip32, let alone a standardisation of how they should be represented. You can't know that a path is relative just because it lacks a leading
This is just naming,
I think this is unavoidable if you want to ascribe meaning to that prefix. |
I hadn't thought about it in that direction. But when |
Unfortunately not, see e.g https://github.com/rust-bitcoin/rust-bitcoin/blob/master/src/util/bip32.rs#L414 where a derived key of depth 1 is further derived using an |
The new
bip32_key_from_parent_path_str
function takes apath_str
argument. When this starts withm/
it should strip the firstdepth
levels from the path string. Currently it just treats everything as a relative path.This would help me avoid a string manipulation workaround like this:
It's especially useful in de context of PSBT processing, where the PSBT will have absolute paths, but the wallet may want to derive from a (cached) xpub to see if it can sign something, as well as for change detection.
Perhaps a flag could be added to (dis)allow the use of absolute paths when deriving from
depth > 0
since that can lead to mistakes.The text was updated successfully, but these errors were encountered: