commit d5c8a0e0d0597bc510b79b76c73c26689f3d692d
parent 0caf8e30cd70848baf9c83bfc52fb3063df91386
Author: chris-belcher <chris-belcher@users.noreply.github.com>
Date: Wed, 16 Jan 2019 17:48:10 +0000
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.
Diffstat:
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git 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
@@ -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)