From c49e563881f3b7101d98ca768f58b0b7fee9bea2 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Sat, 8 Sep 2018 18:10:21 +0200 Subject: [PATCH] verifier: if we fail to verify SPV proof, disconnect from server --- electrum/verifier.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/electrum/verifier.py b/electrum/verifier.py index f1bc1aad6..1013648b5 100644 --- a/electrum/verifier.py +++ b/electrum/verifier.py @@ -24,12 +24,11 @@ import asyncio from typing import Sequence, Optional -from aiorpcx import TaskGroup - -from .util import ThreadJob, bh2u, VerifiedTxInfo, aiosafe +from .util import ThreadJob, bh2u, VerifiedTxInfo from .bitcoin import Hash, hash_decode, hash_encode from .transaction import Transaction from .blockchain import hash_header +from .interface import GracefulDisconnect class MerkleVerificationFailure(Exception): pass @@ -94,14 +93,10 @@ class SPV(ThreadJob): verify_tx_is_in_block(tx_hash, merkle_branch, pos, header, tx_height) except MerkleVerificationFailure as e: self.print_error(str(e)) - # FIXME: we should make a fresh connection to a server - # to recover from this, as this TX will now never verify - return + raise GracefulDisconnect(e) # we passed all the tests self.merkle_roots[tx_hash] = header.get('merkle_root') try: - # note: we could pop in the beginning, but then we would request - # this proof again in case of verification failure from the same server self.requested_merkle.remove(tx_hash) except KeyError: pass self.print_error("verified %s" % tx_hash)