TeachMeBitcoin

How UTXOs Track Balances

From TeachMeBitcoin, the free encyclopedia โฑ๏ธ 3 min read

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:

  1. 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.
  2. Aggregation: It identifies all matching outputs and aggregates their values.
  3. 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:

  1. The Transaction Arrives: A node receives a transaction spending a specific transaction input (referred to by its OutPoint: txid + vout).
  2. Instant RAM Lookup: Instead of scanning the blockchain files on disk, the node looks up the OutPoint in its RAM-cached chainstate database (built using Googleโ€™s LevelDB).
  3. 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.
  4. Database Update: Once the block is confirmed, the node deletes the consumed OutPoint from the chainstate database and inserts the newly created outputs, keeping the active global state updated with maximum efficiency!
โ˜• Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!