-
Notifications
You must be signed in to change notification settings - Fork 414
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
Why does HierarchicalPath::derivePath() now only derive relative paths? #850
Comments
Yea I suppose its a difference to older versions. It didn't make much sense to accept absolute paths for non-root nodes. The old code was too flexible, and I'm pretty sure the old version didn't respect the m / M capitalization effect, so it didn't even do it right. Non-root keys don't store their path, and you'd never want to do something like:
Instead the idea is more like this:
I guess derivePath could be changed to match what people would expect - would the following cover it? if ($this->depth == 0 && ($path[0] == 'm' || $path[0] == 'M')) {
list($wasPrivate, $parts) = $sequences->decodeAbsolute($path);
} else {
$wasPrivate = true;
$parts = $sequences->decodeRelative($path);
} and down the bottom if (!$wasPrivate) {
$key = $key->withoutPrivate();
} |
I think that would be an improvement, yes. regarding m/M... Do any wallets actually enforce that? In my wanderings, I've seen |
yep!
I think that's because both forms refer to the same public key anyway, and the extra bit of info stored in m/M is also available via the extended key's prefix bytes (those ones responsible for xpub/xprv/ypub/zpub). Whilst importing a wallet from the key, and if the wallet implements BIP44/49/84, the extended key's prefix tells you the entire path (m/44'/0'/0' say) unless the user indicates it's custom somehow. Then the software can save whatever version it likes internally |
yeah, so I notice that decodeAbsolute() supports |
I don't really follow the question - it returns an array with two elements - the parts (like decodeRelative) and the value ($parts[0] == 'm'), to tell you which it was. So the caller can recreate the path from this information. bitcoin-php/src/Key/Deterministic/HierarchicalKeySequence.php Lines 34 to 37 in b53ce77
|
ah, so the caller can decide. That seems better. I didn't look at it closely enough. Are you planning to merge the changes in above comment soon? |
bump! |
Hello, can you help me how to send bitcoin from wallet 1 to another wallet? Do you have code for this? Thanks |
hd-wallet-derive has been using an older version of bitcoin-php. When I just tried to update, path derivation of absolute paths fails with error: "Only relative paths accepted".
See
bitcoin-php/src/Key/Deterministic/HierarchicalKey.php
Line 324 in b53ce77
I looked for calls within the lib to HierarchicalKeySequence::deriveAbsolute(), but there don't seem to be any.
Please advise...
The text was updated successfully, but these errors were encountered: