Oddbean new post about | logout
 Now you too can manually audit the bitccoin without employing and cryptographic proofs:

def audit_bitcoin_supply():
	block_count = rpc_connection.getblockcount()
	total_supply = 0.0
	total_utxo_amount = 0.0
	for block_number in range(0, block_count + 1):
		block_hash = rpc_connection.getblockhash(block_number)
		block = rpc_connection.getblock(block_hash)
		coinbase_txid = block['tx'][0]  # Coinbase transaction is always the first transaction
		coinbase_tx = rpc_connection.getrawtransaction(coinbase_txid, True)
		block_reward = sum(vout['value'] for vout in coinbase_tx['vout'])
		total_supply += block_reward
	unspent_txos = rpc_connection.listunspent(0)
	total_utxo_amount = sum(utxo['amount'] for utxo in unspent_txos)
	print(f"Total Bitcoin Supply (based on block rewards): {total_supply:.8f} BTC")
	print(f"Total Bitcoin in UTXOs: {total_utxo_amount:.8f} BTC")
	print(f"Difference: {total_supply - total_utxo_amount:.8f} BTC")