consensus/doc: explain GetValueOut() precondition

`Consensus::CheckTxInputs` calls `tx.GetValueOut()` and assumes output-range checks already ran.
Document the mempool and block validation call paths where this is guaranteed.

Co-authored-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
Lőrinc 2026-02-02 19:31:28 +01:00
parent 82ef92c8d0
commit 8c03318387
No known key found for this signature in database
GPG Key ID: 669FFF0FFA477A76

View File

@ -188,6 +188,10 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,
}
}
// `tx.GetValueOut()` won't throw in validation paths because output-range checks run first
// (`bad-txns-vout-negative`, `bad-txns-vout-toolarge`, `bad-txns-txouttotal-toolarge`):
// * `MemPoolAccept::PreChecks`: `CheckTransaction()` is called before this method;
// * `Chainstate::ConnectBlock`: `CheckTransaction()` is called via `CheckBlock()` before this method.
const CAmount value_out = tx.GetValueOut();
if (nValueIn < value_out) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-in-belowout",