Bitcoin P2P message bytes
Terms used in this lesson
- P2P
- Peer-to-peer: nodes communicate directly with other nodes rather than through one central server.
- ASCII
- A standard mapping between common text characters and byte values.
- HASH256
- Bitcoin's name for applying SHA-256 twice to the same byte sequence.
Parse network magic, command, payload length, checksum, and payload from a byte stream before applying command-specific limits and validation.
Loading lesson visuals...
Learn the idea
A Bitcoin peer-to-peer message begins with a 24-byte header: four network-magic bytes, a 12-byte zero-padded ASCII command, a four-byte little-endian payload length, and four checksum bytes taken from HASH256 of the payload. The payload format and size limit depend on the command and negotiated protocol version.
Match network magic
Mainnet magic serializes f9 be b4 d9. Other networks use different values. A stream reader searches or synchronizes carefully without treating coincidental bytes inside a malicious payload as a trusted frame.
Inspect every idea above to open it.
It detects payload corruption or mismatch. The command payload remains untrusted and must pass its own parser, policy, and consensus checks.
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.