Bitcoin does not keep a global balance per address. It tracks unspent transaction outputs (UTXOs) — discrete chunks of value that can be spent exactly once.
Complete Step 1 // Required reading in the study plan above, then continue here. Use your Foundations regtest node for the hands-on step.
Step 2 — Core idea: inputs, outputs, change
If you think in bank-style “account balance” terms, you will mis-build wallets, explorers, and Lightning funding logic. UTXOs are the native accounting unit.
Analogy: Cash bills in a wallet. You do not subtract $7 from a $20 balance in place — you hand over bills and get change. Each bill is a UTXO.
A transaction:
- Consumes one or more UTXOs as inputs
- Creates one or more new outputs
- Pays the difference as a miner fee (no explicit fee output)
Loading diagram…
type Utxo = {
txid: string;
vout: number;
valueSats: number;
scriptPubKey: string;
};
const balance = utxos.reduce((sum, u) => sum + u.valueSats, 0);Wallet balance is the sum of UTXOs your keys can unlock — not a single number stored on-chain.
When sending, wallets select coins. Goals often include minimizing fees, avoiding unnecessary change, and preserving privacy when possible.
Done when: You can explain fee = inputs − outputs and why change is a new UTXO.
Step 3 — Try it: count and spend UTXOs (lab)
Complete the Decoding Bitcoin UTXO interactive, then on regtest:
ADDR=$(bitcoin-cli -regtest getnewaddress)
bitcoin-cli -regtest generatetoaddress 101 "$ADDR"
bitcoin-cli -regtest listunspentEach listunspent row is a UTXO (txid, vout, amount). Send, then list again — some rows disappear and new ones appear (payment + change).
Very small UTXOs can cost more in fees to spend than they are worth (dust). Consolidation improves future fee efficiency but links history (privacy tradeoff).
Common mistakes
- Forgetting change and accidentally overpaying the fee
- Creating dust that costs more to spend later than it is worth
- Assuming address-balance APIs equal UTXO-aware wallet state
Done when: Lab evidence (Decoding note + before/after listunspent + one-sentence spend story) is complete.
Next lesson
Keys & Addresses — how private keys become the locking conditions on those UTXOs.