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:
1 parent
77f00d1b4e
commit
8bcee27c23
13 files changed
+341
-6
No files matched your search
@@ -44,6 +44,12 @@ public sealed class FakeElectrumServer : IAsyncDisposable
|
||||
_listener = new TcpListener(IPAddress.Loopback, port);
|
||||
_listener.Start();
|
||||
Handle("server.version", _ => new[] { "FakeElectrumX 1.0", "1.4" });
|
||||
// Reports the mainnet genesis, as a real server does; override to simulate another chain.
|
||||
Handle("server.features", _ => new
|
||||
{
|
||||
genesis_hash = PalladiumWallet.Core.Chain.ChainProfiles.Mainnet.GenesisHash,
|
||||
hash_function = "sha256",
|
||||
});
|
||||
_acceptLoop = Task.Run(AcceptLoopAsync);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user