mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 12:20:38 +00:00
psbt: analyzepsbt reports an error when outputs exceed inputs #36569
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36569
Loading…
Reference in a new issue
No description provided.
Delete branch "analyzepsbt-outputs-exceed-inputs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
AnalyzePSBTcomputesfee = in_amt - out_amtonce every input amount is known and returns it as is. A PSBT whose outputs are worth more than its inputs therefore gets a negativefeeand anextrole of updater, even though no wallet can ever sign it into a valid transaction. The function already returnsPSBT is not valid. ...for bad input values, unspendable outputs and an out-of-range output total.An output total above the input total is reported the same way:
The functional test builds a PSBT that spends a 1 BTC output into a 2 BTC output and checks the error and the
creatorrole. Without the change the assertion onnextfails.rpc_psbt.py,wallet_send.py,wallet_multisig_descriptor_psbt.py,rpc_openrpc.pyand the psbt unit tests pass.Base:
924f4c4ac78b0cd3b917c694f42c0651a6f3003aHead:
82629330135ba7df7ef5fc061ffadca3288043b1Findings
Major
Check fee optional before GUI dereference (src/node/psbt.cpp:123, head)
For a well-formed PSBT with all UTXOs supplied and outputs exceeding inputs, this change sets
analysis.feetonulloptinstead of returning an engaged negative amount. The file and clipboard import path inWalletFrame::gotoLoadPSBT()passes such PSBTs toopenWithPSBT(), which proceeds to render them even without a loaded wallet; a false return fromFinalizePSBT()does not stop rendering.renderTransaction()then dereferencesanalysis.feebefore displaying transaction status. Dereferencing the disengaged optional is undefined behavior and can abort the GUI in hardened builds. Other invalid PSBTs already expose this caller bug, but this change adds the overspending class. Preserve the validity check, and update the GUI to check optional engagement before dereferencing and add import regression coverage.Full review report
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Tested ACK
8262933013on Windows. Would it be worth also adding a unit test in psbt_tests?tACK
8262933Verified the bug on
master(where an overspending PSBT returned a negative fee, empty error, andsignerrole).rpc_psbt.pypasses on this branch.The guard in
AnalyzePSBTis a good fix.Also agree with @Yudis-bit - adding a companion unit test in
psbt_tests.cppwould be worthwhile for regression coverage here.@Husteem @Yudis-bit
Sorry for bikeshedding. I am trying to understand what the motive for a unit test is here.. What special thing would the unit test assert that the current functional test does not 🤔 ?
Hi @winterrdog. It's totally fine to enquire!
While I'd say it's a nit, obviously, the thought was mainly direct coverage on the C++ struct (
has_sane_fee = falseandfeestaying unset) without spinning up a test node.That said, since rpc_psbt.py already asserts both
errorandnext == 'creator'across the RPC boundary, you're pretty right that it covers the regression well enough.psbt_version=0doesn't seem required - v2 is the default.