From 8c03318387f6b3d1520a539f426b300bae316fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Mon, 2 Feb 2026 19:31:28 +0100 Subject: [PATCH] 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 --- src/consensus/tx_verify.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index ec612a55e6f..4efed70fd41 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -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",