<p><a href="https://github.com/bitcoin/bitcoin/search?q=bad-txns-in-belowout&amp;unscoped_q=bad-txns-in-belowout" rel="noreferrer">https://github.com/bitcoin/bitcoin/search?q=bad-txns-in-belowout&amp;unscoped_q=bad-txns-in-belowout</a></p>

<pre><code>const CAmount value_out = tx.GetValueOut();
if (nValueIn &lt; value_out) {
    return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
        strprintf("value in (%s) &lt; value out (%s)", FormatMoney(nValueIn), FormatMoney(value_out)));
}
</code></pre>

CC BY-SA 4.0
2019-03-27T13:58:47.797Z
2019-03-27T13:58:47.797Z
amaclin
<p>I'm searching the function that validates a transaction according to <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages" rel="nofollow noreferrer">Protocol rules - "tx" messages</a> especially step 14 <code>sum(vin) &gt; sum(vout)</code>.</p>

<p>I found <a href="https://github.com/bitcoin/bitcoin/blob/f7a21dae5dbf71d5bc00485215e84e6f2b309d0a/src/main.cpp#L939" rel="nofollow noreferrer">this</a> interesting function <code>CheckTransaction(const CTransaction&amp; tx, CValidationState &amp;state)</code> but it does not validate step 14, right?</p>

<p>Where is this check for step 14?</p>

<bitcoin-core><bitcoin-core-development><transaction-verification>
Where is sum(vin) > sum(vout) check in Bitcoin Core?
Piu130
# Where is sum(vin) > sum(vout) check in Bitcoin Core?

(Asked by: username_0 on 2019-03-27)

I'm searching the function that validates a transaction according to [Protocol rules - "tx" messages](https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages) especially step 14 `sum(vin) > sum(vout)`.

I found [this](https://github.com/bitcoin/bitcoin/blob/f7a21dae5dbf71d5bc00485215e84e6f2b309d0a/src/main.cpp#L939) interesting function `CheckTransaction(const CTransaction& tx, CValidationState &state)` but it does not validate step 14, right?

Where is this check for step 14?

**Tags:** bitcoin-core, bitcoin-core-development, transaction-verification


---

## 1 answers

### Answer by username_1 on 2019-03-27. Score: 6 | Accepted answer

https://github.com/bitcoin/bitcoin/search?q=bad-txns-in-belowout&unscoped_q=bad-txns-in-belowout
const CAmount value_out = tx.GetValueOut();
if (nValueIn < value_out) {
    return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
        strprintf("value in (%s) < value out (%s)", FormatMoney(nValueIn), FormatMoney(value_out)));
}


---

