fix(connect): reject non-positive fee in parsePsbt - #32184
Open
mroz22 wants to merge 1 commit into
Open
Conversation
`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
requested review from
marekrjpolak,
martykan and
szymonlesisz
as code owners
September 7, 2026 12:25
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, throwMethod_InvalidParameterwhenfee = sumOfInputs - sumOfOutputs <= 0, before building the result.Why:
composePsbtis a public SDK method andpsbtDatais caller-controlled, so a PSBT whose output values meet or exceed the referenced (owned) input amounts yields a zero/negativeBigIntfee. Without the guard,parsePsbtreturnstype: 'final'with a negativefee/feePerByte— a misleading "successful" precompose. A successful response should return functional data, so this fails fast at the boundary instead. It mirrors the existingsignTransaction.payloadToPrecomposedguard (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 /
signTransactionreject a non-positive-fee transaction regardless. The value is only thatcomposePsbtreturns a clean error instead of a nonsensicalfinalresult.Based on
feat/connect-psbt.🤖 Generated with Claude Code
🔍 Currents Test Results
🔍 Suite native android test results: View in Currents