mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 14:11:39 +00:00
WIP: descriptor: Reconstruct a multipath descriptor from its expansion #36443
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36443
Loading…
Reference in a new issue
No description provided.
Delete branch "multipath-reconstruction"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#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
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, 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:
src/util/bip32.h:for a give multipath position→for a given multipath position[misspelling]src/test/descriptor_tests.cpp:Failed reconstrcted to private string→Failed to reconstruct private string[misspelling and unclear phrasing]src/test/descriptor_tests.cpp:Failed reconstructed to private string→Failed to reconstruct private string[broken phrasing]Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/qt/test/wallettests.cpp:WalletDescriptor w_desc(std::move(desc), 0, 0, 1, 1)src/script/descriptor.cpp:std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey, false)src/script/descriptor.cpp:std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey, true)src/test/fuzz/scriptpubkeyman.cpp:Parse(desc_str.value(), keys, error, false)src/wallet/scriptpubkeyman.cpp:WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0)src/wallet/scriptpubkeyman.cpp:Parse(desc_str, provider, error, false)src/wallet/scriptpubkeyman.cpp:Parse(desc_str, parsed_keys, parse_error, false)src/wallet/scriptpubkeyman.cpp:WalletDescriptor w_desc(std::move(desc), 0, 0, chain_counter, 0)src/wallet/test/psbt_wallet_tests.cpp:WalletDescriptor w_desc(std::move(desc), 0, 0, 10, 0)src/wallet/test/util.cpp:Parse(desc_str, keys, error, false)src/wallet/test/wallet_tests.cpp:WalletDescriptor w_desc{std::move(desc), 0, 0, 0, 0}src/wallet/wallet.cpp:Parse(desc_str, keys, desc_error, false)src/wallet/walletutil.cpp:Parse(desc_str, keys, error, false)2026-11-07 03:08:11
8 additional verified findings in the full report.
Earlier concerns remain unresolved; see the full report for their current assessments.
🟠 Minor · Reconstruction accepts repeated branches and can produce rejected descriptor syntax
Repeated branches can make reconstruction return duplicate multipath indexes or silently omit an input instead of rejecting the sequence.
Location:
src/script/descriptor.cpp:709(head).🟠 Minor · getdescriptorinfo help still describes the old multipath result
For multipath input,
descriptornow contains the full expression rather than the first branch, but RPC help still promises the old result.Location:
src/rpc/output_script.cpp:212(head).🟠 Minor · Mixed hardened markers change Miniscript compatibility hashes
Preserving each hardened marker changes the COMPAT string and new-import SPKM ID for mixed-marker Miniscript input, despite the documented stable-hash contract.
Location:
src/script/descriptor.cpp:589(head).🔵 Suggestion · Descriptor evaluation rebuilds the multipath expansion at every index
Each ranged derivation index deep-clones the descriptor again and discards fixed-participant MuSig aggregation state that base reused.
Location:
src/rpc/util.cpp:1368(head).🔵 Suggestion · Multipath expansion copies every alternative into every branch
Clone-then-select performs quadratic alternative copies where base's placeholder substitution was linear.
Location:
src/script/descriptor.cpp:1330(head).🔵 Suggestion · Single-path operations silently accept unexpanded multipath objects
Expansion uses branch 0 while origin metadata can retain alternatives, leaving correctness dependent on callers selecting a branch first.
Location:
src/script/descriptor.cpp:530(head).Review coverage was incomplete.
Reviewed:
09d019a4c86c· Full review report · Previous reportspermalink
🚧 At least one of the CI tasks failed.
Task
macOS-cross to arm64: https://github.com/bitcoin/bitcoin/actions/runs/37381386585/job/112003972868LLM reason (✨ experimental): CI failed to compile
walletload_tests.cpp:Parse()returns astd::unique_ptr<Descriptor>, but the code assigns it to a vector of those pointers.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK
🐙 This pull request conflicts with the target branch and needs rebase.
ReconstructMultipathaccepts 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/*)giveswpkh(X/<0;1;0>/*), whichParserefuses as a duplicate.wpkh(X/0/*)twice and thenwpkh(X/1/*)giveswpkh(X/<0;1>/*): two elements for three inputs. Two identical inputs give the single-path descriptor back. InBIP32PubkeyProvider::ReconstructMultipath, each relative is compared withpafterAddMultipathIndexhas already extended it. So a repeat is skipped whilepstill holds one index, and appended once it holds more. Nothing checks the indexes already inp, 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.A relative whose index is already in the step is a repeat, so reject it.
Same check for the musig path.
Fail unless the step ends with one index per input. This also rejects identical inputs.
Add the repeated-value cases, with and without musig.
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK, seems like a natural follow-up of the precursor #36442.