Bitcoin — Digital Gold, Censorship-Resistant Money, and the Lightning Network

From Satoshi's nine-page whitepaper to a $1 trillion network: how Byzantine fault tolerance, SHA-256, and economic incentives combine to create the first credibly scarce digital asset. Covers the UTXO model, Bitcoin Script, Nakamoto consensus, the halving schedule, and Lightning's multi-hop HTLCs.

Prereq: public-key cryptography, hash functions Time to read: ~45 min Interactive diagrams: 2 UPDATED Apr 11 2026 19:32

1. Overview

Bitcoin is a peer-to-peer electronic cash system that allows online payments to be sent directly from one party to another without going through a financial institution. That single sentence — from Satoshi Nakamoto's October 2008 whitepaper — contains a 50-year-old unsolved computer science problem: how do you prevent double-spending without a trusted third party?

The answer Satoshi provided was not any single new idea, but a synthesis of:

The precursors to Bitcoin

ProjectYearCreatorKey ideaWhy it failed
DigiCash / eCash1989David ChaumBlind signatures for anonymous electronic paymentsCentralized — Chaum's company controlled the mint. Filed for bankruptcy 1998.
b-money1998Wei DaiPseudonymous distributed electronic cash; PoW-based coin creationNever implemented — no solution to Sybil attacks or bootstrapping
Bit gold1998Nick SzaboTimestamped PoW puzzles chained together; digital collectibles with scarcityNever implemented; required trusted parties to record ownership
Hashcash1997Adam BackProof-of-work stamps to deter email spam; SHA-1 partial preimageNot currency — no ledger or double-spend protection
RPOW2004Hal FinneyReusable Proofs of Work — transferable Hashcash tokensCentralized server tracked balances; single point of failure

Each precursor solved part of the problem. Bitcoin was the first to combine all the pieces with a viable incentive structure that made the network self-sustaining.

Programmable scarcity: the 21 million cap

The total supply of bitcoin is hard-capped at 20,999,999.9769 BTC — effectively 21 million. This cap is enforced by the consensus rules that every full node verifies independently. No authority can inflate the supply. This is categorically different from any fiat currency or previous digital cash system.

THE CORE INSIGHT

Scarcity is trivial to enforce digitally when you can run a deterministic program. What was hard was creating a scarcity that no single party controls. Bitcoin solves this by distributing the rule enforcement across tens of thousands of independent nodes — changing the cap would require convincing all of them to run different software simultaneously, which is economically irrational for anyone who holds bitcoin.

2. The UTXO model

Bitcoin does not track account balances. Instead it tracks Unspent Transaction Outputs (UTXOs). Your "balance" is the sum of all UTXOs that you can unlock with your private key.

How UTXOs are created and spent

UTXO
A discrete chunk of bitcoin locked to a specific script (usually a public key hash). Every UTXO must be spent in full — you cannot partially spend a UTXO.
Coinbase tx
The first transaction in every block. It has no inputs — it creates new UTXOs from thin air, subject to the block reward schedule.
scriptPubKey
The locking script attached to an output. Defines the conditions that must be met to spend this UTXO.
scriptSig
The unlocking script provided by the spender. When concatenated with scriptPubKey and executed, must leave a truthy value on the stack.
UTXO set
The complete set of all unspent outputs currently on the chain. Every full node maintains this ~5 GB dataset in memory for fast validation.
Change output
When spending a UTXO larger than required, the excess is sent back to the sender as a new UTXO — like receiving change from a banknote.

A transaction consumes one or more UTXOs (inputs) and creates one or more new UTXOs (outputs). The sum of input values must exceed or equal the sum of output values; the difference is the miner fee. Once a UTXO is spent it is removed from the UTXO set forever.

Interactive UTXO spending diagram

Alice has 3 UTXOs. Click "Send 1.5 BTC to Bob" to watch inputs consumed and outputs created.

UTXO vs. account model

PropertyUTXO (Bitcoin)Account (Ethereum)
StateSet of unspent outputs — no balancesMapping of address → balance + nonce + code
ParallelismTransactions spending different UTXOs are fully independent — easily parallelisableTransactions from the same account must be ordered by nonce
PrivacyEasier to use fresh addresses per transaction (no linking)Single address reuse is the norm, links all activity
Replay protectionBuilt-in: a UTXO can only be spent once; txid encodes the outpointRequires explicit nonce field; EIP-155 chain ID
SPV proofsSimple — just verify the UTXO's Merkle path and it hasn't been spentRequires stateful proof (Patricia trie witnesses)
Smart contractsDifficult — UTXO script is limited and statelessNatural — contracts hold their own state and balance
WHY UTXO PROVIDES NATURAL PARALLELISM

Each UTXO is an independent piece of state. Two transactions that spend different UTXOs have zero shared state — they can be validated simultaneously on different CPU cores. This is one reason why high-throughput UTXO chains (like the proposed Bitcoin rollups) are attractive: the validation bottleneck can be parallelized across shards.

3. Bitcoin Script

Bitcoin's transaction validation language is a minimal, stack-based scripting system inspired by Forth. It is deliberately not Turing-complete: there are no loops and no unbounded recursion. Every script terminates in a bounded number of steps, making it trivially analyzable and preventing denial-of-service via infinite loops.

How the stack machine works

Execution proceeds left to right. Data items are pushed onto the stack. Opcodes pop items off the stack, perform an operation, and push the result. When execution finishes, if the top of the stack is non-zero (truthy), the script passes and the UTXO is validly spent.

P2PKH: Pay to Public Key Hash

The most common output type, used in >70% of all Bitcoin transactions. The locking script (scriptPubKey) is:

OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

To spend, Alice provides the unlocking script (scriptSig):

<sig> <pubKey>

Step-by-step execution:

StepInstructionStack (top → bottom)
1Push <sig>[sig]
2Push <pubKey>[pubKey, sig]
3OP_DUP[pubKey, pubKey, sig]
4OP_HASH160[HASH160(pubKey), pubKey, sig]
5Push <pubKeyHash>[pubKeyHash, HASH160(pubKey), pubKey, sig]
6OP_EQUALVERIFY[pubKey, sig] — aborts if hashes don't match
7OP_CHECKSIG[1] if signature verifies against pubKey and tx hash

P2SH, SegWit, and Taproot

Script typeIntroducedKey featureAddress prefix
P2PKGenesisPay directly to public key. Used by early miners. Vulnerable if ECDSA is broken.
P2PKHGenesisPay to hash of public key. Hides full public key until spend time.1…
P2SHBIP 16 (2012)Pay to hash of redeem script. Shifts burden of providing complex script to spender.3…
P2WPKHSegWit (2017)Witness data separated from tx body. Fixes transaction malleability. Lower fees.bc1q…
P2WSHSegWit (2017)P2SH equivalent for SegWit. Script in witness data.bc1q…
P2TR (Taproot)BIP 341 (2021)Schnorr signatures + MAST. All outputs look identical whether key-path or script-path spent.bc1p…

Taproot is the most significant upgrade since SegWit. It combines three improvements:

In Taproot, key-path spending uses a tweaked public key that commits to the entire MAST root. If both parties cooperate (as in a Lightning channel close), only a single Schnorr signature appears on-chain — indistinguishable from a simple payment.

Common opcodes

OpcodeHexOperation
OP_00x00Push empty byte array (falsy)
OP_DUP0x76Duplicate top stack item
OP_HASH1600xa9RIPEMD160(SHA256(top)) — produces 20-byte hash
OP_EQUAL0x87Pop two, push 1 if equal, else 0
OP_EQUALVERIFY0x88OP_EQUAL then OP_VERIFY — aborts if not equal
OP_CHECKSIG0xacPop sig and pubkey; verify ECDSA sig over sighash; push 1/0
OP_CHECKMULTISIG0xaeM-of-N threshold signature check
OP_CHECKLOCKTIMEVERIFY0xb1Fail if current block height/time < specified value (BIP 65)
OP_CHECKSEQUENCEVERIFY0xb2Fail if input's relative lock time is less than specified (BIP 112, used by Lightning)
OP_RETURN0x6aMark output unspendable; embed arbitrary data (used for OP_RETURN outputs)
OP_CHECKSIGADD0xbaTapscript: adds to a running sig count (replaces OP_CHECKMULTISIG)
▶ P2PKH execution in pseudocode (Python-style)
# Script: <sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

stack = []
script = [sig, pubKey, OP_DUP, OP_HASH160, pubKeyHash, OP_EQUALVERIFY, OP_CHECKSIG]

for op in script:
    if op == OP_DUP:
        stack.append(stack[-1])            # duplicate top
    elif op == OP_HASH160:
        top = stack.pop()
        stack.append(ripemd160(sha256(top)))
    elif op == OP_EQUALVERIFY:
        a, b = stack.pop(), stack.pop()
        if a != b:
            raise ScriptError("EQUALVERIFY failed")  # abort, UTXO not spent
    elif op == OP_CHECKSIG:
        pub = stack.pop()
        sig = stack.pop()
        tx_hash = compute_sighash(current_tx, input_index)
        valid = ecdsa_verify(sig, tx_hash, pub)
        stack.append(1 if valid else 0)
    else:
        stack.append(op)   # push data item

assert stack[-1] != 0, "Script failed"
# UTXO is validly spent

4. Nakamoto Consensus

Nakamoto consensus is the mechanism by which the Bitcoin network agrees on a single canonical chain history without a trusted coordinator. It combines proof-of-work, the longest-chain rule, and economic incentives to achieve probabilistic finality.

Proof of Work: SHA-256 double hash

To produce a valid block, a miner must find a nonce such that the double-SHA-256 hash of the 80-byte block header is numerically less than a target value:

SHA256(SHA256(header)) < target

The difficulty target is a 256-bit number. A smaller target means fewer valid hashes exist, so on average more hashes must be tried. The current difficulty requires the hash to start with approximately 76 leading zero bits — corresponding to roughly 10²³ hashes per valid block.

Difficulty adjustment

Every 2016 blocks (~2 weeks at 10 min/block), every node independently adjusts the target:

new_target = old_target × (actual_time / 1,209,600 seconds)

If blocks came faster than 10 minutes, the target decreases (harder). If slower, the target increases (easier). This self-regulating mechanism keeps block time near 10 minutes regardless of how much hash rate joins or leaves the network.

The longest-chain rule

When two miners find valid blocks simultaneously, a fork occurs. Nodes follow whichever chain has the most accumulated proof-of-work (not longest by block count, but heaviest by total difficulty). Miners build on the heaviest chain because building on a lighter chain is statistically certain to waste revenue.

Probabilistic finality: why 6 confirmations?

After a block containing your transaction is mined, each subsequent block (confirmation) makes reversing the transaction exponentially harder. Satoshi's original paper provided the exact analysis: an attacker with fraction q of total hash rate and honest miners with fraction p = 1 - q has probability:

P(attack succeeds after z confirmations) ≈ 1 − Σₖ₌₀ᶻ [e^(−λ) λᵏ / k!] × [1 − (q/p)^(z−k)]

where λ = z(q/p). For an attacker with 10% of hash rate:

ConfirmationsAttacker probability (q=10%)Attacker probability (q=30%)
10.20450.4958
30.05400.3586
60.00150.1773
120.00000240.0314

Six confirmations provides <0.15% chance of reversal for an attacker with 10% of hash rate — considered safe for most payments. Exchanges handling large amounts typically require 3–6 confirmations; high-value transactions (Bitcoin ETF custodians) may require 12–30.

Selfish mining

In the selfish mining attack (Eyal & Sirer, 2013), a mining pool withholds valid blocks to gain a disproportionate share of rewards. A pool with just 25–33% of hash rate can earn more than its fair share by strategically releasing blocks. This attack is mitigated by propagation speed and the fact that large pools are publicly identifiable — the community can coordinate a fork to punish them.

Mining pools

Solo mining is impractical for most participants — at current difficulty, a single ASIC miner would expect to find a block every 20,000 years. Pools aggregate hash rate, find blocks more frequently, and distribute rewards proportionally. Major pools (Foundry USA, AntPool, ViaBTC) each control 15–25% of hash rate. A cartel of the top 3 pools approaching 51% is a recurring concern for decentralization maximalists.

5. Mining economics

Block subsidy and the halving schedule

Every Bitcoin block awards the miner a subsidy — newly created BTC. This subsidy halves every 210,000 blocks (~4 years):

EraBlock rangeApprox. dateSubsidy (BTC)Total BTC issued in era
10 – 209,9992009–201250.0010,500,000
2210,000 – 419,9992012–201625.005,250,000
3420,000 – 629,9992016–202012.502,625,000
4630,000 – 839,9992020–20246.251,312,500
5840,000 – 1,049,9992024–20283.125656,250
61,050,000 – 1,259,9992028–20321.5625328,125
≥33~6,930,000+~2140~0 (dust)Approaches 21M asymptotically

The geometric series sums to exactly 21 × 10⁶ BTC: Σ (50 × 210,000 / 2ⁿ) for n=0,1,2,... = 50 × 210,000 × 2 = 20,999,999.97…

The fee market

As the block subsidy approaches zero, miner revenue must come entirely from transaction fees. This is not a bug — it is the designed long-term security model. The theory: as Bitcoin becomes more valuable, the total economic activity it processes grows, and fees per block should be sufficient to incentivize mining. Critics note this assumes perpetually growing on-chain demand, which is uncertain.

OPEN RESEARCH QUESTION

The "fee market transition" is Bitcoin's most debated long-term security question. Block reward will be below 0.1 BTC by ~2032, below 0.01 BTC by ~2036. Will transaction fee revenue provide sufficient miner incentive to maintain hash rate? Some researchers (e.g., Eric Budish) argue the answer is no without protocol changes or dramatically higher adoption.

ASIC arms race

Bitcoin mining is dominated by Application-Specific Integrated Circuits (ASICs) custom-designed for SHA-256 double-hashing. Modern ASICs (Bitmain S21 XP: ~270 TH/s, 14.2 J/TH) are 10,000,000x more energy-efficient than the CPU mining of 2009. The arms race has priced out individual hobbyist miners and concentrated hardware production in a small number of foundries (primarily TSMC and Samsung, building chips for Bitmain and MicroBT).

Geographic distribution

Post the 2021 Chinese mining ban, the geographic distribution shifted dramatically. Current estimates (Cambridge CBECI, 2025):

CountryEst. % of hash ratePrimary energy source
United States~38%Stranded natural gas, curtailed renewables, hydro (PNW)
Kazakhstan~13%Coal-heavy grid; some stranded gas
Canada~7%Hydro (Quebec, BC)
Russia~6%Cheap stranded gas, hydro (Siberia)
Germany~4%Mixed; some renewables
Other~32%Varies widely

6. The Lightning Network

On-chain Bitcoin throughput is approximately 7 transactions per second — insufficient for global retail payments. The Lightning Network is a Layer 2 payment channel network that enables near-instant, low-fee microtransactions without trusting a custodian.

Payment channels

A payment channel between Alice and Bob is created by locking BTC in a 2-of-2 multisig funding transaction on-chain. Once open, the two parties exchange signed commitment transactions off-chain, each of which represents the current balance split. Sending a payment = exchanging a new commitment transaction. Only the final state needs to be broadcast to close the channel.

Funding tx
On-chain 2-of-2 multisig transaction locking channel capacity. Both parties must sign to spend it.
Commitment tx
Off-chain signed transaction representing current balance state. Never broadcast unless channel closes.
Revocation key
Secret that allows punishing a party who broadcasts an old (revoked) commitment transaction.
HTLC
Hash Time Locked Contract — the primitive that enables multi-hop payments.

Multi-hop routing with HTLCs

If Alice wants to pay Dave 0.001 BTC but doesn't have a direct channel, she can route through Charlie (who has channels to both). The routing uses Hashed Time Locked Contracts:

  1. Dave generates a random secret R and sends Alice the hash H = SHA256(R)
  2. Alice creates an HTLC with Charlie: "You get 0.001 BTC if you reveal a preimage of H within 40 blocks, else I get my money back"
  3. Charlie creates an HTLC with Dave: "You get 0.001 BTC if you reveal a preimage of H within 20 blocks"
  4. Dave reveals R to Charlie to claim payment; Charlie then reveals R to Alice to claim her HTLC
  5. Atomicity: either all hops complete (Dave reveals R in time) or all revert (timeouts expire)
Alice 0.5 BTC Bob 0.2 BTC Charlie 0.3 BTC Eve 0.1 BTC Frank 0.2 BTC Dave dest. Alice → Charlie → Dave (HTLC route, 0.001 BTC) unused channels shown in gray — routing is onion-encrypted
6-node Lightning network. The highlighted orange path shows Alice routing 0.001 BTC to Dave via Charlie using HTLCs. Neither Charlie nor intermediate nodes learn the payment origin or destination — onion routing (similar to Tor) hides the full path from each hop.

Onion routing for privacy

Lightning uses a Sphinx-based onion routing protocol. The sender wraps the route in layers of encryption — each hop only knows the previous and next node, not the full path. This prevents routing nodes from learning that Alice is paying Dave.

Real-world adoption

Use case / productNotable fact
El Zonte ("Bitcoin Beach"), El SalvadorCircular Bitcoin economy using Lightning for everyday purchases since 2019; predated legal tender adoption
Chivo Wallet (El Salvador)Government-issued Lightning wallet used by >3M Salvadorans; controversial due to custodial design
StrikeGlobal Lightning remittance app; partners with Shopify, Blackhawk Network for BTC-funded USD payments
Cash AppBlock's Cash App integrated Lightning in 2022; millions of users can receive Lightning payments
Podcasting 2.0 / Value4ValueStreaming Lightning micropayments per minute of podcast listened; Fountain, Breez enable this natively

Lightning limitations

▶ Lightning channel open/close pseudocode
# Opening a channel
def open_channel(alice_key, bob_key, alice_amount, bob_amount):
    funding_tx = create_transaction(
        inputs=[alice_utxos + bob_utxos],
        outputs=[
            # 2-of-2 multisig output
            P2WSH(MultiSig(2, [alice_key, bob_key]),
                  value=alice_amount + bob_amount)
        ]
    )
    # Both sign and broadcast
    alice_sig = sign(funding_tx, alice_key)
    bob_sig   = sign(funding_tx, bob_key)
    broadcast(funding_tx)  # on-chain; ~1 confirmation needed

    # Initial commitment transactions (never broadcast unless closing)
    alice_commitment = create_commitment_tx(
        input=funding_tx.output[0],
        outputs=[
            CSV_delayed_to(alice_key, value=alice_amount),  # Alice's balance
            P2PKH(bob_key, value=bob_amount),               # Bob's balance
        ]
    )
    return Channel(funding_tx, alice_commitment)

# Cooperative close
def close_channel_cooperative(channel, alice_key, bob_key):
    closing_tx = create_transaction(
        input=channel.funding_tx.output[0],
        outputs=[
            P2WPKH(alice_key, final_alice_balance),
            P2WPKH(bob_key,   final_bob_balance),
        ]
    )
    # Both sign — single Schnorr signature with Taproot (indistinguishable from simple payment)
    sig = schnorr_sign_aggregated([alice_key, bob_key], closing_tx)
    broadcast(closing_tx)  # on-chain settlement

7. Bitcoin as money

Store of value vs medium of exchange

Gresham's Law states: bad money drives out good money. When two currencies circulate, people spend the inflationary one and hoard the deflationary one. In practice, Bitcoin holders spend fiat and save BTC — making Bitcoin function as a store of value rather than a unit of account or medium of exchange at current adoption levels.

The maximalist argument: this is the correct evolution. Gold similarly was first adopted as a store of value before becoming a medium of exchange in coinage. Lightning Network is the medium-of-exchange layer when/if the broader population holds BTC.

Stock-to-Flow model (and its critics)

The S2F model (PlanB, 2019) models Bitcoin's price as a function of its stock-to-flow ratio — the existing supply divided by annual new supply. Gold's S2F ≈ 60; after the 2024 halving, Bitcoin's S2F ≈ 120. The model predicted exponential price growth post-halving and achieved viral adoption among retail investors.

CRITICISM

The S2F model has failed several predictions. Critics note: (1) supply schedule is perfectly known in advance — markets price it in before halvings; (2) the model has no demand side; (3) it implies infinite price at zero issuance; (4) statistical analysis (Coin Metrics) suggests the supposed S2F–price relationship disappears when autocorrelation is accounted for. Use S2F as a narrative framework, not a price prediction tool.

Bitcoin vs gold

PropertyBitcoinGold
Supply cap21M BTC — hard, enforced by code~210,000 tonnes above ground; ~3,500 tonnes/year mined; asteroid mining possible
Divisibility8 decimal places (100M satoshis per BTC)Divisible but requires assaying; impractical for small amounts
PortabilityAny amount, anywhere, in 10 minutes; 12 words in your head cross any borderHeavy; confiscated at borders; expensive to ship
VerifiabilityInstantly verifiable by any node with SHA-256Requires assay; gold-plated tungsten fraud exists
Custody riskPrivate key loss = permanent loss; no recoveryPhysical — can be stolen; requires secure storage
Track record15 years; regulatory risk remains5,000 years as monetary metal
Market cap (2025)~$1.8T~$17T

Institutional adoption

8. Network and nodes

Full node responsibilities

A Bitcoin full node downloads and validates every block and transaction since genesis. It independently enforces all consensus rules:

There are ~15,000–20,000 publicly reachable full nodes and likely 50,000–100,000 private nodes. They enforce consensus rules by refusing to relay or build on invalid blocks — even blocks produced by miners. This is the key insight behind the phrase "nodes > miners": miners can produce blocks, but nodes decide which rules count.

SPV clients

Simplified Payment Verification (SPV) clients (most mobile wallets) only download block headers (~80 bytes each; ~60 MB for the full chain). They verify payment inclusion via Merkle proofs from full nodes. SPV clients trust the longest chain of headers — they cannot independently verify every rule, but they can verify that their transaction is included in a block with valid proof-of-work.

Mempool and fee market dynamics

Unconfirmed transactions wait in each node's mempool (memory pool). Miners select transactions that maximize fee revenue per weight unit (satoshis/vByte). When block space is congested, fee rates spike. Users can accelerate stuck transactions using Replace-by-Fee (RBF) — rebroadcasting the transaction with a higher fee, signalled by setting sequence number < 0xFFFFFFFD. Child-Pays-for-Parent (CPFP) is an alternative: a recipient creates a child transaction with high fees to incentivize mining the stuck parent.

FULL NODES ARE THE CONSTITUTION

In 2017, Segwit2x proposed doubling the block size. Miners representing 85% of hash rate agreed. But nearly every full node operator refused to run the new software. The hard fork was cancelled. This demonstrated the unique governance property of Bitcoin: miners produce blocks, but full nodes enforce the rules. Economic majority using full nodes has veto power over all protocol changes.

P2P gossip protocol

Bitcoin uses a custom peer-to-peer protocol over TCP. Nodes connect to 8 outbound peers by default. New transactions and blocks are announced with inv (inventory) messages and fetched with getdata. Block propagation uses compact blocks (BIP 152) — nodes send only the short transaction IDs for transactions they assume the peer already has in its mempool, reducing block propagation from ~1MB to ~10KB and cutting propagation latency from ~3s to ~0.3s.