🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Bitcoin Architecture

Bitcoin Deep DiveđŸŸĸ Free Lesson

Bitcoin Architecture

Bitcoin block structure, UTXO model, Bitcoin Script, transaction format, SegWit, Taproot, and BIPs.

Overview

Bitcoin's architecture is the foundation of all cryptocurrencies. Understanding its internals is essential for blockchain development.

Bitcoin Block Structure

Bitcoin Block StructureBlock Header (80 bytes)Version (4 bytes)Prev Block Hash (32B)Merkle Root (32B)Timestamp (4B)Bits (4 bytes)Nonce (4 bytes)Transaction Counter (1-9 bytes)Transaction Data (variable)Coinbase Transaction + Up to ~4,000 Regular TransactionsEach TX: Version → Input Count → Inputs → Output Count → Outputs → LocktimeMax Block Size: 4 MB (SegWit) | ~2 MB (effective)

UTXO Model

The Unspent Transaction Output (UTXO) model is Bitcoin's way of tracking ownership.

UTXO Model FlowUTXO SetUnspent OutputsTransaction InputReferences UTXOScript ValidationSig + PubKeyNew UTXOs CreatedChange + PaymentUTXO ExampleAlice has: UTXO-A (2.5 BTC), UTXO-B (1.0 BTC)Alice sends: 2.0 BTC to Bob→ Input: UTXO-A (2.5 BTC) | Output 1: 2.0 BTC to Bob | Output 2: 0.49 BTC change to Alice→ Fee = 2.5 - 2.0 - 0.49 = 0.01 BTC

UTXO Properties

PropertyDescriptionBenefit
IndependenceEach UTXO is discreteParallel processing
FungibilityUnits are interchangeablePrivacy
DivisibilityCan be splitFlexible payments
VerifiabilityCryptographic proofTrustless validation

Transaction Format

{
  "version": 2,
  "vin": [
    {
      "txid": "prev_tx_hash",
      "vout": 0,
      "scriptSig": "signature pub_key",
      "sequence": 0xffffffff
    }
  ],
  "vout": [
    {
      "value": 0.01,
      "n": 0,
      "scriptPubKey": "OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG"
    }
  ],
  "locktime": 0
}

Bitcoin Script

Bitcoin Script is a stack-based, non-Turing-complete language.

Script Execution Stack

P2PKH Script ExecutionLocking Script (scriptPubKey)OP_DUPOP_HASH160<pubKeyHash>OP_EQUALVERIFYOP_CHECKSIGUnlocking Script (scriptSig)<signature><public_key>Combined: <sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Common Script Types

Script TypePatternUse Case
P2PKHOP_DUP OP_HASH160 {hash} OP_EQUALVERIFY OP_CHECKSIGLegacy addresses (1...)
P2SHOP_HASH160 {hash} OP_EQUALMultisig, complex scripts
P2WPKHOP_0 {20-byte-hash}Native SegWit (bc1q...)
P2TROP_1 {32-byte-key}Taproot (bc1p...)
P2MSm {pubkeys} n OP_CHECKMULTISIGBare multisig (deprecated)

SegWit (Segregated Witness)

SegWit separated signature data from transaction data, enabling:

  • Block weight reduction: Signatures moved to witness data
  • Lightning Network: Enabled through SegWit addresses
  • Malleability fix: Transaction IDs no longer change with signature changes

SegWit Transaction Structure

FieldLegacySegWitChange
Version4 bytes4 bytesSame
Marker-0x00New
Flag-0x01New
InputVarIntVarIntSame
OutputVarIntVarIntSame
Witness-Witness dataMoved
Locktime4 bytes4 bytesSame

Weight vs Size

Architecture Diagram
Weight = Base Size × 3 + Total Size
Virtual Bytes (vB) = Weight / 4

Base size: 1 byte per input/output overhead Total size: includes witness data

Taproot (BIP-340/341/342)

Taproot introduced Schnorr signatures and Merkle Abstract Syntax Trees (MAST).

Taproot Key Path vs Script Path

Taproot Spending PathsTaproot OutputKey Path SpendSingle Schnorr signatureScript Path SpendReveals script + Merkle proof

Schnorr vs ECDSA

FeatureECDSA (secp256k1)Schnorr (BIP-340)
Signature Size~71-72 bytes64 bytes
Batch VerificationNoYes (up to 10x faster)
Multi-signatureIndividual sigsKey aggregation (MuSig)
MalleabilityPotentialNon-malleable
PrivacyMultisig visibleIndistinguishable

Key Size Calculations

Transaction Size

For P2WPKH:

Fee Estimation

Example:

  • 1 P2WPKH input + 2 outputs = ~141 vB
  • At 10 sat/vB: Fee = 141 × 10 = 1,410 satoshis

Bitcoin Improvement Proposals (BIPs)

BIPNameYearImpact
BIP-32HD Wallets2012Deterministic key generation
BIP-39Mnemonic Seeds2013Human-readable seed phrases
BIP-44Multi-account2014Hierarchical wallet structure
BIP-141SegWit2015Block weight, witness data
BIP-148UASF2017User-activated soft fork
BIP-340Schnorr2020New signature scheme
BIP-341Taproot2020MAST, key/spend paths
BIP-342Tapscript2020Script upgrades for Taproot

Real-World Examples

Bitcoin Transaction Fees Over Time

PeriodAvg Fee (USD)Avg Fee (sat/vB)Block Size
2017 Peak$55400+~1 MB
2019 Low$0.5010-20~1 MB
2021 Peak$60200+~2 MB
2023 Average$2-515-30~1.5 MB
Ordinals 2023$10-5050-200~3-4 MB

Lightning Network Statistics (2024)

MetricValue
Channel Capacity~5,400 BTC
Nodes~16,000
Channels~75,000
Avg Tx Fee0.01-0.1%

Trade-offs

Legacy vs SegWit vs Taproot

AspectLegacySegWitTaproot
CompatibilityAll walletsMost walletsNewer wallets
Fee SavingsBaseline25-40%40-60%
PrivacyBasicBasicEnhanced
Smart ContractsLimitedP2SHComplex scripts
Adoption100%~70%~30%

UTXO vs Account Model

FeatureUTXO (Bitcoin)Account (Ethereum)
State TrackingSet of unspent outputsAccount balances
PrivacyBetter (unlinkable)Worse (pseudonymous)
ParallelismHighLow
Smart ContractsLimitedFull Turing-complete
AtomicityBuilt-inRequires careful coding

Interview Questions

  1. How does the UTXO model ensure transaction atomicity?

    • Answer: All inputs must be consumed; if valid, outputs are created atomically. Either the entire transaction succeeds or fails completely.
  2. What problem does Taproot solve that SegWit didn't?

    • Answer: Taproot adds privacy for complex scripts by allowing them to look like simple payments, and enables key aggregation for multisig via Schnorr signatures.
  3. Why is Bitcoin Script non-Turing-complete, and is this a limitation?

    • Answer: It lacks loops and has limited opcodes to prevent halting problems and reduce attack surface. This is intentional for security, not a limitation for Bitcoin's use case.

Quiz Questions

  1. What is the maximum block weight in SegWit?

    • A) 1 MB
    • B) 2 MB
    • C) 4 MB ✓
    • D) 8 MB
  2. Which BIP introduced HD wallet key derivation?

    • A) BIP-39
    • B) BIP-32 ✓
    • C) BIP-44
    • D) BIP-141
  3. In a P2PKH transaction, what does OP_CHECKSIG verify?

    • A) Transaction amount
    • B) Block hash
    • C) Signature against public key ✓
    • D) UTXO existence

Practice

  1. Build a raw Bitcoin transaction manually (testnet)
  2. Implement a UTXO set tracker in Python
  3. Write a Bitcoin Script parser for common patterns
  4. Compare transaction sizes between P2PKH, P2SH, P2WPKH, and P2TR
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-09-22

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Related Tutorials

Content with similar topics across other courses

Need Expert Blockchain Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement