Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste 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. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where named args for integral literals may be used (e.g.
2026-11-07 03:08:11 |
2f74637 to
9422834
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
9422834 to
62e70eb
Compare
|
Concept ACK |
Apply the four reconstruction commits on top of the latest bitcoin#36442, keeping its newer predecessor implementation and the private-key substitution integration.
Apply the wallet relationship commits onto the latest bitcoin#36442 and bitcoin#36443 implementations. Integrate known-key substitution and repair extracted functional-test setup.
Apply the wallet relationship commits onto the latest bitcoin#36442 and bitcoin#36443 implementations. Integrate known-key substitution and repair extracted functional-test setup. Integration fixes carried by this merge: - Fix Clang -Wthread-safety errors by locking each descriptor manager when reading its multipath descriptor or updating its relationships. - Snapshot local keys, cache and relative IDs before acquiring relatives' locks, and retain shared descriptor ownership during reconstruction. - Reconstruct exported multipath descriptors before taking the caller's descriptor lock, avoiding receive/change lock-order inversions.
Apply the four reconstruction commits on top of the latest bitcoin#36442, keeping its newer predecessor implementation and the private-key substitution integration. Include <variant> for the comparison operators used by multipath reconstruction, satisfying IWYU 23 without relying on transitive includes.
Apply the wallet relationship commits onto the latest bitcoin#36442 and bitcoin#36443 implementations. Integrate known-key substitution and repair extracted functional-test setup. Integration fixes carried by this merge: - Fix Clang -Wthread-safety errors by locking each descriptor manager when reading its multipath descriptor or updating its relationships. - Snapshot local keys, cache and relative IDs before acquiring relatives' locks, and retain shared descriptor ownership during reconstruction. - Reconstruct exported multipath descriptors before taking the caller's descriptor lock, avoiding receive/change lock-order inversions.
Apply the four reconstruction commits on top of the latest bitcoin#36442, keeping its newer predecessor implementation and the private-key substitution integration. Include <variant> for the comparison operators used by multipath reconstruction, satisfying IWYU 23 without relying on transitive includes.
Apply the wallet relationship commits onto the latest bitcoin#36442 and bitcoin#36443 implementations. Integrate known-key substitution and repair extracted functional-test setup. Integration fixes carried by this merge: - Fix Clang -Wthread-safety errors by locking each descriptor manager when reading its multipath descriptor or updating its relationships. - Snapshot local keys, cache and relative IDs before acquiring relatives' locks, and retain shared descriptor ownership during reconstruction. - Reconstruct exported multipath descriptors before taking the caller's descriptor lock, avoiding receive/change lock-order inversions.
fametrano
left a comment
There was a problem hiding this comment.
ReconstructMultipath accepts relatives that repeat a path value, and then returns a descriptor that is not their multipath form.
I tested it with a small harness against btclib-wallet, a BIP389 implementation I maintain. Its expansions of 24 multipath descriptors each came back as the original. Thirteen mismatched sets (different keys, function, threshold, timelock, key order, tree shape, origin, wildcard or range, two changed steps in one key, musig steps at both levels) return null, as they should.
Repeated values are not caught. wpkh(X/0/*), wpkh(X/1/*), wpkh(X/0/*) gives wpkh(X/<0;1;0>/*), which Parse refuses as a duplicate. wpkh(X/0/*) twice and then wpkh(X/1/*) gives wpkh(X/<0;1>/*): two elements for three inputs. Two identical inputs give the single-path descriptor back. In BIP32PubkeyProvider::ReconstructMultipath, each relative is compared with p after AddMultipathIndex has already extended it. So a repeat is skipped while p still holds one index, and appended once it holds more. Nothing checks the indexes already in p, or that the step ends with one index per input. The inline suggestions add both checks, with a test for the repeated cases, musig included. I can share the harness and its outputs.
| return false; | ||
| } | ||
| multipath_pos = i; | ||
| p.AddMultipathIndex(rp.Index(0)); |
There was a problem hiding this comment.
A relative whose index is already in the step is a repeat, so reject it.
| p.AddMultipathIndex(rp.Index(0)); | |
| if (std::ranges::find(p.Indexes(), rp.Index(0)) != p.Indexes().end()) return false; | |
| p.AddMultipathIndex(rp.Index(0)); |
| return false; | ||
| } | ||
| multipath_pos = i; | ||
| p.AddMultipathIndex(rp.Index(0)); |
There was a problem hiding this comment.
Same check for the musig path.
| p.AddMultipathIndex(rp.Index(0)); | |
| if (std::ranges::find(p.Indexes(), rp.Index(0)) != p.Indexes().end()) return false; | |
| p.AddMultipathIndex(rp.Index(0)); |
| } | ||
| } | ||
|
|
||
| return out; |
There was a problem hiding this comment.
Fail unless the step ends with one index per input. This also rejects identical inputs.
| return out; | |
| // Each relative must add one multipath index | |
| if (!relatives.empty() && multipath_len != relatives.size() + 1) return nullptr; | |
| return out; |
| CheckFailedMultipathReconstruction({ | ||
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/1))", | ||
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/9/*h,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/1))", | ||
| }); |
There was a problem hiding this comment.
Add the repeated-value cases, with and without musig.
| }); | |
| }); | |
| CheckFailedMultipathReconstruction({ | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/1)", | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| }); | |
| CheckFailedMultipathReconstruction({ | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/1)", | |
| }); | |
| CheckFailedMultipathReconstruction({ | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| "wpkh(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)", | |
| }); | |
| CheckFailedMultipathReconstruction({ | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/1)", | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/2)", | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/1)", | |
| }); | |
| CheckFailedMultipathReconstruction({ | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/1)", | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/1)", | |
| "tr(musig(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y)/2)", | |
| }); |
62e70eb to
3b15fde
Compare
We will want to have member functions on KeyPath later, so make it a class now.
Moves all of the multipath parsing into ParseHDKeypath, and let KeyPathElement be a multipath element.
Internally, descriptor parsing will produce multipath descriptor objects rather than std::vector<DescriptorImpl>. This single multipath descriptor becomes std::vector<Descriptor> within Parse. Future commits will return the single multipath descriptor object for all descriptor parsing.
Instead of a std::vector<std::unique_ptr<Descriptor>>, Parse can return a single std::unique_ptr<Descriptor> that contains the multipath information if the descriptor was multipath. Callers that require the multipath expansion use GetMultipathExpansion() to get the expanded descriptors.
3b15fde to
09d019a
Compare
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
Concept ACK, seems like a natural follow-up of the precursor #36442. |

#36442 allows multipath descriptors to be represented in a single
Descriptorobject.GetMultipathExpansionreturns the multiple descriptors represented by a multipath descriptor. This expansion is reversible - given the expansion in the order of the multipath elements, it is possible to determine what the original multipath descriptor was. This PR addsReconstructMultipathto produce a newDescriptorrepresenting the multipath descriptor that produced the expansion.Depends on #36442