diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 00022a33dd3..ec612a55e6f 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -197,6 +197,11 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state, // Tally transaction fees const CAmount txfee_aux = nValueIn - value_out; if (!MoneyRange(txfee_aux)) { + // Unreachable, given the following preconditions: + // * `value_out` comes from `tx.GetValueOut()`, which throws unless `MoneyRange(value_out)` and asserts `MoneyRange(nValueOut)` on return. + // * `MoneyRange(nValueIn)` was enforced in the input loop. + // * `nValueIn < value_out` was handled above, so `nValueIn >= value_out` here (and `txfee_aux >= 0`). + // Therefore `0 <= txfee_aux = nValueIn - value_out <= nValueIn <= MAX_MONEY`. return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-fee-outofrange"); }