feat(spv): verify the chain identity of a server on connect

After the handshake the wallet checks server.features genesis_hash and,
when the profile has checkpoints, the header at the highest checkpoint
not above the server's tip (mainnet shares Bitcoin's genesis, so the
checkpoint is what tells the chains apart). A server on another chain is
refused with WrongChainException and the next candidate is tried. Used by
the GUI, peer discovery, the CLI and the server probe. See ADR 0036.
This commit is contained in:
davide committed 2026-11-03 14:01:34 +01:00
1 parent 77f00d1b4e
commit 8bcee27c23
13 files changed
+341 -6

No files matched your search

+5
View File
@@ -9,6 +9,11 @@ release and covers the full history from the initial commit.
### Fixed
- The wallet now verifies the chain identity of a server right after connecting: the
`genesis_hash` from `server.features` must match the profile and, on mainnet (which shares
Bitcoin's genesis), the header at the highest checkpoint not above the server's tip must match
the hardcoded one. A server on another chain is refused with an explicit message and the next
known server is tried. Applies to the GUI, peer discovery, the CLI and the server probe.
- `ElectrumClient`: a single server reply is now capped at 16 MiB (`maxLineBytes` in
`ConnectAsync`). A hostile server could stream an endless line with no newline and exhaust the
client's memory; the connection now fails with `InvalidDataException` as soon as the cap is