mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 12:20:38 +00:00
descriptor: add CreateMultisigDescriptor() #36143
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!36143
Loading…
Reference in a new issue
No description provided.
Delete branch "create-multisig-descriptor"
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?
The multisig setup flows need to assemble a descriptor from collected cosigner keys without hand-crafting the descriptor string, which today means bash interpolation with no validation of key forms, duplicates, or threshold.
CreateMultisigDescriptor() takes a threshold, a list of key expressions with origin info, and an output type, and returns a ranged, multipath wsh(sortedmulti(...)) descriptor with checksum.
Part of the multisig wizard tracking issue #35645.
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/script/descriptor.cpp:complaint hardware wallets→compliant hardware wallets[wrong word changes the intended meaning]2026-11-29 08:11:35
Concept NACK, unless this is part of a larger end-to-end implementation (with some buy-in), like a GUI or RPC that actually uses this new method.
But I also think that's premature. Wallet setup is a one-off thing, and it's not obvious what the best approach is. A Python utility is more flexible. A full c++ implementation is also likely to need a huge stack of commits, see e.g. https://github.com/Sjors/bitcoin/pull/91 which only implements spending from an existing multisig wallet.
So I think the better sequence is:
1.introduce a Python utility that helps the user construct and import a multisig descriptor
2. gradually improve / add RPC methods to simplify that utility and eventually make it unnecessary
Step (2) is where changes like this may be useful.
That sequencing makes sense. Would exposing this via an RPC in the same PR address the "nothing uses it" concern, or do you specifically want the Python flow to exist first so the RPC surface is shaped by what that flow needs?
Yes, but.
I think that's the better yes.
🐙 This pull request conflicts with the target branch and needs rebase.
Following the Python wizard #36325, which exercises the actual setup flow, the contract for
createMultisigDescriptor()is now concrete and has real consumers: the Python utility (#36325), the GUI, and potentially thecreatemultisigRPC.It becomes a function that constructs ranged, multipath descriptors for bech32 and bech32m, as well as the unranged plain-key case createmultisig builds today.
This fits the multisig setup process better because the descriptor is built up front and becomes the source of truth, and bech32m falls out naturally. By contrast,
createmultisigrecovers its descriptor withInferDescriptor, which only sees the script: it always producesmulti(...), since nothing in the script records that the keys were sorted, and its inputs are raw public keys, so there are no origins or ranges to express.Step 1 is #36325.
CreateMultisigDescriptor()would be the first change step 2 asks for.In general it is, we want the GUI to be calling a utility function like this one to construct the descriptors for import.
We already have a
createmultisigRPC, and it should be modernized to produce descriptors.I think this is entirely unnecessary. The RPC already exists, it should be modernized and refactored such that the GUI can use it too.
Earlier concerns neither republished nor resolved: 5 suggestions. See the Run archive linked from the Review report for their assessments.
🔴 Major · Metadata aliases bypass the multisig duplicate-key check
CreateMultisigDescriptor()accepts metadata variants of the samexpubas distinct cosigners, allowing one holder to satisfy a nominal 2-of-3 threshold; no current production caller was found.Location:
src/script/descriptor.cpp:3131(head).🟠 Minor · Depth-254/255
xpubs produce descriptors that cannot expandWith an unusually deep or metadata-altered
xpubat depth 254 or 255,CreateMultisigDescriptor()succeeds although neither branch can generate addresses; no current production caller supplying such inputs was found.Location:
src/script/descriptor.cpp:3154(head).🔵 Suggestion · Private-key rejection echoes secrets in diagnostics
Only unit tests currently call
CreateMultisigDescriptor(), but rejectedWIFandxprvinputs are copied verbatim into its returned diagnostics.Location:
src/script/descriptor.cpp:3104(head).🔵 Suggestion · The Taproot commit lacks its positive construction test
The positive test for
tr(musig(...),sortedmulti_a(...))appears only in the later sorting commit, leaving the Taproot commit without an assertion of the output it introduces.Location: src/script/descriptor.cpp:3068 (commit).
Review coverage was incomplete.
Reviewed:
753744fd5c88· Review report · Previous reportspermalink
createmultisigcan delegate toCreateMultisigDescriptor()for key expressions and bech32m, while keeping its existing contract for hex pubkeys unchanged. That gives the GUI and the RPC one assembly function.Concept ACK
rxbryan wrote that the descriptor is built up front and becomes the source of truth for the setup, so I checked that string against code outside Core, on
589f3fe6b5. Over 98 cases (2 to 6 account xpubs with origin, every threshold, 49 per output type), Core's string equals the descriptor I expected, checksummed by bip32-descriptors, a library I maintain, in 98 of 98. The library derives the same receive and change scriptPubKeys at indexes 0 to 4: 980 of 980, 490 of them Taproot.The string still depends on the order the keys come in: the six orders of the test's three keys give six descriptors and six checksums per output type, with the same scriptPubKeys, so cosigners who enter the keys in a different order get descriptors that do not compare equal. Sorting
canonical_keysbefore assembly gave one descriptor for all six orders, scriptPubKeys unchanged. Could the keys be sorted, or the header say that the string depends on their order?Gist: https://gist.github.com/fametrano/cc31cf590d6f7a977866849b1e67a998/3fb58384cdeb54184ce5f8599e351015c5d8a69e
Thanks @fametrano for the checks.
753744f now sorts the keys so a key set always produces the same descriptor string and checksum, whatever order the keys come in. Also added a test case for it.