Skip to content

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

Open
dolepee wants to merge 3 commits 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 3 commits 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

@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.

Copy link
Copy Markdown
Contributor

@njdawn njdawn left a comment

Choose a reason for hiding this comment

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

LGTM -> after CI fixes + merge conflicts can merge

dolepee added 3 commits April 17, 2026 11:08
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 force-pushed the feat/bitcoin-psbt-via-sign-transaction branch from 44cd19e to a49e546 Compare April 17, 2026 10:11
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​bitcoin@​0.32.87710090100100

View full report

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