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:
1 file changed
+4
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user