Merged
Conversation
Implement Pay-to-Merkle-Root (P2MR, BIP360) support: add P2MR payment class and legacy factory (src/payments/p2mr.ts), types (P2MRPayment), and tests/fixtures. Wire P2MR into address and PSBT utilities (address.fromOutputScript/toOutputScript, psbt utils, payments index) and add Merkle utilities (rootHashFromPathP2MR and tapBranchHash) reused from Taproot logic. Include documentation (documentation/p2mr.md) and update package metadata (package-lock.json) for a new release candidate.
There was a problem hiding this comment.
Pull request overview
This PR implements Pay-to-Merkle-Root (P2MR, referenced as BIP 360) payment support - a SegWit version 2 output type that commits directly to the Merkle root of a script tree without an internal public key. This eliminates the quantum-vulnerable key-path spend found in P2TR (Taproot) while maintaining the efficient script tree structure.
Changes:
- Added P2MR payment class and legacy factory function with full validation and lazy-computed getters following established patterns
- Implemented P2MR-specific Merkle utilities (rootHashFromPathP2MR) and exported tapBranchHash for reuse
- Integrated P2MR into address encoding/decoding, PSBT utilities, type system, and exports with comprehensive test fixtures and documentation
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/payments/p2mr.ts | New P2MR payment class implementation with validation, getters, factory methods, and legacy function |
| src/payments/types.ts | Added P2MRPayment interface and P2MR to PaymentType enum and Payment union |
| src/payments/index.ts | Exported P2MR types, classes, functions, and utilities (rootHashFromPathP2MR, tapBranchHash) |
| src/payments/bip341.ts | Added rootHashFromPathP2MR function and made tapBranchHash public for P2MR support |
| src/address.ts | Added P2MR detection in fromOutputScript and encoding in toOutputScript for bc1z addresses |
| src/psbt/psbtutils.ts | Added isP2MR payment factory function for PSBT integration |
| src/index.ts | Exported P2MRPayment type in main index |
| test/payments.spec.ts | Added p2mr module to test execution array |
| test/fixtures/p2mr.json | Comprehensive test fixtures covering address/output/hash conversions, script trees, and witness construction |
| documentation/p2mr.md | Complete documentation with examples, API reference, and comparison with P2TR |
| package-lock.json | Version bump from 7.0.0-rc.1 to 7.0.0-rc.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Feb 17, 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.
Description
Implement Pay-to-Merkle-Root (P2MR, BIP360) support: add P2MR payment class and legacy factory (src/payments/p2mr.ts), types (P2MRPayment), and tests/fixtures. Wire P2MR into address and PSBT utilities (address.fromOutputScript/toOutputScript, psbt utils, payments index) and add Merkle utilities (rootHashFromPathP2MR and tapBranchHash) reused from Taproot logic. Include documentation (documentation/p2mr.md) and update package metadata (package-lock.json) for a new release candidate.
Type of Change
Checklist
Build & Tests
npm installcompletes without errorsnpm testpasses all testsnpm run browserBuildcompletes without errors (if applicable)Code Quality
Documentation
Security
Bitcoin Specific
Testing
Related Issues
By submitting this PR, I confirm that my contribution is made under the terms of the project's license.