<p>There is no point. It would just be slower and more complex for no gain.</p>

<p>Despite what the name may imply, that test is not there to enforce the inflation schedule. It's there to prevent exploiting integer overflow (something which happened in Bitcoin's early history).</p>

<p>The test could be replaced with <code>&gt; 1000000000000000000</code> instead and be equally effective.</p>

CC BY-SA 4.0
2020-05-17T09:35:07.260Z
Just to elaborate a tiny bit: Five lines above the [line linked in the question](https://github.com/bitcoin/bitcoin/blob/aaaaad6ac95b402fe18d019d67897ced6b316ee0/src/consensus/tx_check.cpp#L27) there is a comment saying `// Check for negative or overflow output values (see CVE-2010-5139)`. Looking up that CVE (any search engine) yields the explanation regarding integer overflow. The only reason I looked is because when I read Pieter's answer my immediate thought was - "that's the sort of thing I'd put in a comment against that line of code" - so I looked to see if someone had done that or not.
RedGrittyBrick
CC BY-SA 4.0
2020-05-17T04:01:25.173Z
2020-05-17T04:01:25.173Z
Pieter Wuille
<p>Added explanation: There is also no direct way of calculating "circulating supply". Circulation is not something the protocol can identify. By circulating supply we simply mean</p>

<p><code>TotalSupply - ((coins estimated to be lost) + (satoshi's coins))</code>.</p>

<p>Trying to enforce against circulating supply in the protocol will be unnecessarily heuristical and will provide no functional benefit.</p>

<p>To verify no new money is created, its enough to just check against max money.   </p>

CC BY-SA 4.0
2020-05-17T15:33:19.733Z
2020-05-17T15:33:19.733Z
Rajarshi Maitra
<p><a href="https://github.com/bitcoin/bitcoin/blob/aaaaad6ac95b402fe18d019d67897ced6b316ee0/src/consensus/tx_check.cpp#L27" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/aaaaad6ac95b402fe18d019d67897ced6b316ee0/src/consensus/tx_check.cpp#L27</a></p>

<p>If <code>txout.nValue</code> is more than the circulating supply and less than <code>MAX_MONEY</code>, <code>CheckTransaction</code> would return true.</p>

<p>Why not check <code>txout.nValue</code> against the circulating supply? and if it is above then just return false at that point.</p>

<transactions><output>
Check txout against the circulating supply instread of MAX_MONEY
yahiheb
# Check txout against the circulating supply instread of MAX_MONEY

(Asked by: username_0 on 2020-05-17)

<https://github.com/bitcoin/bitcoin/blob/aaaaad6ac95b402fe18d019d67897ced6b316ee0/src/consensus/tx_check.cpp#L27>

If `txout.nValue` is more than the circulating supply and less than `MAX_MONEY`, `CheckTransaction` would return true.

Why not check `txout.nValue` against the circulating supply? and if it is above then just return false at that point.

**Tags:** transactions, output


---

## 2 answers

### Answer by username_1 on 2020-05-17. Score: 2 | Accepted answer

There is no point. It would just be slower and more complex for no gain.

Despite what the name may imply, that test is not there to enforce the inflation schedule. It's there to prevent exploiting integer overflow (something which happened in Bitcoin's early history).

The test could be replaced with `> 1000000000000000000` instead and be equally effective.

> **Comments:**
> **username_2**: Just to elaborate a tiny bit: Five lines above the [line linked in the question](https://github.com/bitcoin/bitcoin/blob/aaaaad6ac95b402fe18d019d67897ced6b316ee0/src/consensus/tx_check.cpp#L27) there is a comment saying `// Check for negative or overflow output values (see CVE-2010-5139)`. Looking up that CVE (any search engine) yields the explanation regarding integer overflow. The only reason I looked is because when I read username_1's answer my immediate thought was - "that's the sort of thing I'd put in a comment against that line of code" - so I looked to see if someone had done that or not.  

---

### Answer by username_3 on 2020-05-17. Score: 0

Added explanation: There is also no direct way of calculating "circulating supply". Circulation is not something the protocol can identify. By circulating supply we simply mean

`TotalSupply - ((coins estimated to be lost) + (satoshi's coins))`.

Trying to enforce against circulating supply in the protocol will be unnecessarily heuristical and will provide no functional benefit.

To verify no new money is created, its enough to just check against max money.


---

