# Module BSV::Network::Checkpoints <a id="module-BSV-Network-Checkpoints"></a>

Per-network trust anchors for the `spv_headers` trust model (HLR #335).

A checkpoint is a single, hard-coded block at a known height whose full
80-byte header is baked into the gem. It is the root from which {HeaderSyncer}
extends a locally-validated, contiguous, PoW-checked header chain. The wallet
trusts this one header on faith — every header above it is validated against
it (and against its own predecessor) before being persisted, so the trust
surface is exactly this constant and nothing else.

## Why a recent checkpoint

The mainnet checkpoint sits a few hundred blocks below the live tip at release
time. That bounds the cost of a wallet's **first** sync: a fresh wallet need
only fetch and validate the handful of headers between the checkpoint and the
height it is asked about, not the entire chain from genesis. The checkpoint
header itself is assembled from its six wire fields and
<strong>self-verified</strong> at load: its recomputed `block_hash` must equal
the published block hash, or boot fails loud rather than seeding the chain
with a header that lies about its identity.

NOTE: refresh the mainnet checkpoint toward the chain tip each release.
Letting it drift far below the tip inflates every fresh wallet's first-sync
span (and pushes it toward the DoS cap in {HeaderSyncer::MAX_SYNC_SPAN}). The
block chosen here was a few hundred blocks below the tip when this was
authored.

## Constants
### `MAINNET_HEADER_FIELDS` <a id="constant-MAINNET_HEADER_FIELDS"></a> <a id="MAINNET_HEADER_FIELDS-constant"></a>
Not documented.

### `MAINNET_HEIGHT` <a id="constant-MAINNET_HEIGHT"></a> <a id="MAINNET_HEIGHT-constant"></a>
Mainnet trust anchor: block 955000.

Authored when the live tip was ~955617 (~600 blocks above), so a fresh
wallet's first sync is tiny. The fields below are the block's wire header
values; {BlockHeader.from_service_fields} reassembles the 80 bytes and
round-trips the `hash` as an integrity guard.

## Public Class Methods
### `for(network)` <a id="method-c-for"></a> <a id="for-class_method"></a>
Return the trust anchor for `network`.
- **@param** `network` [Symbol] +:mainnet+ (phase-1) — anything else raises.
- **@raise** [UnsupportedNetworkError] for a network with no baked-in checkpoint
- **@raise** [CorruptCheckpointError] if the baked-in header fails its self-verification
- **@return** [Hash{Symbol => Object}] +{ height: Integer, header: BlockHeader }+

### `mainnet_header()` <a id="method-c-mainnet_header"></a> <a id="mainnet_header-class_method"></a>
Assemble and self-verify the mainnet checkpoint header.

`from_service_fields` returns `nil` when the assembled header's hash does not
match the supplied <code>hash:</code> — that is the round-trip guard. A `nil`
here means the baked-in constant is internally inconsistent, which is a
build-time defect, so it is escalated to a raised {CorruptCheckpointError}
rather than a silent `nil`.
- **@raise** [CorruptCheckpointError]
- **@return** [BlockHeader]
