feat: add P2MR fixed-script wallet integration#247
Merged
Conversation
8ed1ed5 to
1698651
Compare
OttoAllmendinger
requested changes
Apr 8, 2026
packages/wasm-utxo/src/fixed_script_wallet/wallet_scripts/mod.rs
Outdated
Show resolved
Hide resolved
5a099bf to
3bf0bc7
Compare
1698651 to
3363c32
Compare
OttoAllmendinger
requested changes
Apr 9, 2026
packages/wasm-utxo/src/fixed_script_wallet/wallet_scripts/mod.rs
Outdated
Show resolved
Hide resolved
3bf0bc7 to
b19bd0e
Compare
91d8d19 to
415affc
Compare
b19bd0e to
eeae358
Compare
415affc to
6064a34
Compare
ac5e692 to
7a36520
Compare
6064a34 to
da43899
Compare
Add witness v2 (P2MR) support to the address encoding layer: - Generic bech32 segwit::encode() for all witness versions (v0-v2+) - P2MR script detection (34 bytes, witness v2, OP_PUSHBYTES_32) - OutputScriptSupport.p2mr flag on all Bitcoin networks - P2MR address test vectors (bc1z mainnet, tb1z testnet) validated against BIP-360 spec fixtures BTC-3241
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 360/361 - ScriptP2mr: 3-leaf tree (user+bitgo, user+backup, backup+bitgo) using same 2-of-2 checksigverify scripts as P2TR - InputScriptType::P2mr with proper witness size calculation (1 + 32*depth control blocks, no 32-byte internal key) - PSBT output metadata (tap_tree, tap_key_origins) reusing taproot fields (tested with rust-bitcoin, bitcoinjs-lib, utxo-lib) - PSBT input signing stub (returns "not yet supported") - Fixture tests for output scripts, control blocks, chain values BTC-3241
da43899 to
73de89f
Compare
Add chain codes 360/361 to the TypeScript chainCodes array so the WASM chain_code_table() entries for P2MR don't crash at module load time. Skip P2MR in utxo-lib comparison tests since utxo-lib won't add P2MR support. Restore the bitcoinBitGoSignet -> bitcoinPublicSignet fixture mapping that was incorrectly removed. Ticket: BTC-3241
OttoAllmendinger
requested changes
Apr 14, 2026
| inner_psbt.inputs[input_index].witness_script = Some(script.witness_script.clone()); | ||
| } | ||
| WalletScripts::P2mr(_) => { | ||
| return Err("BIP-322 signing for P2MR is not yet supported".to_string()); |
Contributor
There was a problem hiding this comment.
let's add it in this PR
Add P2MR (BIP-360) input construction to add_bip322_input. P2MR uses the same sighash as P2TR (BIP-342 common signature message) and the same 2-of-2 checksigverify leaf scripts. The key difference is that P2MR has no internal key (quantum resistance), so tap_scripts cannot be populated (rust-bitcoin's ControlBlock requires an internal key). Instead, we use precomputed leaf hashes from ScriptP2mr and set only tap_key_origins, which is sufficient for signing. Also adds P2MR support to build_output_script_from_pubkeys for BIP-322 verification with pubkeys. Ticket: BTC-3241
OttoAllmendinger
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add P2MR (BIP-360) address encoding and fixed-script wallet integration
to wasm-utxo.
Address encoding:
segwit::encode()for all witness versions (v0-v2+)OutputScriptSupport.p2mrflag on all Bitcoin networksFixed-script wallet:
OutputScriptType::P2mrwith chain values 360/361ScriptP2mr: 3-leaf tree (user+bitgo, user+backup, backup+bitgo)using same 2-of-2 checksigverify scripts as P2TR
InputScriptType::P2mrwith proper witness size calculation(1 + 32*depth control blocks, no 32-byte internal key)
fields (tested with rust-bitcoin, bitcoinjs-lib, utxo-lib)
skipped in utxo-lib comparison tests (wasm-only)
BTC-3241