Reviewed Aug 2026
DE
BA-01 · LESSON 07

CompactSize and Bitcoin byte fields

KEY DEFINITIONS

Terms used in this lesson

Outpoint
A transaction ID plus output number that identifies one exact prior output.

Parse variable-length counts, fixed-width integers, hashes, scripts, and length-prefixed vectors without confusing display order with serialized order.

55 min Difficulty 1/5 Not started

Loading lesson visuals...

01

Learn the idea

Bitcoin serialization combines fixed-width fields with CompactSize-prefixed vectors. CompactSize is a variable-length unsigned-integer encoding used for counts and lengths. It is not a general-purpose compressed number and it is not Bitcoin Script's signed-number encoding. A correct parser knows the field type before reading bytes.

GUIDED EXPLANATION1/5 ideas inspected
1

Read the field specification

Determine whether the next field is a fixed-width integer, 32-byte hash, CompactSize count, length-prefixed byte vector, Script number, or raw byte sequence. The surrounding structure supplies meaning.

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

Inspect every idea above to open it.

Important distinctionCompactSize means any Bitcoin number can be shortened by removing leading zero bytes.

CompactSize is a specific unsigned count and length encoding. Other fields keep their own fixed width or Script-number rules.

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.