Skip to content

feat: add P2MR fixed-script wallet integration#247

Open
lcovar wants to merge 1 commit intoBTC-3241-bip360-p2mr-supportfrom
BTC-3241-bip360-p2mr-fixed-script
Open

feat: add P2MR fixed-script wallet integration#247
lcovar wants to merge 1 commit intoBTC-3241-bip360-p2mr-supportfrom
BTC-3241-bip360-p2mr-fixed-script

Conversation

@lcovar
Copy link
Copy Markdown
Contributor

@lcovar lcovar commented Apr 7, 2026

Stacked on #246

Add P2MR as a new script type in the fixed-script wallet system,
mirroring P2TR legacy but without internal key or tweak.

  • OutputScriptType::P2mr with chain values 50/51
  • ScriptP2mr: 3-leaf tree (user+bitgo, user+backup, backup+bitgo)
    using same 2-of-2 checksigverify scripts as P2TR
  • P2MR witness size calculation (1 + 32*depth control blocks)
  • PSBT input signing stubs (returns "not yet supported")
  • Fixture tests for 3 pubkey triples (merkle root, output script,
    control blocks, depth assertions, chain value round-trips)

BTC-3241

@lcovar lcovar requested a review from a team as a code owner April 7, 2026 23:17
Add P2MR as a new script type in the fixed-script wallet system,
mirroring the P2TR legacy pattern but without internal key or tweak.

Wallet script generation:
- ScriptP2mr: 3-leaf tree (user+bitgo, user+backup, backup+bitgo)
  using same 2-of-2 checksigverify leaf scripts as P2TR
- OutputScriptType::P2mr with chain values 50/51
- Reuses existing build_p2tr_ns_script for leaf scripts and
  crate::p2mr::build_p2mr_tree for tree construction

PSBT/signing stubs:
- P2MR input signing returns "not yet supported" error
- P2MR outputs need no extra PSBT metadata (no tap_internal_key)
- BIP-322 P2MR returns "not yet supported" error

Dimensions:
- P2MR witness size calculation (1 + 32*depth control blocks,
  no 32-byte internal key unlike P2TR)
- Primary spend at depth 1, recovery paths at depth 2

Fixture tests verify merkle root, output script, and control blocks
for 2 pubkey triples with different key orderings.

BTC-3241
@lcovar lcovar force-pushed the BTC-3241-bip360-p2mr-fixed-script branch from 8ed1ed5 to 1698651 Compare April 8, 2026 04:51
OutputScriptType::P2wsh => 20,
OutputScriptType::P2trLegacy => 30,
OutputScriptType::P2trMusig2 => 40,
OutputScriptType::P2mr => 50,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OutputScriptType::P2mr => 50,
OutputScriptType::P2mr => 360,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants