Skip to content

fix(connect): reject non-positive fee in parsePsbt - #32184

Open
mroz22 wants to merge 1 commit into
feat/connect-psbtfrom
mroz22/composepsbt-reject-non-positive-fee
Open

fix(connect): reject non-positive fee in parsePsbt#32184
mroz22 wants to merge 1 commit into
feat/connect-psbtfrom
mroz22/composepsbt-reject-non-positive-fee

Conversation

@mroz22

@mroz22 mroz22 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Standalone extraction from the review of #26056 — a single self-contained commit, so it can be taken (or not) independently of the rest of the review follow-ups.

Change: in parsePsbt, throw Method_InvalidParameter when fee = sumOfInputs - sumOfOutputs <= 0, before building the result.

Why: composePsbt is a public SDK method and psbtData is caller-controlled, so a PSBT whose output values meet or exceed the referenced (owned) input amounts yields a zero/negative BigInt fee. Without the guard, parsePsbt returns type: 'final' with a negative fee/feePerByte — a misleading "successful" precompose. A successful response should return functional data, so this fails fast at the boundary instead. It mirrors the existing signTransaction.payloadToPrecomposed guard (if (fee.lte(0)) throw).

Scope note: this is defensive hygiene, not a funds-safety fix. It cannot occur for a well-formed PSBT with correct account data (a real transaction always has a positive fee), and the device / signTransaction reject a non-positive-fee transaction regardless. The value is only that composePsbt returns a clean error instead of a nonsensical final result.

Based on feat/connect-psbt.

🤖 Generated with Claude Code

🔍 Currents Test Results

🔍 Suite native android test results: View in Currents

`fee = sumOfInputs - sumOfOutputs` could be zero or negative when the PSBT's
outputs meet or exceed its owned inputs, yet parsePsbt returned a
`type: 'final'` result with a negative fee/feePerByte. signTransaction
guards this in a different path; do the same here so composePsbt rejects it
up front with Method_InvalidParameter instead of returning a malformed
"final" transaction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mroz22 mroz22 added the no-project This label is used to specify that PR doesn't need to be added to a project label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-project This label is used to specify that PR doesn't need to be added to a project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant