Header-chain sync (SPEC-VERIFICATION §4 "header sync"): a locally validated,
disk-persistable header chain that anchors proof bundles WITHOUT trusting any
server's hash-at-height answers. Validation per appended header:
80-byte parse, prev-hash linkage, embedded PoW;
difficulty retarget: at period boundaries bits must equal
calcNextBits(...) (exact pow.cpp arithmetic); within a period it must
equal the previous header's bits (mainnet has no min-difficulty rule);
median-time-past: timestamp strictly greater than the median of the
previous 11 (skipped for the first 11 headers after a snapshot base,
which are anchored by the base hash instead);
timestamps bounded against the local clock (+2h consensus drift);
compiled checkpoint crossings (height → hash) must match.
Trust model note: the Electrum transport verifies server certificates by
default (see ElectrumTcpOptions for CA/pinning/insecure), but TLS is NOT
the trust anchor: every header is validated locally and reorgs are only
adopted on strictly greater cumulative work. TLS just denies a trivial
on-path attacker free tampering with an otherwise-authenticated stream.
The chain starts from a retarget-ALIGNED trusted base (height % 2016 == 0),
so the first boundary after the base is fully checkable. The default base
covers every inscription ever (period start below inscription 0's block).
NODE-ONLY (v1): ElectrumTcpTransport needs raw TCP/TLS sockets and
persistence needs a filesystem; neither exists in browsers. This module is
therefore a separate subpath export (@ordspv/fetch/headersync) kept
OUT of the browser bundle. Browser story: keep using checkpoint + M-of-N
anchoring (makeHeaderTrust), or run headerSyncTrust behind your own
WebSocket→Electrum bridge by implementing ElectrumTransport over it. The
validation core (HeaderChain) is IO-free and would run in a browser given
headers; only the built-in transport and file persistence are node-bound.
Header-chain sync (SPEC-VERIFICATION §4 "header sync"): a locally validated, disk-persistable header chain that anchors proof bundles WITHOUT trusting any server's hash-at-height answers. Validation per appended header:
bitsmust equal calcNextBits(...) (exact pow.cpp arithmetic); within a period it must equal the previous header's bits (mainnet has no min-difficulty rule);Trust model note: the Electrum transport verifies server certificates by default (see ElectrumTcpOptions for CA/pinning/insecure), but TLS is NOT the trust anchor: every header is validated locally and reorgs are only adopted on strictly greater cumulative work. TLS just denies a trivial on-path attacker free tampering with an otherwise-authenticated stream.
The chain starts from a retarget-ALIGNED trusted base (height % 2016 == 0), so the first boundary after the base is fully checkable. The default base covers every inscription ever (period start below inscription 0's block).
NODE-ONLY (v1): ElectrumTcpTransport needs raw TCP/TLS sockets and persistence needs a filesystem; neither exists in browsers. This module is therefore a separate subpath export (
@ordspv/fetch/headersync) kept OUT of the browser bundle. Browser story: keep using checkpoint + M-of-N anchoring (makeHeaderTrust), or run headerSyncTrust behind your own WebSocket→Electrum bridge by implementing ElectrumTransport over it. The validation core (HeaderChain) is IO-free and would run in a browser given headers; only the built-in transport and file persistence are node-bound.