#36569 psbt: analyzepsbt reports an error when outputs exceed inputs

ReviewabilityReviewsAgreementSize
#36569 Ravan002 psbt: analyzepsbt reports an error when outputs exceed inputsWaiting on author2Strong5 + 8 tests
  • Stop analyzepsbt from reporting negative fees when outputs exceed known inputs
  • Return an error instead of advising unviable signing or updating steps
  • Ready for review
  • Verified fix on master and confirmed regression tests pass (Husteem)
  • Verified by testing on Windows (Yudis-bit)
  • Open suggestion to add a unit test in psbt_tests (Yudis-bit)
  • Questioned need for a unit test given functional test coverage (winterrdog)
  • 5 lines added or modified outside tests
  • 8 lines added or modified in tests
  • 0 lines removed in total
  • 2 files, 1 commits
RPC / REST / ZMQ#37 of 55
P3 · bug fix
  • P3 because it fixes misleading RPC output for transactions that can never be validly mined
  • Corrects confusing negative fees and bad next-role advice once all input amounts are known
  • Ranking pass: Moved up 9: corrects misleading analyzepsbt output (negative fee, wrong next role) for an impossible transaction.
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Updates `analyzepsbt` to mark a PSBT as invalid when total output amount exceeds total input amount once all input amounts are known. Instead of returning a negative fee and suggesting next roles like updater or signer, the RPC now returns an error string and sets the next role to creator.

Problem: When all input amounts are known but outputs exceed inputs, `analyzepsbt` calculates a negative fee and fee rate, advising downstream roles like updater or signer for a transaction that can never be validly mined.

Evidence of importance:

  • PR description: 'A PSBT whose outputs are worth more than its inputs therefore gets a negative fee and a next role of updater, even though no wallet can ever sign it into a valid transaction.'

Risk of a mistake: low (rpc_api). A bug in this check could falsely reject or misreport the next role in analyzepsbt for valid PSBTs, but it only triggers when known outputs strictly exceed known inputs.

Reviewability

Paused · Waiting on author

Open objection from Yudis-bit with no author reply for 12 days; review would repeat what has been asked.

Waiting on (from the thread read):

  • author: response to suggestion about adding a unit test in psbt_tests 2026-10-19

Agreement

Strong

substantive support, no open objection (Husteem)

Thread notes: Added Husteem's Tested ACK and winterrdog's query regarding test scope. Yudis-bit's unit test suggestion remains open awaiting author response.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
Yudis-bit (none)suggestion, maintenanceConsider adding a unit test in psbt_testsopen · no author replyansweredno2026-10-19: 'Would it be worth also adding a unit test in psbt_tests?'

Support:

  • Yudis-bit (none) (Tested ACK, 2026-10-19) [tested]: tested on Windows [not substantive]
  • Husteem (none) (Tested ACK, 2026-10-20) [both: AnalyzePSBT, rpc_psbt.py]: guard in AnalyzePSBT is a good fix; verified bug on master and rpc_psbt.py passes

Participants:

  • Yudis-bit (none, support, 1 statements 2026-10-19 to 2026-10-19): Tested ACK; suggested adding a unit test in psbt_tests
  • Husteem (none, support, 2 statements 2026-10-20 to 2026-10-20): Tested ACK; supported adding a unit test but conceded functional tests cover the regression
  • winterrdog (contributor, neutral, 1 statements 2026-10-20 to 2026-10-20): questioned the motive for adding a unit test given existing functional test coverage

Files

8 lines under test/bench/ci.

  • test/functional/rpc_psbt.py +8/-0
  • src/node/psbt.cpp +5/-0

Card

The short text the ranking pass compares across PRs.

Updates analyzepsbt to report an error when output amounts exceed input amounts on a PSBT with all input values known. Currently, analyzepsbt calculates a negative fee and directs the user to updater or signer for a transaction that can never become valid. It now sets the next role to creator and returns an invalid PSBT error, aligning with existing checks for bad input values or unspendable outputs.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-21T01:20, confidence high, input hash 91065bfc18b8f739
thread read through 2026-10-20 (4 statements), head 8262933013
labels: PSBT

Categories

RPC / REST / ZMQ

P3 · bug fix (ranking pass: Moved up 9: corrects misleading analyzepsbt output (negative fee, wrong next role) for an impossible transaction.)

Fixes `analyzepsbt` calculating a negative fee and advising downstream roles like updater or signer for unspendable transactions. The change prevents confusing output when inputs and outputs are fully known.

Membership: Modifies `src/node/psbt.cpp` to adjust `analyzepsbt` RPC behavior and error reporting when PSBT outputs exceed inputs.

Factors: security/stability 0, bug 1, performance 0, user value 1, leverage 0