Repository navigation
Conversation
BIP 380 states that H is a valid hardened indicator.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32788. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
H as a hardened indicator
|
Concept ACK, see bitcoin/bips#1803 |
| if (elem.size() > 0) { | ||
| const char last = elem[elem.size() - 1]; | ||
| if (last == '\'' || last == 'h') { | ||
| if (last == '\'' || last == 'h' || last == 'H') { |
There was a problem hiding this comment.
nit: perhaps you can add a comment about the key expression specification in BIP380..
Dorex45
left a comment
There was a problem hiding this comment.
Great update! Supporting both 'H' and 'h' for hardened keys makes things easier for everyone and helps avoid confusion. The extra tests are a nice touch too. Thanks for making this even more user-friendly!
janb84
left a comment
There was a problem hiding this comment.
ACK b625265
This PR adds capital H to the parser as a valid Hardened indicator for the descriptor. Capital H usage as an indicator is per BIP-380 spec. This makes the ParseKeyPathNum function adhere (more) to the BIP spec.
- Code review ✅
- Build and tested ✅
- Checked that the test fails if the addition to the parser is removed. ✅
There was a problem hiding this comment.
Concept ACK b625265
I feel the following site should also be updated for uniformity in this PR.
Nit: This condition can also be extracted out in a IsHardenedIndicator(char input) utility that can be reused to avoid any misses in the future.
bitcoin/src/test/descriptor_tests.cpp
Line 495 in c584966
| Check("combo([01234567]xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc)", "combo([01234567]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL)", "combo([01234567]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL)", SIGNABLE, {{"2102d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0ac","76a91431a507b815593dfc51ffc7245ae7e5aee304246e88ac","001431a507b815593dfc51ffc7245ae7e5aee304246e","a9142aafb926eb247cb18240a7f4c07983ad1f37922687"}}, std::nullopt, /*op_desc_id=*/uint256{"7f127f7861594e3ede449eb47a7cc623c753acc0b0f0fc03fbb2dac636c20d6f"}); | ||
| Check("pk(xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0)", "pk(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", "pk(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", DEFAULT, {{"210379e45b3cf75f9c5f9befd8e9506fb962f6a9d185ac87001ec44a8d3df8d4a9e3ac"}}, std::nullopt, /*op_desc_id=*/uint256{"0e54cf04f2bb8d607e2241d611d169c6f7d78f0ab1f15a80642192a19fbdb7cc"}, {{0}}); | ||
| Check("pkh(xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U/2147483647'/0)", "pkh(xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/2147483647'/0)", "pkh([bd16bee5/2147483647h]xpub69H7F5dQzmVd3vPuLKtcXJziMEQByuDidnX3YdwgtNsecY5HRGtAAQC5mXTt4dsv9RzyjgDjAQs9VGVV6ydYCHnprc9vvaA5YtqWyL6hyds/0)", HARDENED, {{"76a914ebdc90806a9c4356c1c88e42216611e1cb4c1c1788ac"}}, OutputType::LEGACY, /*op_desc_id=*/uint256{"35a5cf511e941a35b9cb0cf515d3ef887aa4246db87d6af463265a386ad856fe"}, {{0xFFFFFFFFUL,0}}); | ||
| Check("pkh([deadbeef/1H/1'/1h]xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U/2147483647H/0h/0'/0)", "pkh([deadbeef/1H/1'/1h]xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/2147483647H/0h/0'/0)", "pkh([deadbeef/1h/1h/1h/2147483647h/0h/0h]xpub6D9zrB5MDjRMPNekz6itAEnsEXGu6vM57F8UYAkK66vUchHcACsMtvafSvTq7qS1LvB8RV9MkUiYvUrDgUTg7xYxTKAHV2ptuZSqJRoiqv8/0)", HARDENED, {{"76a914dafb9a0f0bc515b9ba064af19fb2e22c575f0b3188ac"}}, OutputType::LEGACY, /*op_desc_id=*/std::nullopt, {{0x80000001UL, 0x80000001UL, 0x80000001UL, 0xFFFFFFFFUL, 0x80000000UL, 0x80000000UL, 0}}, /*spender_nlocktime=*/0, /*spender_nsequence=*/CTxIn::SEQUENCE_FINAL, /*preimages=*/{}, "pkh([deadbeef/1'/1'/1']xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U/2147483647'/0'/0'/0)", "pkh([deadbeef/1'/1'/1']xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/2147483647'/0'/0'/0)"); |
There was a problem hiding this comment.
+1 on passing the max int value in the test.
|
Concept ACK Can you modify one of the functional tests to cover the use of |
|
Why is another way to specify hardened derivation needed? Is anyone using it? Seems better to remove I'm sure most of the software out there rejects anything besides |
rkrux
left a comment
There was a problem hiding this comment.
In addition to this comment #32788 (review),
this site for hardened range derivation should also be updated inside ParsePubkeyInner that is called via descriptor Parse, I think a common utility function here could prove to be robust. Maybe a functional test change as suggested in this #32788 (comment) could have caught this discrepancy.
bitcoin/src/script/descriptor.cpp
Line 1567 in c584966
Also, updated comments in the following places would be good to have:
➜ bitcoin git: git grep -n "' or h" src/script/descriptor.cpp
src/script/descriptor.cpp:374: // Whether ' or h is used in harded derivation
src/script/descriptor.cpp:1648: * @param[in] split BIP32 path string, using either ' or h for hardened derivation
I would prefer the removal from BIP if no other software is using it but I'm not sure if there is a way to comprehensively verify if this has not been used in the past (bitcoin/bips#1643). And with the lack of such a verification, the allowance in core wallet seems required to me. |
|
My guess is that some wallets use ALL CAPS descriptors in order to generate smaller QR codes. Not sure how useful that is when you have a mixed case xpub and other characters that are not in the limited set, e.g. |
i think the argument is circular. How those "softwares" worked up until this point? Adding it now to ref implementation will cause that someone will start using it and then all wallet implementations will need to implement, or stay incompatible. thanks @Sjors, I didn't know that is possible. I thought you need just alphanumeric for that. |
We don't know, which is kind of the point of this PR. The text of the BIP has always stated that The document the BIP is based on (doc/descriptors.md) did not state that However, there was also a test vector that had Since this discrepancy was only flagged a few months ago, it seems like there are multiple possibilities of what could have happened:
The 2 primary implementations of descriptors are probably Bitcoin Core and rust-miniscript. Looking at rust-miniscript, it seems that they also did not allow Maybe I'll ask on the mailing list again. |
In my understanding, BIP 380 is intended to describe an implementation-independent language for describing output scripts, while Bitcoin Core is specified as a reference implementation in the BIP, isn't it a better course of action to modify the reference implementation to more closely match the spec than to change out the spec from under existing 1 implementations? Footnotes
|
If I did my back of the napkin math correctly, you could encode an xpub into a format like bech32, encoded into QR alphanumeric mode and save ~15% over a base58 encoded xpub in QR binary mode. Since afaik nobody has bothered exploring this, maybe it's of dubious value, and if you wanted to encode full descriptors you'd probably need some kind of escape sequence for |
I think it would be nice in general to have a bech32m encoding for extended keys, because part of the reason why descriptors look weird is the mix of bech32 and base58. Like Silent Payment addresses it could just concatenate the public key and chain code. For the human readable prefix Additionally you could allow a slightly shorter encoding without checksum, since the descriptor itself already has one, but then it wouldn't comply with bech32m. And people and software might copy xpubs around to generate more complex wallets setups, so they should always have a checksum. |
|
Not merging for now - IIUC if the approach mentioned in https://groups.google.com/u/1/g/bitcoindev/c/IAYEx4zUhHA is taken, this would be closed? |
support for |
|
Moved this to draft for now, given bitcoin/bips#1888. |
|
bitcoin/bips#1888 was merged so this is no longer relevant. |
BIP 380 states that
His a valid hardened indicator.