How UTXOs Track Balances
How UTXOs Track Balances and the Global State
When you open your Bitcoin wallet on your phone, you might see a single, clean balance like 0.05 BTC. However, at the protocol level, no such balance exists.
Your wallet balance is a synthetic calculation.
๐งฎ The Synthetic Balance Formula
To display your balance, your wallet software performs a search and aggregate operation:
- Scanning: The wallet scans the blockchain ledger (or asks an indexer node) for any active UTXOs whose
scriptPubKey(locking script) can be successfully unlocked by private keys derived from your seed phrase. - Aggregation: It identifies all matching outputs and aggregates their values.
- Summation: It performs the math:
$$\text{Synthetic Wallet Balance} = \sum_{i=1}^{N} \text{UTXO}_i$$
Wallet Derived Addresses Scanned UTXOs Aggregated Balance
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Address 1 (bc1q...) โโโโโบโ UTXO A: 0.015 BTC โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ โ
โ Address 2 (bc1q...) โโโโโบโ UTXO B: 0.030 BTC โโโโโบโ 0.050 BTC โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ โ
โ Address 3 (bc1q...) โโโโโบโ UTXO C: 0.005 BTC โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
If you received five separate transactions of 0.01 BTC each, your wallet holds five separate UTXOs, not a single coin of 0.05 BTC. To the network, those coins are physically separated.
๐๏ธ The Global UTXO Set: The Core of Bitcoin's State
At any point in time, the true state of the entire Bitcoin ledger is defined by the Global UTXO Set.
The UTXO Set is a database containing every single unspent transaction output that currently exists on the network. * Every transaction on the network consumes (destroys) one or more items from this set. * Every transaction adds (creates) one or more new items to this set. * As of 2026, there are roughly 180+ million individual UTXOs in the global set, weighing around 10โ12 Gigabytes in size.
โก The chainstate Database (Why Nodes Are So Fast)
If a Bitcoin node had to scan the entire multi-gigabyte transaction history on disk every time a user wanted to spend coins to verify that the coins weren't already spent, the network would grind to a halt.
To solve this, every Bitcoin Core node maintains a highly optimized database inside its directory named chainstate.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BITCOIN CORE NODE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ BLOCK STORAGE (Blocks 1 to 850,000+) โ CHAINSTATE DATABASE (LevelDB) โ
โ โข Hard Disk (Slow Storage) โ โข Cached in RAM (Ultra-Fast Lookup) โ
โ โข Multi-hundred Gigabytes โ โข ~10-12 Gigabytes in size โ
โ โข Historical Audit Trail โ โข Houses the active UTXO Set โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ How a Node Validates a Transaction:
- The Transaction Arrives: A node receives a transaction spending a specific transaction input (referred to by its OutPoint: txid + vout).
- Instant RAM Lookup: Instead of scanning the blockchain files on disk, the node looks up the OutPoint in its RAM-cached
chainstatedatabase (built using Googleโs LevelDB). - The Verdict:
- If the OutPoint is found in
chainstate, the coin is valid and unspent. The node validates the signature and approves the transaction. - If the OutPoint is not found, the coin has either already been spent or never existed. The node rejects the transaction immediately as an invalid double-spend.
- If the OutPoint is found in
- Database Update: Once the block is confirmed, the node deletes the consumed OutPoint from the
chainstatedatabase and inserts the newly created outputs, keeping the active global state updated with maximum efficiency!
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: