From 81666bf9ac8b42d0ac25415ee3815d899c8adda6 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 5 Mar 2018 11:44:03 +0100 Subject: [PATCH] fix #4026 --- lib/synchronizer.py | 6 ++++++ lib/verifier.py | 5 ++++- lib/wallet.py | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/synchronizer.py b/lib/synchronizer.py index 70e13e529..4b81810db 100644 --- a/lib/synchronizer.py +++ b/lib/synchronizer.py @@ -84,6 +84,8 @@ class Synchronizer(ThreadJob): return bh2u(hashlib.sha256(status.encode('ascii')).digest()) def on_address_status(self, response): + if self.wallet.synchronizer is None: + return # we have been killed, this was just an orphan callback params, result = self.parse_response(response) if not params: return @@ -98,6 +100,8 @@ class Synchronizer(ThreadJob): self.requested_addrs.remove(addr) def on_address_history(self, response): + if self.wallet.synchronizer is None: + return # we have been killed, this was just an orphan callback params, result = self.parse_response(response) if not params: return @@ -127,6 +131,8 @@ class Synchronizer(ThreadJob): self.requested_histories.pop(addr) def tx_response(self, response): + if self.wallet.synchronizer is None: + return # we have been killed, this was just an orphan callback params, result = self.parse_response(response) if not params: return diff --git a/lib/verifier.py b/lib/verifier.py index c2d0f1250..236ffbfe6 100644 --- a/lib/verifier.py +++ b/lib/verifier.py @@ -65,6 +65,8 @@ class SPV(ThreadJob): self.undo_verifications() def verify_merkle(self, r): + if self.wallet.verifier is None: + return # we have been killed, this was just an orphan callback if r.get('error'): self.print_error('received an error:', r) return @@ -95,7 +97,8 @@ class SPV(ThreadJob): self.print_error("verified %s" % tx_hash) self.wallet.add_verified_tx(tx_hash, (tx_height, header.get('timestamp'), pos)) - def hash_merkle_root(self, merkle_s, target_hash, pos): + @classmethod + def hash_merkle_root(cls, merkle_s, target_hash, pos): h = hash_decode(target_hash) for i in range(len(merkle_s)): item = merkle_s[i] diff --git a/lib/wallet.py b/lib/wallet.py index 291d63db3..28597b851 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -912,7 +912,8 @@ class Abstract_Wallet(PrintError): # make tx local self.unverified_tx.pop(tx_hash, None) self.verified_tx.pop(tx_hash, None) - self.verifier.merkle_roots.pop(tx_hash, None) + if self.verifier: + self.verifier.merkle_roots.pop(tx_hash, None) # but remove completely if not is_mine if self.txi[tx_hash] == {}: # FIXME the test here should be for "not all is_mine"; cannot detect conflict in some cases