Skip to content

feat(psbt): add PsbtV2 BIP-370 support built on bip370#2327

Draft
jvgelder wants to merge 1 commit into
bitcoinjs:masterfrom
jvgelder:feat/bip370
Draft

feat(psbt): add PsbtV2 BIP-370 support built on bip370#2327
jvgelder wants to merge 1 commit into
bitcoinjs:masterfrom
jvgelder:feat/bip370

Conversation

@jvgelder
Copy link
Copy Markdown

@jvgelder jvgelder commented Mar 23, 2026

Adds PSBTv2 (BIP-370) support via a wrapper around bip370. Where bip370 only handles the structural side: map encoding, role enforcement and serialization. This wrapper adds signing and validation with an API similair to Psbt.

What's new over the base bip370 library:

  • Signing and signature validation legacy, segwit, taproot key/script path
  • toTransaction extracts a finalized tx with a fee rate guard
  • verifyNonWitnessUtxo validates funding tx via Transaction.getHash()
  • getInputHashForSig and getTaprootHashesForSig expose the raw sighash directly for hardware wallets and HSMs that cannot hold PSBT state. Prefer signInput() or passing the PSBT as hex where possible, these helpers skip the script and pubkey checks that signInput() enforces, placing full responsibility for correctness on the caller.

Before merge I would like someone to have a look at the bip370 implementation first (also need to fix one test) :)

closes #2316

Adds PSBTv2 (BIP-370) support via a wrapper around bip370.
Where bip370 only handles the structural side: map encoding, role
enforcement and serialization. This wrapper adds signing and validation
with an API similair to Psbt.

What's new over the base bip370 library:
- Signing and signature validation legacy, segwit, taproot key/script path
- toTransaction extracts a finalized tx with a fee rate guard
- verifyNonWitnessUtxo validates funding tx via Transaction.getHash()
- getInputHashForSig and getTaprootHashesForSig expose the raw sighash
  directly for hardware wallets and HSMs that cannot hold PSBT state.
  Prefer signInput() or passing the PSBT as hex where possible, these
  helpers skip the script and pubkey checks that signInput() enforces,
  placing full responsibility for correctness on the caller.
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.

Bip370 PSBTv2 support

1 participant