Auditing Bitcoin Supply
The Bitcoin network does not hold any assets, bitcoins are not backed by anything.
What the Bitcoin network does is issue a claim on some quantity of satoshis (1 btc = 100,000,000 satoshis), a liability.
These network liabilities, called outputs, each have a smart contract to cryptographically secure their future transfer.
An output can only be unlocked and transferred if an input is provided that fulfills the spending conditions of the output's smart contract.
The asset owned by the user is generally just a private key that can fulfill the spending conditions of some set of unspent outputs (UTXOs).
The issuance of satoshis is governed by an open p2p network of nodes, run by users, enforcing strict adherence to specific Bitcoin protocol rules.
Miners who propose a valid block to the network can transfer newly issued satoshis to themselves based on a formula with one variable: the block's height.
Every node on the Bitcoin network divides the block height by a fixed issuance halving interval, 210,000 blocks. Rounding to the nearest whole number gives us how many halvings to apply to the 50 BTC initial per-block subsidy.
Halvings are applied by "right shifting" the binary representation of the subsidy, where the last bit is dropped and a zero is prepended in front. Each right shift applied causes a halving of issuance.
Here is the C++ code for this function as implemented in Bitcoin Core:
Here are the results of that function at each of the halving heights, blocks mined at this height and before the next row's height can create at most the calculated subsidy:
|Height||Halvings||Right shifted binary representation of subsidy||Subsidy integer||Total satoshis issued|
This gives us a precise understanding of Bitcoin's issuance consensus rule.
Note that 21 million bitcoin, 2,100,000,000,000,000 satoshis, was a lie.
It's actually 2,099,999,997,690,000 satoshis.
That's a 2,310,000 satoshi difference.
Thankfully it's deflationary trivia in our favor.
This is why we run the numbers.
Next we want to test if total issuance is equal to or less than the issuance consensus. Why "or less than"? The protocol rules do allow miners to irrationally not issue bitcoin, and this has happened due to bugs in proprietary mining software.
Miners issue bitcoin by creating a coinbase transaction, which is special because it has no inputs, and they put this coinbase transaction inside the block they are going to mine.
The mining process includes this special transaction, so the resulting nonce is uniquely tied to it. Only the miner that did the proof of work, hashed enough to find the winning nonce unique to the miner's block, can benefit from it.
The coinbase transaction does not just include the new bitcoin being issued, called the subsidy. It also includes transaction fees.
To calculate the transaction fees we add all of the outputs that are being spent and subtract all of the new outputs (excluding the coinbase transaction's new outputs).
This is the transaction fee revenue being paid to the miners. We can subtract it from the total coinbase claimed to derive actual new issuance.
If the miner pays themself even less than the transaction fees, then they are actually destroying bitcoin, permanently taking them out of the UTXO set.
The reconciling equation can be thought of this way:
Expected issuance = UTXO set + coinbase losses + unspendable outputs
We want to actually calculate this equation at every block height to potentially uncover a deflation or inflation bug.
What are unspendable outputs? Fabian Jahr has an in-depth description of them here: https://blog.okcoin.com/2020/05/12/btc-developer-asks-where-are-the-coins/
- Genesis block
- Other https://bitcointalk.org/index.php?topic=675321.0
We already know expected issuance at every block height from the above recalculation.
Here are the other two equations:
Coinbase losses = subsidy + transaction fees - coinbase outputs
Transaction fees = spent outputs - new outputs ex-coinbase
How can we operationally calculate the sum of the UTXO set, coinbase losses, and unspendable outputs at every block height? The Bitcoin blockchain is hundreds of gigabytes, iterating through it and parsing the relevant data is no small task.
Thankfully the same Fabian Jahr who identified the unspendables has been developing a data index in Bitcoin Core to gather statistics about the UTXO set at every block height.
This index is exactly what we need, by combining it with our own expected issuance calculations we can easily test our equations balance, that debits equal credits.
Our hero Fabian has also written a data exporter for this index.
This allows us to easily dump out a large ~109 MB CSV file.
At every block height, we can subtract total UTXOs and cumulative unspendables from the expected issuance to make sure Bitcoin's actual monetary policy is sound.
|Block Height||Expected Issuance||Sum of UTXOs||Unspendables and Coinbase Losses||Difference|
We can and should perform more tests on this data to try to identify exceptions that are not being accounted for, but being able to prove out expected issuance with actual balances is a crucial part of auditing Bitcoin's supply.