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. |
90a7be3 to
feb2f59
Compare
feb2f59 to
5f0da0f
Compare
Following the discussion on bitcoin#36143, this commit adds a python utility implementing the multisig setup flow tracked in bitcoin#35645 using available RPCs and implements work arounds for missing RPC or wallet features. Adds wallet creation and key generation step. The wallet cannot store a name for a key, so cosigner names live in the setup and are lost on import.
Check a key expression before recording it, and reject private keys, derivation paths, multipath derivations, keys without origin information and duplicates. The wizard also requires the BIP 87 path, which the descriptor layer does not.
Builds the ranged, multipath descriptor from the collected keys and a call to getdescriptorinfo checks the resulting descriptor and supplys the checksum. For taproot the key path is a MuSig2 aggregate of all n keys rather than a fixed or variable NUMS point: it cannot bypass the policy, since spending that way needs every signer, and it avoids the fingerprinting using a well-known internal key would cause.
analyze_descriptor reports what the descriptor requires to spend. Which cosigner we are, and the first receive address, Accepted shapes are wsh(sortedmulti(...)) and, for taproot, tr(KEY,sortedmulti_a(...)) where KEY is either musig() of exactly the keys in the leaf, so that spending by key path needs every cosigner, or the NUMS point, which is provably unspendable. Anything else is rejected. Names are local, so any cosigner we have no name for is reported by fingerprint.
During the import process, the participant swaps their own key expression in the descriptor for the private one since importdescriptors reject a descriptor with no private keys when the wallet has private keys enabled. See bitcoin#35377
5f0da0f to
2803e15
Compare
|
Do we need this in the repository? Seems fine to me if it were just an external script. |
|
Aside from being a demonstration of the multisig setup flow, the utility is intended to become a command-line equivalent of the GUI wizard that ships with Core so users can set up multisig without hand-assembling descriptors. Whether that belongs in the repo is worth settling first. |
There was a problem hiding this comment.
cACK, only cursory code review of wizard.py but the interface and usage looks correct.
As for @sedited wondering if we need this in the repository:
For years, Core having user unfriendly multisig has been exploited by scammers to promote alternative multisig wallets with substantially less scrutiny than this repository.
| Guides an orchestrator/participant through setting up a k-of-n multisig descriptor wallet. | ||
|
|
||
| This utility implements the multisig setup flow tracked in #35645 using available | ||
| RPCs and implements workarounds for missing RPC or wallet feature. |
There was a problem hiding this comment.
| RPCs and implements workarounds for missing RPC or wallet feature. | |
| RPCs and implements workarounds for missing RPC or wallet features. |
| *configurations* | ||
| `rpc` is a wallet rpc handle. | ||
| All steps require an unlocked wallet with private keys enabled. | ||
| A coordinator that does not contribute keys needs a watch-only wallet |
There was a problem hiding this comment.
| A coordinator that does not contribute keys needs a watch-only wallet | |
| A coordinator that does not contribute keys needs a watch-only wallet. |
|
I'm not sure we want this in this repository. Looking at the other scripts in From what I understand in the discussion in #35645, this would not be used, as once the work in the GUI and wallet has finished, that would be preferred. The script is still valuable, but we might not want it with the contrib scripts.
I don't think the goal of Bitcoin Core is to be "non-technologist" friendly, and also adding a new script to the repo does not guarantee that it will be maintained. It is just another piece of code the Bitcoin Core maintainers will need to worry about forever. To me, it makes the most sense to keep this change on your own fork and share it with the group in the thread so they can still use it without merging it into this repo, where it will need to be maintained |
@rxbryan are you willing to maintain this script (including bug fixing) until the RPC obsoletes it?
@Sjors said in #36143 (comment) a wallet c++ implementation is premature and he preferred to:
The script serves as a functional to-do checklist for multisig, with its workarounds deleted as wallet PRs land. The advantage of merging it into this repo is better scrutiny and CI against bugs for adventurous users who'd like to use it on mainnet. |
Yes. I'll maintain it, we have enough test cases to force a maintenance contract on whoever modifies code touching it. |
|
Thanks for putting this together and listing the gaps. That said, I'm leaning Concept NACK on merging this into the repo. Also putting a script in What we can do
|
Even I, supporting the idea of merging this into the repo due to the demand for a well reviewed multisig setup, did not fully code review it due to it's length and my expectation that it would receive cNACKs. What's the absolute smallest it could be made to maximize the number of people willing to review it and minimize the time it takes them? For example were it 100-300 lines I likely would have code reviewed despite my expectations.
Could you modularize it so that each time one of our workarounds lands, we just delete a function or module and replace it with the new RPC? So it's a +1/-?? diff to review? I think that would maximizes the chances of support and review interest.
Agreed, if the goal of this script is to disappear that means we want a terminal or CLI wizard for multisig so that it is eventually replaced by something in C++, I haven't seen that talked about if that is the goal, although I would cACK that also since it's better than nothing and no GUI. |
|
tACK 2803e15 Review nits
|
|
Concept NACK The purpose of #35645 is to add a first class feature into the software, a contrib script is not this, nor is it something that meaningfully contributes to the completion of that feature as most of the work is not visible on RPC, or is in the GUI. |

Per the discussion in #35645, this PR adds a Python utility that performs the multisig setup process, so that RPC and interface work is shaped by what that flow actually needs.
It covers wallet creation, key generation at the BIP 87 path, collecting cosigner keys, assembling a
wsh(sortedmulti())ortr(musig(),sortedmulti_a())descriptor, verifying it, and importing it.Gaps that need new functionality in C++
importdescriptorsrejects a descriptor with no private keys when the wallet has private keys enabled. See wallet: Allow importing of descriptors without private keys when the wallet has the private keys #35377.pkh()forgetdescriptorinfoto parse. See descriptor: Expose key expression parsing #35918, which exposesParsePubkey().createmultisigonly takes plain public keys, not extended keys with origins, and cannot build a ranged or taproot multisig descriptor.Part of #35645.