Bitcoin Deep Dive

UTXO Model

The UTXO Model

Module 2 of Bitcoin Deep Dive


What Is a UTXO?

UTXO = Unspent Transaction Output

Bitcoin doesn't track account balances like a bank. Instead, it tracks individual "coins" — outputs from previous transactions that haven't been spent yet.

Your "balance" = Sum of all UTXOs you control.


The Mental Model: Digital Cash

Think of UTXOs like physical bills:

Traditional Bank:
  Alice's account balance: $100

UTXO Model:
  Alice controls:
    - UTXO #1: 50 BTC (from transaction abc...)
    - UTXO #2: 30 BTC (from transaction def...)
    - UTXO #3: 20 BTC (from transaction ghi...)
    Total: 100 BTC

Each UTXO is like a separate bill. To spend, you must use entire bills and get change back.


How Transactions Work

Structure of a Transaction

INPUTS:                          OUTPUTS:
┌─────────────────────┐         ┌─────────────────────┐
│ Reference to UTXO 1 │         │ 7 BTC to Address X  │
│ Signature proving   │   ──→   │ (new UTXO #1)       │
│ ownership           │         ├─────────────────────┤
├─────────────────────┤         │ 2.999 BTC to me     │
│ Reference to UTXO 2 │         │ (new UTXO #2 change)│
│ Signature           │         └─────────────────────┘
└─────────────────────┘

Inputs: References to existing UTXOs + proof of ownership (signature) Outputs: New UTXOs created by this transaction

Example Transaction

Alice wants to send 7 BTC to Bob:

Alice's UTXOs:

  • UTXO A: 5 BTC
  • UTXO B: 4 BTC

Transaction:

  • Inputs: UTXO A (5 BTC) + UTXO B (4 BTC) = 9 BTC
  • Output 1: 7 BTC to Bob
  • Output 2: 1.999 BTC to Alice (change)
  • Fee: 0.001 BTC (implicit: input - output)

Result:

  • UTXO A and B are "spent" (removed from UTXO set)
  • Two new UTXOs created (one for Bob, one for Alice's change)

The UTXO Set

The UTXO set is the complete database of all unspent outputs.

Current UTXO Set (~80 million UTXOs, ~5GB)
┌──────────────────────────────────────────┐
│ txid: abc123, output: 0, value: 5 BTC    │
│ txid: def456, output: 1, value: 0.5 BTC  │
│ txid: ghi789, output: 0, value: 100 BTC  │
│ ...                                      │
└──────────────────────────────────────────┘

Properties:

  • Every valid UTXO is in this set
  • When spent, UTXO is removed
  • New outputs are added
  • Full nodes maintain this set in memory

Why It Matters

Validating a transaction only requires:

  1. Check inputs exist in UTXO set
  2. Verify signatures
  3. Confirm input sum ≥ output sum

Don't need to scan entire blockchain history!


UTXO vs Account Model

Ethereum uses an account model. How do they compare?

AspectUTXO (Bitcoin)Account (Ethereum)
StateSet of coinsMap of balances
TransactionConsumes + creates UTXOsModifies balances
ParallelismHigh (independent UTXOs)Low (sequential nonces)
PrivacyBetter (new addresses)Worse (same address)
ComplexityComplex coin selectionSimpler logic
Smart contractsLimitedNative support
Light clientsEasier (Merkle proofs)Harder

Coin Selection

When spending, wallet must choose which UTXOs to use.

Strategies

1. Largest First Use biggest UTXOs first.

  • Pro: Fewer inputs, lower fees
  • Con: May create many small change outputs

2. Smallest First Use smallest UTXOs first.

  • Pro: Consolidates dust
  • Con: More inputs, higher fees

3. Branch and Bound Find exact match to avoid change.

  • Pro: Optimal fee, no change output
  • Con: Computationally expensive

4. Random Random selection weighted by value.

  • Pro: Privacy (less predictable)
  • Con: May not be optimal

Example

Want to send 1 BTC. Available UTXOs:

  • 0.5 BTC
  • 0.3 BTC
  • 0.25 BTC
  • 0.8 BTC

Option A: 0.8 + 0.25 = 1.05 BTC (2 inputs, 0.05 change) Option B: 0.5 + 0.3 + 0.25 = 1.05 BTC (3 inputs, higher fee)

Good wallets optimize for fee vs. privacy tradeoffs.


Dust and UTXO Bloat

What Is Dust?

Dust = UTXOs so small that spending them costs more in fees than they're worth.

UTXO value: 500 satoshis
Cost to spend: 1000 satoshis in fees
→ This UTXO is "dust" - uneconomical to spend

The Problem

Too many small UTXOs:

  • Bloat the UTXO set
  • Increase node resource requirements
  • May become permanently unspendable

Solutions

  1. Dust limits: Nodes reject outputs below threshold
  2. Consolidation: Combine small UTXOs when fees are low
  3. Batching: Combine multiple payments into one transaction

Transaction Fees

Fees in Bitcoin are calculated per byte, not per value.

Fee = Transaction size (bytes) × Fee rate (sat/byte)

What Affects Size?

ComponentApproximate Size
Input (P2PKH)~148 bytes
Input (P2WPKH)~68 bytes
Output (P2PKH)~34 bytes
Output (P2WPKH)~31 bytes
Overhead~10-12 bytes

Example:

  • 2 inputs (P2WPKH): 136 bytes
  • 2 outputs: 62 bytes
  • Overhead: 10 bytes
  • Total: ~208 bytes
  • At 50 sat/byte: 10,400 sats (~$4)

UTXO Implications

More inputs = larger transaction = higher fee

This is why UTXO management matters!


Privacy Implications

Address Reuse

UTXOs enable better privacy than accounts:

Bad: Receive all funds to same address
     → All transactions linked

Good: New address for each receive
      → Harder to link ownership

Change Address Problem

Change reveals information:

Inputs: 10 BTC from Address A
Outputs:
  - 3 BTC to Address B (recipient)
  - 6.999 BTC to Address C (change)

Observer can guess:
  - Address C is probably the spender's
  - A and C likely same owner

Heuristics Analysts Use

  1. Common input ownership: Inputs likely from same person
  2. Change detection: Round numbers usually payments
  3. Address reuse: Links transactions
  4. Timing analysis: Transaction patterns

CoinJoin and Privacy

CoinJoin: Multiple users combine transactions.

Normal:
Alice: 1 BTC → Bob (clearly Alice paid Bob)

CoinJoin:
Alice + Carol + Eve combine:
  Inputs: A(1), C(1), E(1)
  Outputs: B(1), D(1), F(1)

Who paid whom? Unclear!

UTXO model enables this privacy technique.


Key Takeaways

  1. Bitcoin has no balances — only UTXOs
  2. Transactions consume and create UTXOs — like spending and receiving bills
  3. UTXO set is the state — all you need to validate new transactions
  4. Coin selection matters — affects fees and privacy
  5. More inputs = higher fees — optimize UTXO management
  6. Better privacy than accounts — but not anonymous

Questions to Consider

  1. Why didn't Satoshi use a simpler account model?
  2. How does UTXO model affect Lightning Network design?
  3. What's the ideal UTXO count for a wallet?
  4. Can dust UTXOs ever become spendable again?