Skip to content

Fix browser PSBT prevout attachment - #96

Merged
sidhujag merged 2 commits into
mainfrom
agent/fix-psbt-browser-buffer
Aug 17, 2026
Merged

Fix browser PSBT prevout attachment#96
sidhujag merged 2 commits into
mainfrom
agent/fix-psbt-browser-buffer

Conversation

@sidhujag

@sidhujag sidhujag commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary

  • pin Buffer 6 so bitcoinjs-lib v7 BigInt transaction parsing/serialization works in the client bundle
  • replace Buffer.equals transaction-hash checks with Uint8Array-safe byte comparisons
  • validate txid integrity in the same-origin transaction proxy while preserving its immutable raw-response format
  • parse and witness-strip the authenticated parent in the browser before PSBT attachment
  • add browser-polyfill, txid-mismatch, witness-stripping, and serialization regressions

Reported reproduction

Verified against Tanenbaum parent transaction 575befd47b4effe268e967fc08d93163ecc81616b49970971dd8c0df93ed1a3d: txid validation, witness stripping, PSBT attachment, and browser-polyfill serialization all succeed.

Verification

  • yarn test --runInBand (169 tests)
  • yarn build
  • exact reported Tanenbaum parent transaction browser-polyfill serialization harness

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bridge-testnet Ready Ready Preview Aug 16, 2026 11:42pm
syscoin-bridge Ready Ready Preview Aug 16, 2026 11:42pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a16d712e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread utils/psbt-prevouts.ts Outdated
Comment on lines +114 to +116
const nonWitnessUtxo = hexToBytes(rawTransactionHex);
const previousTransactionHash =
syscoinUtils.bitcoinjs.crypto.hash256(nonWitnessUtxo);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Strip witnesses from injected fetcher results

When exportPsbtWithPrevouts is called by the sponsorship flow, api/services/sponsor-wallet.ts:410-415 injects fetchBackendRawTx rather than the new same-origin proxy, so a witness-bearing parent is still returned with its witness serialization. Hashing those bytes here computes the wtxid instead of the input's txid, causing the comparison below to reject valid SegWit prevouts and preventing sponsored UTXO burns from being prepared. Preserve the previous parse-and-strip behavior for custom fetchers, or route this caller through a fetcher that guarantees witness-stripped hex.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7423bc6. The browser now parses and witness-strips every raw parent response before hashing and attachment, including injected sponsorship fetchers. Buffer 6 is pinned so that bitcoinjs-lib v7 parsing and serialization are supported in the client bundle.

@sidhujag

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 7423bc6c2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sidhujag
sidhujag merged commit 921ac17 into main Aug 17, 2026
7 checks passed
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