Skip to content

feat(bitcoin): add PSBT signing via sign_transaction#201

Open
dolepee wants to merge 1 commit intoopen-wallet-standard:mainfrom
dolepee:feat/bitcoin-psbt-via-sign-transaction
Open

feat(bitcoin): add PSBT signing via sign_transaction#201
dolepee wants to merge 1 commit intoopen-wallet-standard:mainfrom
dolepee:feat/bitcoin-psbt-via-sign-transaction

Conversation

@dolepee
Copy link
Copy Markdown
Contributor

@dolepee dolepee commented Apr 9, 2026

Summary

Adds Bitcoin PSBT (BIP-174) signing support through the existing `sign_transaction` interface, keeping the `ChainSigner` trait chain-agnostic (no new trait methods).

`BitcoinSigner::sign_transaction` detects PSBT format by magic bytes (`psbt\xff`) and routes to PSBT handling automatically. Non-PSBT transactions continue through the existing double-SHA256 path.

What it does

  • Parses PSBT, identifies P2WPKH inputs owned by the signing key
  • Computes BIP-143 sighash and signs with ECDSA
  • Inserts partial signatures into the PSBT
  • Returns the signed PSBT bytes in `SignOutput::signature`
  • Skips inputs not owned by the key (safe for multi-party signing)

Changes

  • `ows/crates/ows-signer/Cargo.toml`: add `bitcoin` crate dependency
  • `ows/crates/ows-signer/src/chains/bitcoin.rs`: PSBT detection + signing in `sign_transaction`, helper methods, 2 new tests

Design note

Per feedback on #137, this avoids adding any Bitcoin-specific method to the `ChainSigner` trait. PSBT is handled as an implementation detail of `BitcoinSigner` behind the same `sign_transaction` entry point all chains use.

Verification

cargo test --package ows-signer -- bitcoin
# 15 passed, 0 failed

Detects PSBT format by magic bytes inside BitcoinSigner::sign_transaction,
keeping the ChainSigner trait chain-agnostic with no new methods.

Supports P2WPKH inputs, skips inputs not owned by the signing key.
Signed PSBT bytes are returned in SignOutput::signature.
@dolepee dolepee requested a review from njdawn as a code owner April 9, 2026 19:38
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

@dolepee is attempting to deploy a commit to the MoonPay Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant