From d5c8a0e0d0597bc510b79b76c73c26689f3d692d Mon Sep 17 00:00:00 2001 From: chris-belcher Date: Wed, 16 Jan 2019 17:48:10 +0000 Subject: [PATCH] Add flag --skipmerklecheck (#4957) The --skipmerklecheck optional flag makes Electrum tolerate invalid merkle proofs from the server. This is useful for building Electrum servers that need a minimum amount of storage, though of course users should only enable it if they completely trust the connected server. --- electrum/commands.py | 1 + electrum/verifier.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index 1ac6b306f..a5bae9cf8 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -909,6 +909,7 @@ def add_network_options(parser): parser.add_argument("-s", "--server", dest="server", default=None, help="set server host:port:protocol, where protocol is either t (tcp) or s (ssl)") parser.add_argument("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http") parser.add_argument("--noonion", action="store_true", dest="noonion", default=None, help="do not try to connect to onion servers") + parser.add_argument("--skipmerklecheck", action="store_true", dest="skipmerklecheck", default=False, help="Tolerate invalid merkle proofs from server") def add_global_options(parser): group = parser.add_argument_group('global options') diff --git a/electrum/verifier.py b/electrum/verifier.py index 247d124db..a4c220cc3 100644 --- a/electrum/verifier.py +++ b/electrum/verifier.py @@ -116,8 +116,11 @@ class SPV(NetworkJobOnDefaultServer): try: verify_tx_is_in_block(tx_hash, merkle_branch, pos, header, tx_height) except MerkleVerificationFailure as e: - self.print_error(str(e)) - raise GracefulDisconnect(e) + if self.network.config.get("skipmerklecheck"): + self.print_error("skipping merkle proof check %s" % tx_hash) + else: + self.print_error(str(e)) + raise GracefulDisconnect(e) # we passed all the tests self.merkle_roots[tx_hash] = header.get('merkle_root') try: self.requested_merkle.remove(tx_hash)