Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Jul 31, 2023

BIP32 allows both ' and h as hardened derivation marker. Our legacy wallet uses '. Since #26076 our descriptor wallets use h by default.

ParseHDKeypath only supports '. It's currently only used in the legacy wallet context, so this doesn't cause any problems. But it will once #22341 uses it (to parse the RPC path argument for getxpub). Might as well fix it now.

I added a restriction for not combining h and '. Afaik this currently isn't enforced anywhere else in the codebase, including for descriptors, but it seems sane. I've occasionally messed that up in the past.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 31, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

No conflicts as of last run.

@achow101
Copy link
Member

I'm not sure if there's any software that enforces the consistent usage of a hardened marker.

@Sjors
Copy link
Member Author

Sjors commented Aug 1, 2023

We could always relax the constraint if someone has a good use case for not being consistent. For now this method is only foreseen to be used with getxpub where I can't think of an even remotely sane reason. More likely someone will do this by accident and end up confused why their descriptor checksum doesn't match.

@luke-jr
Copy link
Member

luke-jr commented Aug 5, 2023

Seems likely someone somewhere will want to combine two derivation paths, which might use different markers.

@Sjors Sjors force-pushed the 2023/07/parse-hd-keypath branch from c5b287d to 08a8ae9 Compare August 21, 2023 11:07
@Sjors
Copy link
Member Author

Sjors commented Aug 21, 2023

I made the consistency check optional and off by default.

src/util/bip32.h Outdated
* @param[out] keypath the parsed path values
* @param[in] check_hardened_marker Check that hardened deriviation markers h and ' are not mixed.
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Why the extra newline after the doxygen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@Sjors Sjors force-pushed the 2023/07/parse-hd-keypath branch from 08a8ae9 to 9bf2c8a Compare October 26, 2023 06:21
Optionally check for inconsistent use.
@Sjors Sjors force-pushed the 2023/07/parse-hd-keypath branch from 9bf2c8a to 777e5f4 Compare February 13, 2024 13:31
@achow101 achow101 closed this Apr 9, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Apr 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants