Contrib: add multisig wizard #36325

Closed
rxbryan wants to merge 5 commits from contrib_multisig into master AGit
rxbryan commented 2026-09-24 12:21:15 +00:00 (Migrated from github.com)

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()) or tr(musig(),sortedmulti_a()) descriptor, verifying it, and importing it.

Gaps that need new functionality in C++

  • importdescriptors rejects a descriptor with no private keys when the wallet has private keys enabled. See #35377.
  • The wallet stores a multipath descriptor as two descriptors, so listdescriptors never shows the descriptor that was shared. See #36133.
  • The wallet labels addresses, not keys, so cosigner names live in the setup and are lost on import.
  • There is no RPC for validating a key expression, so the key is wrapped in pkh() for getdescriptorinfo to parse. See #35918, which exposes ParsePubkey().
  • createmultisig only takes plain public keys, not extended keys with origins, and cannot build a ranged or taproot multisig descriptor.
  • Nothing reports what a descriptor commits to, or whether this wallet holds one of its keys, before it is imported.

Part of #35645.

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())` or `tr(musig(),sortedmulti_a())` descriptor, verifying it, and importing it. ### Gaps that need new functionality in C++ - `importdescriptors` rejects a descriptor with no private keys when the wallet has private keys enabled. See #35377. - The wallet stores a multipath descriptor as two descriptors, so listdescriptors never shows the descriptor that was shared. See #36133. - The wallet labels addresses, not keys, so cosigner names live in the setup and are lost on import. - There is no RPC for validating a key expression, so the key is wrapped in `pkh()` for `getdescriptorinfo` to parse. See #35918, which exposes `ParsePubkey()`. - `createmultisig` only takes plain public keys, not extended keys with origins, and cannot build a ranged or taproot multisig descriptor. - Nothing reports what a descriptor commits to, or whether this wallet holds one of its keys, before it is imported. Part of #35645.
DrahtBot commented 2026-09-24 12:21:24 +00:00 (Migrated from github.com)

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.

Type Reviewers
ACK BenWestgate
Concept NACK pseudoramdom

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:

  • #29247 (CAT in Tapscript (BIP-347) by arminsabouri)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36325 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36325.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36325#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [BenWestgate](https://github.com/bitcoin/bitcoin/pull/36325#issuecomment-6488924478) | | Concept NACK | [pseudoramdom](https://github.com/bitcoin/bitcoin/pull/36325#issuecomment-6373344413) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#29247](https://github.com/bitcoin/bitcoin/pull/29247) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29247.svg"></sub> (CAT in Tapscript (BIP-347) by arminsabouri) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
sedited commented 2026-09-25 07:43:50 +00:00 (Migrated from github.com)

Do we need this in the repository? Seems fine to me if it were just an external script.

Do we need this in the repository? Seems fine to me if it were just an external script.
rxbryan commented 2026-09-26 08:33:23 +00:00 (Migrated from github.com)

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.
The workarounds in it will eventually be superseded as functionality is moved to C++.

Whether that belongs in the repo is worth settling first.

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. The workarounds in it will eventually be superseded as functionality is moved to C++. Whether that belongs in the repo is worth settling first.
BenWestgate (Migrated from github.com) reviewed 2026-09-30 00:18:39 +00:00
BenWestgate (Migrated from github.com) left a 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 a while now, Core offline signing and multisig being non-technologist unfriendly has been exploited by scammers to push alternative multisig and airgap wallets with substantially less review than this repository.

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 a while now, Core offline signing and multisig being non-technologist unfriendly has been exploited by scammers to push alternative multisig and airgap wallets with substantially less review than this repository.
BenWestgate (Migrated from github.com) commented 2026-09-29 23:44:11 +00:00
RPCs and implements workarounds for missing RPC or wallet features.
```suggestion RPCs and implements workarounds for missing RPC or wallet features. ```
BenWestgate (Migrated from github.com) commented 2026-09-29 23:45:00 +00:00
A coordinator that does not contribute keys needs a watch-only wallet.
```suggestion A coordinator that does not contribute keys needs a watch-only wallet. ```
First-time contributor

4 minor findings · 4 suggestions · 2 previous findings

🟠 Minor

Repeated keys are counted as separate multisig cosigners

Location: contrib/multisig/wizard.py:201 (head).

A received descriptor can pass verification as k-of-n even when one key holder can fill multiple signing slots.

Details and suggested fix

parse_multi() returns every key without checking for duplicates, and Core accepts repeated keys in these multisig expressions. As a result, a received wsh(sortedmulti(2,A/<0;1>/*,B/<0;1>/*,B/<0;1>/*)) is reported as 2-of-3 and imports, although B's holder can satisfy both B slots and spend without A. The same issue affects tr(musig(...),sortedmulti_a(...)) when the repeated keys match on both sides. The add_cosigner() check also compares serialized xpub strings, so the same account key can pass when re-encoded with different origin metadata. Compare decoded public keys and chain codes, ignoring origin and serialization metadata, and reject or prominently warn about repeats in both new and received descriptors.

Previous reports

First reported at 2803e1518bb22394a80bac94e2435bb3982d0cde. Last checked at 2803e1518bb22394a80bac94e2435bb3982d0cde.

🟠 Minor

Key matching calls derivehdkey with paths the RPC rejects

Location: contrib/multisig/wizard.py:274 (head).

For certain accepted keys, verify() and import_descriptor() abort with an RPC error instead of recognizing a key the wallet holds.

Details and suggested fix

derivehdkey rejects paths with no hardened step, but find_own_key() calls it with m for an exact xpub match and with the descriptor's origin path in the derived-key branch. An account xprv stored as an unused key can therefore fail the exact-match branch. The derived-key branch can fail for received descriptors with a fingerprint-only origin or an origin containing only unhardened steps. In either case, a participant whose wallet holds an unused key cannot verify or import the descriptor. For an exact match, use the xprv from gethdkeys(private=True); in the derived branch, skip candidates whose origin has no hardened step. generate_key() only creates master-level unused keys, and no checked-in caller builds such a descriptor, so production impact is unconfirmed.

Previous reports

First reported at 2803e1518bb22394a80bac94e2435bb3982d0cde. Last checked at 2803e1518bb22394a80bac94e2435bb3982d0cde.

🟠 Minor

Received descriptors can import another cosigner's private key

Location: contrib/multisig/wizard.py:221 (head).

A shared descriptor containing a cosigner's xprv can give the importer enough signing keys to spend below the reported threshold.

Details and suggested fix

analyze_descriptor() calls getdescriptorinfo() but does not check hasprivatekeys, and it retains the original descriptor body. import_descriptor() submits that body after replacing only the participant's own key. If a received descriptor contains another cosigner's xprv, verification still reports the stated threshold, while import stores that private key in the participant's wallet. In a 2-of-3, the importer then holds two keys and can sign alone. Reject descriptors for which getdescriptorinfo() reports hasprivatekeys, and add a verification and import test for this case. No checked-in caller produces such a descriptor, so production impact is unconfirmed.

🟠 Minor

Importing a second multisig makes it active and redirects change

Location: contrib/multisig/wizard.py:345 (head).

In a wallet holding two vaults of the same output type, a spend from one vault can send change to the other, and coin selection can combine both vaults' coins.

Details and suggested fix

import_descriptor() always imports with active: True, which replaces the wallet's active external and internal descriptors for that output type. The existing second-multisig test confirms that getnewaddress then returns the second vault's address. A later spend from the wallet can send change from vault-1 coins to vault 2, whose cosigners or threshold may differ. Coin selection can also select coins from both vaults, requiring both cosigner sets to sign and linking the vaults on-chain. Either keep one wallet per setup, as create_wallet() already names the wallet after the setup, and refuse imports when an active descriptor of that type exists; or import additional multisigs as inactive behind an explicit option and document the behavior.

🔵 Suggestion

The account parameter derives from a new seed on every call

Location: contrib/multisig/wizard.py:51 (head).

account=N suggests account separation under one seed, but each call to generate_key() creates a fresh seed.

Details and suggested fix

generate_key() calls addhdkey() without an argument, which generates a new random seed, and then derives m/87h/{coin}h/{account}h from that seed. Thus, generate_key(cosigner_wallet, account=1) on a wallet that already holds a seed creates keys from a new seed at account 1, not account 1 of the existing seed. The account index does not separate keys, and restoring only the first seed will not recover later keys. Reuse the existing unused seed when there is exactly one, calling addhdkey() only when there is none; alternatively, remove account from generate_key() and document that each multisig uses a fresh seed.

🔵 Suggestion

verify() fetches private keys it does not use

Location: contrib/multisig/wizard.py:277 (head).

Each verify() call sends account xprvs over JSON-RPC even though verification needs only a public-key match.

Details and suggested fix

find_own_key() always calls derivehdkey with private=True, but verify() retains only the matched public-key expression. Deriving the public key requires the same hardened path and wallet unlock, so verification can use private=False without changing the match. As written, it fetches an xprv over the RPC connection for every hardened origin path in the descriptor and every unused seed. Add a private flag to find_own_key() and enable it only when import_descriptor() calls the helper.

🔵 Suggestion

The NUMS xpub check rejects derived and test-network forms

Location: contrib/multisig/wizard.py:247 (head).

Descriptors using a derived NUMS xpub or a test-network encoding are rejected, and the constant itself is not exercised by the functional test.

Details and suggested fix

analyze_descriptor() accepts a NUMS key path only when the internal key exactly equals NUMS_H or NUMS_H_XPUB. The latter is a mainnet xpub that getdescriptorinfo rejects on test chains, so the functional test exercises only NUMS_H. A NUMS xpub with /<0;1>/* derivation falls through to the error that the key path may be spendable on its own, even though its children remain unspendable. To support this descriptor form, recognize network-appropriate NUMS xpubs with the multipath suffix and add a check that decodes the constant to 02||NUMS_H. Alternatively, remove NUMS_H_XPUB if an underived xpub is unnecessary.

🔵 Suggestion

The README incorrectly requires private keys for every step

Location: contrib/multisig/README.md:10 (head).

The instructions may lead a watch-only coordinator to use a wallet with private keys even though it does not need one.

Details and suggested fix

The README says every step requires an unlocked wallet with private keys enabled, then says a coordinator that contributes no key needs a watch-only wallet. The code and functional tests support a watch-only coordinator running verification and import. Clarify that generate_key() and participant imports need an unlocked private-key wallet, while a coordinator that contributes no key can use a watch-only wallet for verification and import.


Previous findings (2)
[Minor · still present] Origin-tagged raw public keys pass validation but cannot be ranged

add_cosigner() can accept a key that later makes descriptor assembly fail after all cosigner keys have been collected.

validate_key() accepts an origin-annotated hex public key when its origin has the expected BIP 87 path. build_descriptor() then appends /<0;1>/* to every key, but Core accepts a raw hex key only without a derivation suffix. As a result, getdescriptorinfo fails and assemble() reports only Invalid descriptor. Require an extended key in validate_key(), for example by checking that pkh({key}/*) parses, and add tests for origin-tagged compressed and uncompressed raw keys. No checked-in caller supplies this form, so production impact is unconfirmed.

Location: contrib/multisig/wizard.py:81 (head).

First reported at 2803e1518bb22394a80bac94e2435bb3982d0cde. Last checked at 2803e1518bb22394a80bac94e2435bb3982d0cde.

[Minor · still present] Importing with timestamp "now" can hide payments made before import

A participant or watch-only coordinator importing after funding will not see earlier payments until a rescan.

verify() returns the first receive address before import, but import_descriptor() always passes timestamp: "now". That timestamp bypasses scanning for outputs known never to have been used; the RPC otherwise scans only two hours before the supplied timestamp. If the address was paid earlier, the wallet misses the payment until someone runs rescanblockchain, and getnewaddress can return the already-used address in the meantime. Record a creation time in setup() or accept a timestamp and pass it to importdescriptors. The intended order has every participant importing before funding, and no checked-in caller funds before import, so production impact is unconfirmed.

Location: contrib/multisig/wizard.py:345 (head).

First reported at 2803e1518bb22394a80bac94e2435bb3982d0cde. Last checked at 2803e1518bb22394a80bac94e2435bb3982d0cde.

Review coverage was incomplete.


Reviewed: 2803e1518bb2 · Full review report · Previous reports

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:87bdde6e11c8200ebab55606962dbcbbed1f25d8bebf674c6c6e659db1fe52cc:8f5adaa231eb1aff4d179f52d5ea908b8cc3066455d0b32a1baa87e2b34c9f86 --> <!-- ralph-base:9bf4815b94b9eaf8807f4e569091778da6c338d5 --> <!-- ralph-head:2803e1518bb22394a80bac94e2435bb3982d0cde --> <!-- ralph-case:319be3b9c2951db14299b84d0112e15dd8c06552905bdce0b1a29c3314e4fbc7 --> 4 minor findings · 4 suggestions · 2 previous findings **🟠 Minor** **Repeated keys are counted as separate multisig cosigners** Location: [`contrib/multisig/wizard.py:201`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L201>) (head). A received descriptor can pass verification as k-of-n even when one key holder can fill multiple signing slots. <details> <summary>Details and suggested fix</summary> `parse_multi()` returns every key without checking for duplicates, and Core accepts repeated keys in these multisig expressions. As a result, a received `wsh(sortedmulti(2,A/<0;1>/*,B/<0;1>/*,B/<0;1>/*))` is reported as 2-of-3 and imports, although B's holder can satisfy both B slots and spend without A. The same issue affects `tr(musig(...),sortedmulti_a(...))` when the repeated keys match on both sides. The `add_cosigner()` check also compares serialized xpub strings, so the same account key can pass when re-encoded with different origin metadata. Compare decoded public keys and chain codes, ignoring origin and serialization metadata, and reject or prominently warn about repeats in both new and received descriptors. </details> <details> <summary>Previous reports</summary> First reported at `2803e1518bb22394a80bac94e2435bb3982d0cde`. Last checked at `2803e1518bb22394a80bac94e2435bb3982d0cde`. </details> **🟠 Minor** **Key matching calls derivehdkey with paths the RPC rejects** Location: [`contrib/multisig/wizard.py:274`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L274>) (head). For certain accepted keys, `verify()` and `import_descriptor()` abort with an RPC error instead of recognizing a key the wallet holds. <details> <summary>Details and suggested fix</summary> `derivehdkey` rejects paths with no hardened step, but `find_own_key()` calls it with `m` for an exact xpub match and with the descriptor's origin path in the derived-key branch. An account xprv stored as an unused key can therefore fail the exact-match branch. The derived-key branch can fail for received descriptors with a fingerprint-only origin or an origin containing only unhardened steps. In either case, a participant whose wallet holds an unused key cannot verify or import the descriptor. For an exact match, use the xprv from `gethdkeys(private=True)`; in the derived branch, skip candidates whose origin has no hardened step. `generate_key()` only creates master-level unused keys, and no checked-in caller builds such a descriptor, so production impact is unconfirmed. </details> <details> <summary>Previous reports</summary> First reported at `2803e1518bb22394a80bac94e2435bb3982d0cde`. Last checked at `2803e1518bb22394a80bac94e2435bb3982d0cde`. </details> **🟠 Minor** **Received descriptors can import another cosigner's private key** Location: [`contrib/multisig/wizard.py:221`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L221>) (head). A shared descriptor containing a cosigner's xprv can give the importer enough signing keys to spend below the reported threshold. <details> <summary>Details and suggested fix</summary> `analyze_descriptor()` calls `getdescriptorinfo()` but does not check `hasprivatekeys`, and it retains the original descriptor body. `import_descriptor()` submits that body after replacing only the participant's own key. If a received descriptor contains another cosigner's xprv, verification still reports the stated threshold, while import stores that private key in the participant's wallet. In a 2-of-3, the importer then holds two keys and can sign alone. Reject descriptors for which `getdescriptorinfo()` reports `hasprivatekeys`, and add a verification and import test for this case. No checked-in caller produces such a descriptor, so production impact is unconfirmed. </details> **🟠 Minor** **Importing a second multisig makes it active and redirects change** Location: [`contrib/multisig/wizard.py:345`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L345>) (head). In a wallet holding two vaults of the same output type, a spend from one vault can send change to the other, and coin selection can combine both vaults' coins. <details> <summary>Details and suggested fix</summary> `import_descriptor()` always imports with `active: True`, which replaces the wallet's active external and internal descriptors for that output type. The existing second-multisig test confirms that `getnewaddress` then returns the second vault's address. A later spend from the wallet can send change from vault-1 coins to vault 2, whose cosigners or threshold may differ. Coin selection can also select coins from both vaults, requiring both cosigner sets to sign and linking the vaults on-chain. Either keep one wallet per setup, as `create_wallet()` already names the wallet after the setup, and refuse imports when an active descriptor of that type exists; or import additional multisigs as inactive behind an explicit option and document the behavior. </details> **🔵 Suggestion** **The account parameter derives from a new seed on every call** Location: [`contrib/multisig/wizard.py:51`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L51>) (head). `account=N` suggests account separation under one seed, but each call to `generate_key()` creates a fresh seed. <details> <summary>Details and suggested fix</summary> `generate_key()` calls `addhdkey()` without an argument, which generates a new random seed, and then derives `m/87h/{coin}h/{account}h` from that seed. Thus, `generate_key(cosigner_wallet, account=1)` on a wallet that already holds a seed creates keys from a new seed at account 1, not account 1 of the existing seed. The account index does not separate keys, and restoring only the first seed will not recover later keys. Reuse the existing unused seed when there is exactly one, calling `addhdkey()` only when there is none; alternatively, remove `account` from `generate_key()` and document that each multisig uses a fresh seed. </details> **🔵 Suggestion** **verify() fetches private keys it does not use** Location: [`contrib/multisig/wizard.py:277`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L277>) (head). Each `verify()` call sends account xprvs over JSON-RPC even though verification needs only a public-key match. <details> <summary>Details and suggested fix</summary> `find_own_key()` always calls `derivehdkey` with `private=True`, but `verify()` retains only the matched public-key expression. Deriving the public key requires the same hardened path and wallet unlock, so verification can use `private=False` without changing the match. As written, it fetches an xprv over the RPC connection for every hardened origin path in the descriptor and every unused seed. Add a `private` flag to `find_own_key()` and enable it only when `import_descriptor()` calls the helper. </details> **🔵 Suggestion** **The NUMS xpub check rejects derived and test-network forms** Location: [`contrib/multisig/wizard.py:247`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L247>) (head). Descriptors using a derived NUMS xpub or a test-network encoding are rejected, and the constant itself is not exercised by the functional test. <details> <summary>Details and suggested fix</summary> `analyze_descriptor()` accepts a NUMS key path only when the internal key exactly equals `NUMS_H` or `NUMS_H_XPUB`. The latter is a mainnet xpub that `getdescriptorinfo` rejects on test chains, so the functional test exercises only `NUMS_H`. A NUMS xpub with `/<0;1>/*` derivation falls through to the error that the key path may be spendable on its own, even though its children remain unspendable. To support this descriptor form, recognize network-appropriate NUMS xpubs with the multipath suffix and add a check that decodes the constant to `02||NUMS_H`. Alternatively, remove `NUMS_H_XPUB` if an underived xpub is unnecessary. </details> **🔵 Suggestion** **The README incorrectly requires private keys for every step** Location: [`contrib/multisig/README.md:10`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/README.md#L10>) (head). The instructions may lead a watch-only coordinator to use a wallet with private keys even though it does not need one. <details> <summary>Details and suggested fix</summary> The README says every step requires an unlocked wallet with private keys enabled, then says a coordinator that contributes no key needs a watch-only wallet. The code and functional tests support a watch-only coordinator running verification and import. Clarify that `generate_key()` and participant imports need an unlocked private-key wallet, while a coordinator that contributes no key can use a watch-only wallet for verification and import. </details> --- <details> <summary>Previous findings (2)</summary> <details> <summary>[Minor · still present] Origin-tagged raw public keys pass validation but cannot be ranged</summary> `add_cosigner()` can accept a key that later makes descriptor assembly fail after all cosigner keys have been collected. `validate_key()` accepts an origin-annotated hex public key when its origin has the expected BIP 87 path. `build_descriptor()` then appends `/<0;1>/*` to every key, but Core accepts a raw hex key only without a derivation suffix. As a result, `getdescriptorinfo` fails and `assemble()` reports only `Invalid descriptor`. Require an extended key in `validate_key()`, for example by checking that `pkh({key}/*)` parses, and add tests for origin-tagged compressed and uncompressed raw keys. No checked-in caller supplies this form, so production impact is unconfirmed. Location: [`contrib/multisig/wizard.py:81`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L81>) (head). First reported at `2803e1518bb22394a80bac94e2435bb3982d0cde`. Last checked at `2803e1518bb22394a80bac94e2435bb3982d0cde`. </details> <details> <summary>[Minor · still present] Importing with timestamp &quot;now&quot; can hide payments made before import</summary> A participant or watch-only coordinator importing after funding will not see earlier payments until a rescan. `verify()` returns the first receive address before import, but `import_descriptor()` always passes `timestamp: "now"`. That timestamp bypasses scanning for outputs known never to have been used; the RPC otherwise scans only two hours before the supplied timestamp. If the address was paid earlier, the wallet misses the payment until someone runs `rescanblockchain`, and `getnewaddress` can return the already-used address in the meantime. Record a creation time in `setup()` or accept a timestamp and pass it to `importdescriptors`. The intended order has every participant importing before funding, and no checked-in caller funds before import, so production impact is unconfirmed. Location: [`contrib/multisig/wizard.py:345`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2803e1518bb22394a80bac94e2435bb3982d0cde/contrib/multisig/wizard.py#L345>) (head). First reported at `2803e1518bb22394a80bac94e2435bb3982d0cde`. Last checked at `2803e1518bb22394a80bac94e2435bb3982d0cde`. </details> </details> Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`2803e1518bb2`](<https://git.fish.foo/bitcoin/bitcoin/commit/2803e1518bb22394a80bac94e2435bb3982d0cde>) · [Full review report](<https://review.fish.foo/traces/36325-2803e1518bb22394a80bac94e2435bb3982d0cde-1662-3.html>) · [Previous reports](<https://review.fish.foo/traces/36325/>)
kevkevinpal commented 2026-10-03 17:00:47 +00:00 (Migrated from github.com)

I'm not sure we want this in this repository.

Looking at the other scripts in contrib I don't see any that handle wallet utilities. If this were to be added it would make more sense to add it to the Bitcoin Core wallet.

From what I understand in the discussion in https://github.com/bitcoin/bitcoin/issues/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.

Core offline signing and multisig being non-technologist unfriendly has been exploited by scammers to push alternative multisig and airgap wallets with substantially less review than this repository.

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

I'm not sure we want this in this repository. Looking at the other scripts in `contrib` I don't see any that handle wallet utilities. If this were to be added it would make more sense to add it to the Bitcoin Core wallet. From what I understand in the discussion in https://github.com/bitcoin/bitcoin/issues/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. > Core offline signing and multisig being non-technologist unfriendly has been exploited by scammers to push alternative multisig and airgap wallets with substantially less review than this repository. 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
BenWestgate commented 2026-10-05 00:12:33 +00:00 (Migrated from github.com)

maintainers will need to worry about forever.

@rxbryan are you willing to maintain this script (including bug fixing) until the RPC obsoletes it?

If this were to be added it would make more sense to add it to the Bitcoin Core wallet.

@Sjors said in https://github.com/bitcoin/bitcoin/pull/36143#issuecomment-5508988125 a wallet c++ implementation is premature and he preferred to:

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

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.

> maintainers will need to worry about forever. @rxbryan are you willing to maintain this script (including bug fixing) until the RPC obsoletes it? > If this were to be added it would make more sense to add it to the Bitcoin Core wallet. @Sjors said in https://github.com/bitcoin/bitcoin/pull/36143#issuecomment-5508988125 a wallet c++ implementation is premature and he preferred to: > 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 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.
rxbryan commented 2026-10-05 21:08:05 +00:00 (Migrated from github.com)

maintainers will need to worry about forever.

@rxbryan are you willing to maintain this script (including bug fixing) until the RPC obsoletes it?

Yes. I'll maintain it, we have enough test cases to force a maintenance contract on whoever modifies code touching it.

> > maintainers will need to worry about forever. > > @rxbryan are you willing to maintain this script (including bug fixing) until the RPC obsoletes it? > Yes. I'll maintain it, we have enough test cases to force a maintenance contract on whoever modifies code touching it.
pseudoramdom commented 2026-10-23 19:45:25 +00:00 (Migrated from github.com)

Thanks for putting this together and listing the gaps.

That said, I'm leaning Concept NACK on merging this into the repo.
The goal of #35645 is for the wallet to handle multisig setup by itself - a GUI wizard on top of interfaces::Wallet, plus the RPCs behind it. Like you said that work would supersede this script. Merging this would mean reviewing ~700 lines (script and functional test) whose job is to work around things we plan to fix. We'd then have to review again each time one of those fixes lands and removes a workaround. I'd rather prefer we direct our resources at implementing items in #35645, since they reach both RPC and GUI users.

Also putting a script in contrib/ makes it look like a recommended tool and that's hard to undo once people use it with real funds.

What we can do

  • We can track this separately in a separate fork/gist and have it linked from #35645, so people testing the backend PRs can use it. As @sedited mentioned, it works fine as an external script.
  • We can add the gaps from the description to #35645, so the Core backend work tracks them directly. Some are already there (#35377, #35918, createmultisigdescriptor, analyzeDescriptor)
Thanks for putting this together and listing the gaps. That said, I'm leaning Concept NACK on merging this into the repo. The goal of #35645 is for the wallet to handle multisig setup by itself - a GUI wizard on top of `interfaces::Wallet`, plus the RPCs behind it. Like you said that work would supersede this script. Merging this would mean reviewing ~700 lines (script and functional test) whose job is to work around things we plan to fix. We'd then have to review again each time one of those fixes lands and removes a workaround. I'd rather prefer we direct our resources at implementing items in #35645, since they reach both RPC and GUI users. Also putting a script in `contrib/` makes it look like a recommended tool and that's hard to undo once people use it with real funds. What we can do - We can track this separately in a separate fork/gist and have it linked from #35645, so people testing the backend PRs can use it. As @sedited mentioned, it works fine as an external script. - We can add the gaps from the description to #35645, so the Core backend work tracks them directly. Some are already there (#35377, #35918, `createmultisigdescriptor`, `analyzeDescriptor`)
BenWestgate commented 2026-10-23 20:27:35 +00:00 (Migrated from github.com)

Merging this would mean reviewing ~700 lines (script and functional test) whose job is to work around things we plan to fix.

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.

We'd then have to review again each time one of those fixes lands and removes a workaround.

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.

Also putting a script in contrib/ makes it look like a recommended tool and that's hard to undo once people use it with real funds.

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.

> Merging this would mean reviewing ~700 lines (script and functional test) whose job is to work around things we plan to fix. 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. > We'd then have to review again each time one of those fixes lands and removes a workaround. 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. > Also putting a script in `contrib/` makes it look like a recommended tool and that's hard to undo once people use it with real funds. 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.
BenWestgate commented 2026-10-29 05:37:14 +00:00 (Migrated from github.com)

tACK 2803e1518
All wizard steps run on an offline node for 2-of-3 wsh(sortedmulti) at m/87h/1h/0h: create_wallet, generate_key, add_cosigner, assemble, verify and import_descriptor, for three key wallets and a watch-only coordinator. The watch-only wallet was restored online and created a PSBT. Two key wallets signed it offline, and testmempoolaccept allowed the result.

Review nits

  1. import_descriptor uses "timestamp": "now". In importdescriptors, "now" means the best block's time. An offline node has only the genesis block, so the wallet's birth time is genesis. Restoring that wallet's backup on a pruned online node then fails with Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex. The same descriptor imported with the current time restored fine on the same pruned node. Suggested fix: pass int(time.time()), or let the caller give a timestamp. On an online node the result is the same as "now".
  2. No backup step. After import_descriptor, each participant has to back up their key wallet and the descriptor. A key wallet alone can't rebuild the multisig. The wizard's docstrings don't mention this. It may belong in the README rather than the code.
tACK 2803e1518 All wizard steps run on an offline node for 2-of-3 `wsh(sortedmulti)` at `m/87h/1h/0h`: `create_wallet`, `generate_key`, `add_cosigner`, `assemble`, `verify` and `import_descriptor`, for three key wallets and a watch-only coordinator. The watch-only wallet was restored online and created a PSBT. Two key wallets signed it offline, and `testmempoolaccept` allowed the result. ### Review nits 1. **`import_descriptor` uses `"timestamp": "now"`.** In `importdescriptors`, "now" means the best block's time. An offline node has only the genesis block, so the wallet's birth time is genesis. Restoring that wallet's backup on a pruned online node then fails with `Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex`. The same descriptor imported with the current time restored fine on the same pruned node. Suggested fix: pass `int(time.time())`, or let the caller give a timestamp. On an online node the result is the same as "now". 2. **No backup step.** After `import_descriptor`, each participant has to back up their key wallet and the descriptor. A key wallet alone can't rebuild the multisig. The wizard's docstrings don't mention this. It may belong in the README rather than the code.
achow101 commented 2026-11-03 03:46:58 +00:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36325
No description provided.