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.
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.
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.
// 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.
Commented
May 17, 2020 at 9:35
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.