mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
tests: add functional test for tr musig2 miniscript decaying multisig #35443
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!35443
Loading…
Reference in a new issue
No description provided.
Delete branch "test_tr_miniscript_decaying_multiscript_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?
This is closely based on test/functional/wallet_miniscript_decaying_multisig_descriptor_psbt.py both in code and concept. It builds the same "decaying" multisig that starts as 4-of-4 and decays to 3-of-4, 2-of-4, and finally 1-of-4 at each future halvening block height, but as a Taproot output, combining Taproot, Miniscript, and MuSig2 in a single descriptor of the form
tr(musig(key_1,key_2,key_3,key_4),thresh(4,pk(key_1),s:pk(key_2),s:pk(key_3),s:pk(key_4),sln:after(t1),sln:after(t2),sln:after(t3))). While every signer is available the 4-of-4 is spent through the Taproot key path using a MuSig2 aggregate of the participants, which is the cheapest and most private spend, while the Miniscript script path is a fallback used only when a key becomes inaccessible, so a lost key never permanently strands the funds and the key path stays available even after the multisig has fully decayed. As with thewshversion the signers are plain single-key wallets and the multisig is watch-only, so everything needed to sign (including the MuSig2 participant pubkeys) is carried in the PSBT and signers never import the multisig descriptor. It serves as integration testing for Taproot, Miniscript, and MuSig2 descriptors working together, and like thewshtest is meant to be documentation as much as a functional test, so it is kept as simple and readable as possible.Note: this thresh-based design has BIP110-invalid script-path spends.
sln:aftercompiles toOP_IFin the tapscript leaf (the key-path spend is unaffected). I implemented an alternative that avoids this by splitting the decay into separate timelockedmulti_atapleaves (noOP_IF) in e0482ec. It's a quick, less-thoroughly-tested implementation, but I wanted to present it in case reviewers prefer that approach.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.LLM Linter (✨ experimental)
Possible typos and grammar issues:
2026-06-02 16:02:31
Concept ACK
e588094Based on a cursory glance, there is a lot of similarity with the other test mentioned in the PR description along with a duplicated method.
Consider merging these two files into one while getting rid of the duplication?
Correct, the two tests are (intentionally) similar. This is meant to be a "baby step" improving the privacy of
wallet_miniscript_decaying_multisig_descriptor_psbt.pySo they are generally the same aside from
_spend_keypathand the test conditions exercising that.That said, my preference is keeping these tests separate to prioritize them being maximally simple and easy to follow. I think the "documentation" value of these tests is greater than the test coverage provided. So in that spirit I intentionally duplicated some code to keep these tests elegant and straightforward incase someone references it while creating a wallet.
Thanks for the valid feedback, if more reviewers prefer consolidating I am open to it! These tests could be easily combined (also the OG
test/functional/wallet_multisig_descriptor_psbt.py). But I preferred the 3 part series showing my preferred multisig in core as new technology matures: basic m-of-n => decaying miniscript => this.Base:
631b0065a7f2696a7240db4bbb63589444dc96b8Head:
e5880944cba298c04ad5fe4acd2c6208784554ccFindings
Minor
The example’s first decay height has already passed (doc/descriptors.md:51, head)
Block 840,000 was mined on April 20, 2024. The example’s
after(840000)branch is therefore already satisfied, so adapting the descriptor with your own keys permits a 3-of-4 script-path spend immediately, contrary to the description of a future decay. Update the Taproot example’s locktimes or label them as historical. No current production wallet using this example was identified, so deployment impact is unconfirmed. (blockchain.com)Suggestions
Exercise non-prefix signer subsets in decayed spends (test/functional/wallet_taproot_decaying_multisig_descriptor_psbt.py:135, head)
random.sample(range(self.M), self.M)randomizes signing order but always selects the first M signers. Thus the 3-of-4, 2-of-4, and 1-of-4 script-path cases only use indices 0–2, 0–1, and 0, respectively; the initial 4-of-4 spend does not test those lower thresholds with a non-prefix subset. Please choose deterministic representative subsets across the decay stages so the test covers lower-threshold spends that include later-index signers.Previously reported; verified as still present in this revision. Status: still_present. Author position: none. Originally reported at
e5880944cba298c04ad5fe4acd2c6208784554cc. The prefix-only signer selection remains in the new Taproot test. The base WSH test has an analogous sampling pattern, but this PR adds the Taproot-specific test and its subset-coverage gap, so the finding is not unchanged.Review coverage was incomplete.
Review limitations
Full review report
Please rebase this PR over master, otherwise there's a CMake error in building this branch on local related to the outdate libevent library (which can be worked around by rebasing on local though).
s/2024/2026
Doesn't this assert need to be in the loop?
lgtm ACK
e5880944cbThis particular example doesn't contain any halvening related timelocks. It can be avoided in the description as well.
Nvm, this seems fine outside the loop to check the final completeness of the PSBT post both the rounds.
tACK
e5880944cbI compared the test's descriptor, its five spends and the new doc/descriptors.md example with code outside Core, on master
49c3c7fe09with this commit applied. bip32-descriptors, a library I maintain, derives the same receive and change addresses asderiveaddressesat indexes 0 to 19, for the test's descriptor and for the doc example: 80 of 80. btclib's script interpreter accepts all five spends the test broadcasts, each against an output script bip32-descriptors derived. Two are MuSig2 key-path spends. The script-path spends with lock times 104, 106 and 108 carry 3, 2 and 1 signatures and execute 1, 2 and 3 CHECKLOCKTIMEVERIFY. A flipped signature byte makes each spend fail. Raising the firstafter()by one block changes all 80 addresses.Gist: https://gist.github.com/fametrano/43a546b703a720c9313995568ddb00b3/0b0054e0143591d093a65d5231af7e3bae134a3b
That seems preferable to me. Why did you not push that instead?