Feedback
Sign in./start

Site navigation

Theme

Learn

  • Roadmaps

Build

  • Projects
  • Developer Tools

Contribute

  • Open Source Projects
  • Issues
  • Reviews
  • First Contribution
  • BountiesSoon
  • Feedback

Prove

  • Builders

Ecosystem

  • Partners
  • Get Funded↗
  • HackathonsSoon
Sign in./start-building

Become an Open Source Builder. Learn. Build. Contribute. Prove.

Feedback welcome — open a GitHub issue.

Learn

RoadmapsStart Building

Build

ProjectsDeveloper Tools

Contribute

Open Source ProjectsIssuesReviewsFirst ContributionSupportFeedback

Prove

Builders Directory

Account

Sign in

Legal

PrivacyTermsCredits

© 2026 Pull // code MIT · curriculum CC BY-SA 4.0

PrivacyTermsCredits

lesson // bitcoin

UTXO Model

Understand inputs, outputs, and how wallets track spendable balances.

beginner4 days

Public lesson — sign in to track progress on this roadmap.

./sign-in

On this page

Learning objectives

  • Explain UTXOs versus account balances
  • Trace how inputs consume outputs and create new ones
  • Describe coin selection at a high level

study // plan

Lessons are primers. Start with Step 1 (required reading) when present, then follow the numbered steps in the article. Depth comes from primary sources, labs, reflection, and evidence.

Research on Bitcoin Search
UTXOcoin selectiontransaction output

Step 1 // Required reading

Complete these before the numbered steps in the lesson body. Links are listed here once — not repeated below.

  • bookMastering Bitcoin

    Ch. 6: Transactions

    Focus on inputs, outputs, and how value moves.

Interactive lab // Decoding Bitcoin

Open these Bitcoin Dev Project modules and tools before (or alongside) the graded lab. Capture evidence from the interactive path — do not only skim Pull.

  • Decoding Bitcoin: UTXO

    Interactive explainer - contrast UTXO vs account before the lab.

  • Decoding Bitcoin: Transaction structure

    See how outputs become the next spendable UTXOs.

Reflection prompts

  1. Explain UTXO Model to a teammate without jargon - what problem does it solve?
  2. What would break in production if you misunderstood UTXO Model?
  3. Which BIP, book chapter, or Core doc is authoritative here, and what did you verify?

Lab // Trace a UTXO spend

Complete Steps 2–3. Finish the Decoding Bitcoin UTXO module, then on regtest list unspent outputs, spend one, and show the new change/payment UTXOs created.

evidence required

  • ·Note or screenshot from the Decoding Bitcoin UTXO interactive section
  • ·Before/after listunspent (or wallet UTXO view) from regtest
  • ·One sentence explaining which output was consumed and which new locks appeared
  1. 01

    Worked mental model

    Re-read the diagrams in this lesson once out loud in plain language. If you cannot explain the flow to a friend without jargon, pause and revisit the Mastering Bitcoin / Mastering Lightning chapters linked in Resources. Chapter references are intentional, not decorative.

  2. 02

    Hands-on habit

    Every protocol idea should be paired with one local experiment. That habit turns reading into builder instinct.

    1. Reproduce the happy path on regtest (or Polar for Lightning)
    2. Break it on purpose (wrong fee, expired invoice, offline peer)
    3. Write down what error you saw and which layer produced it (wallet, node, mempool, peer)
  3. 03

    Glossary check

    Pick three terms from this lesson and define them in one sentence each without opening notes. Weak definitions mean the lesson is not finished yet.

  4. 04

    Resource order

    Use Resources in order: narrative book chapter first, then BIP/BOLT for precision, then implementation docs for commands. Jumping straight to RPC flags without the mental model creates brittle knowledge.

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:

  1. Consumes one or more UTXOs as inputs
  2. Creates one or more new outputs
  3. Pays the difference as a miner fee (no explicit fee output)

Loading diagram…

Inputs are fully consumed; change is a new UTXO; the remainder is the fee.
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.

No partial spends

Each input is fully consumed. There is no “spend half of this UTXO” without creating change.

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 listunspent

Each 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.

further reading

  • toolMempool.space
  • articleBitcoin Optech: Coin selection

review // club

Review club

Practice on real Bitcoin OSS changes tied to this chapter. Read the diff, use the checklist, and optionally paste your review comment URL in your lab notes.

  • BDK wallet good first issue

    Shortlist a BDK GFI related to UTXO or wallet APIs and draft a one-paragraph approach.

    gfi
    UTXO trackingAPI clarity
    30 min·intermediateopen on GitHub
review checklist
  1. Does the change solve the stated problem?
  2. Are edge cases and rollout behavior covered?
  3. Are tests or test vectors included?
  4. Is the diff minimal and clearly explained?

More repos and GFIs on /discover and /issues.

progress // sign in

Reading is public. Sign in to mark lessons complete, sync across devices, and unlock your roadmap.

./sign-in-to-track

discussion

Discussion

prevBitcoin EconomicsnextKeys & Addresses

On this page

Press Shift + ? for keyboard shortcuts.

Press R to research on Bitcoin Search.

No questions yet — be the first to ask.