Reviewed Aug 2026
DE
BA-08 · LESSON 09

Raw block anatomy and blk.dat

KEY DEFINITIONS

Terms used in this lesson

Coinbase transaction
The special first transaction in a Bitcoin block, which claims permitted subsidy and fees and has no ordinary prior-output input.
Witness
Signatures, scripts, or other data supplied to satisfy a Bitcoin output’s spending condition.
HASH256
Bitcoin's name for applying SHA-256 twice to the same byte sequence.
Outpoint
A transaction ID plus output number that identifies one exact prior output.
Block subsidy
New bitcoin that consensus permits a block's coinbase transaction to create at a particular height.
Transaction ID
The identifier produced by hashing a Bitcoin transaction’s non-witness serialization.
SegWit
Segregated Witness: a Bitcoin upgrade that separates authorization data from the transaction identifier and introduces versioned witness programs.
Witness transaction ID
An identifier that commits to a transaction including its witness data.
BIP34
The consensus rule requiring a block's coinbase transaction to begin its ScriptSig with the block height.

Decode disk framing, the 80-byte header, CompactSize transaction count, coinbase, ordinary transactions, witness commitment, and neighbouring block links.

35 min Difficulty 2/5 Not started

Loading lesson visuals...

01

Learn the idea

A raw block on the Bitcoin peer-to-peer network begins with an 80-byte header followed by a CompactSize transaction count and complete transactions. Bitcoin Core block files add an eight-byte disk frame before each block: four network-magic bytes and a four-byte little-endian block size. Disk framing is storage metadata and is not part of the block hash.

GUIDED EXPLANATION1/5 ideas inspected
1

Parse blk.dat framing

Read the network-specific four-byte magic and four-byte payload length, reject the wrong network or oversized length, then consume exactly that many block bytes before seeking the next frame.

Inspect each idea before the worked example.
The worked example follows the explanation

Inspect every idea above to open it.

Important distinctionBlock height is stored in every block header.

Height is derived from the linked chain. Modern coinbase ScriptSig commits the height under BIP34, but the 80-byte header has no height field.

02
FINISH LEARNING FIRST

The questions unlock after every required learning activity

Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.