Bitcoin Protocol Deep Dive

🤔 Before We Begin: Think Like a Protocol Designer

Before diving into Bitcoin's transaction model, consider the fundamental problems you'd need to solve:

How do you represent digital money without a bank database?

If there's no central ledger tracking account balances, how do you know who owns what?

🔁
How do you prevent double-spending without a trusted authority?

What stops someone from spending the same digital coin twice in different transactions?

How do you prove ownership without revealing your identity?

Can you have privacy AND security in digital transactions?

📝
What data structure would allow 18,000 independent nodes to agree on transaction order?

How do you design a system where everyone can verify everything independently?

Bitcoin's answer to all of these: The UTXO Model

Prerequisites: Blockchain Basics

Before diving into UTXOs, you should understand that Bitcoin uses a blockchain—a shared ledger that records all transactions in sequential blocks. Each block contains multiple transactions, and blocks are linked together chronologically.

Need a Blockchain Refresher?

If you haven't learned about blockchain basics yet, we recommend starting with:

✓ Already familiar with blockchain? Continue below to learn about Bitcoin's unique UTXO model.

Quick Review: Key Blockchain Terms
  • Block: A batch of transactions grouped together
  • Blockchain: Blocks linked together in chronological order
  • Transaction: A record of value transfer from one address to another
  • Ledger: The complete record of all transactions (the blockchain itself)

The UTXO Model: Bitcoin's Transaction System

Bitcoin doesn't track account balances like a bank. Instead, it tracks Unspent Transaction Outputs (UTXOs)— individual "coins" of various denominations that can be spent once and only once.

How UTXOs Work

Think of UTXOs like physical cash:

  • You have several bills in your wallet: $5, $10, $20
  • To pay $15, you give the $20 bill and receive $5 change
  • The $20 bill is now "spent" (destroyed)
  • You receive a new $5 bill as change

Bitcoin transactions work the same way:

  • Inputs: UTXOs you're spending (destroyed in the transaction)
  • Outputs: New UTXOs created for recipients and change
  • Rule: Sum of outputs ≤ Sum of inputs (difference = miner fee)

Transaction Structure

Every Bitcoin transaction has:

{
  "txid": "abc123...",        // Unique transaction ID
  "version": 2,               // Transaction version
  "inputs": [                 // UTXOs being spent
    {
      "txid": "def456...",    // Previous transaction
      "vout": 0,              // Output index
      "scriptSig": "...",     // Signature proving ownership
      "sequence": 4294967295
    }
  ],
  "outputs": [                // New UTXOs being created
    {
      "value": 50000000,      // Amount in satoshis
      "scriptPubKey": "..."   // Locking script (conditions)
    }
  ],
  "locktime": 0               // Block height/time lock
}

Master UTXO Management

Understanding UTXOs is critical for Bitcoin development. Use this advanced visualizer to explore:

  • UTXO selection strategies
  • Fee optimization techniques
  • Privacy considerations (address clustering)
  • Dust management
  • Raw transaction data and scripts

⚙️ UTXO Visualizer - Advanced Mode

Full UTXO management with technical details panel showing raw transaction data, fee calculations, and script inspection.

Launch UTXO Visualizer (Advanced Mode) →

All 6 scenarios available + expert challenge. Technical panel shows raw tx data, scripts, and fee breakdowns.

Mempool & Fee Market Economics

Deep dive into Bitcoin's fee market mechanics. Understand how mempool dynamics work, how miners prioritize transactions, and master fee estimation strategies. Essential knowledge for building Bitcoin applications!

Launch Mempool Visualizer →

Complete all 5 steps including block building simulation, fee market analysis, and practical scenarios!

Additional Practice: UTXO Transaction Builder

Build a transaction by selecting UTXOs and creating outputs. See how change works!

📦 Your Available UTXOs (Click to Select)

📥 Transaction Inputs (Selected UTXOs)

Click UTXOs above to add as inputs...

Total Input Value: 0 sats

📤 Transaction Outputs

No outputs added yet...

Total Output Value: 0 sats

Transaction Summary

Total Inputs: 0 sats
Total Outputs: 0 sats
Miner Fee: 0 sats
Change Required: 0 sats

Try creating a transaction with exact change vs. requiring change output. Notice how fees work!

🔬 Optional Deep Dive: Bitcoin Script

⚠️ Advanced Topic: This section covers low-level technical details. Feel free to skip if you're new to Bitcoin development — we'll cover this in depth in Stage 3, Module 2 (Building with Bitcoin) when creating transactions from scratch.

📜 How are UTXOs locked and unlocked? (Click to expand)

UTXOs are locked with Bitcoin Script—a stack-based programming language that defines spending conditions.

Common Script Types

1. Pay-to-Public-Key-Hash (P2PKH) - The original Bitcoin address format:

OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

2. Pay-to-Script-Hash (P2SH) - Allows complex scripts like multisig:

OP_HASH160 <scriptHash> OP_EQUAL

3. Pay-to-Witness-Public-Key-Hash (P2WPKH) - SegWit format:

OP_0 <pubKeyHash>

Scripts enable features like multisignature wallets, timelocks, and atomic swaps without requiring protocol changes!

💡 Learn More: We'll dive deep into Bitcoin Script, transaction construction, and signing in Stage 3, Module 2.

Key Takeaways

  • Bitcoin uses the UTXO model, not account balances
  • Transactions consume inputs and create outputs
  • Each UTXO can only be spent once (prevents double-spending)
  • Bitcoin Script locks UTXOs with spending conditions
  • Difference between inputs and outputs = miner fee
  • Every node independently verifies all transactions