Skip to content

fix: drop previous tx of segwit inputs from signed QR PSBTs - #976

Open
odudex wants to merge 1 commit into
selfcustody:developfrom
odudex:fix/trim-segwit-prev-tx-from-signed-psbt
Open

odudex wants to merge 1 commit into
selfcustody:developfrom
odudex:fix/trim-segwit-prev-tx-from-signed-psbt

Conversation

@odudex

@odudex odudex commented Nov 14, 2026

Copy link
Copy Markdown
Member

What is this PR for?

To mitigate the "unproven fee" attack, we asked coordinators such as Sparrow to include the full previous transaction (non_witness_utxo) on segwit inputs, so Krux can prove the input amounts and the fee before signing.

Krux was also sending those transactions back. When signing to QR code the PSBT is trimmed, but since 27ccb7b the trim kept non_witness_utxo whenever present. The coordinator already has that data and witness_utxo is enough for a segwit input, so it only inflated the signed payload and the number of QR frames.

Change

The trimmed PSBT no longer includes non_witness_utxo for segwit inputs that carry witness_utxo.

Unchanged: validation before signing, legacy inputs (which still keep it) and Sign to SD card (not trimmed).

Changes made to:

  • Code
  • Tests
  • Docs
  • CHANGELOG

Did you build the code and tested on device?

  • Yes, build and tested on WonderK

What is the purpose of this pull request?

  • Bug fix
  • New feature
  • Docs update
  • Other

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.60%. Comparing base (9092846) to head (1f3a4ac).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #976   +/-   ##
========================================
  Coverage    97.60%   97.60%           
========================================
  Files           84       84           
  Lines        11001    11001           
========================================
  Hits         10738    10738           
  Misses         263      263           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdlcdl jdlcdl added the prioritized Prioritized focus for near-term merge label Nov 15, 2026
@jdlcdl

This comment was marked as resolved.

@odudex
odudex force-pushed the fix/trim-segwit-prev-tx-from-signed-psbt branch from 1be8f8e to 1f3a4ac Compare November 15, 2026 11:44
@jdlcdl

jdlcdl commented Nov 15, 2026

Copy link
Copy Markdown
Member

ACK at 1f3a4ac, while hoping for more reviews/acks/approval.

@notTanveer

Copy link
Copy Markdown
Contributor

tACK 1f3a4ac

tested with sparrow, 2 input p2wpkh spend, with and without the change. signed QR payload is ~30% smaller now, sparrow combines and broadcasts fine. LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prioritized Prioritized focus for near-term merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants