electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 02c7524d759b5d65b92b69dc0af78756aaf091cb
parent 0928ac961a33faab0a831f3d79fe9a52fe338a25
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 22 Feb 2018 16:44:22 +0100

logging: some extra network-related lines

Diffstat:
Mlib/blockchain.py | 3+++
Mlib/network.py | 5++++-
Mlib/verifier.py | 16++++++++++++----
3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lib/blockchain.py b/lib/blockchain.py @@ -226,6 +226,9 @@ class Blockchain(util.PrintError): if truncate and offset != self._size*80: f.seek(offset) f.truncate() + self.print_error( + 'write. truncating to offset {}, which is around chunk {}' + .format(offset, offset//80//2016)) f.seek(offset) f.write(data) f.flush() diff --git a/lib/network.py b/lib/network.py @@ -549,7 +549,7 @@ class Network(util.DaemonThread): self.donation_address = result elif method == 'mempool.get_fee_histogram': if error is None: - self.print_error(result) + self.print_error('fee_histogram', result) self.config.mempool_fees = result self.notify('fee_histogram') elif method == 'blockchain.estimatefee': @@ -784,7 +784,10 @@ class Network(util.DaemonThread): index = params[0] # Ignore unsolicited chunks if index not in self.requested_chunks: + interface.print_error("received chunk %d (unsolicited)" % index) return + else: + interface.print_error("received chunk %d" % index) self.requested_chunks.remove(index) connect = blockchain.connect_chunk(index, result) if not connect: diff --git a/lib/verifier.py b/lib/verifier.py @@ -74,10 +74,18 @@ class SPV(ThreadJob): pos = merkle.get('pos') merkle_root = self.hash_merkle_root(merkle['merkle'], tx_hash, pos) header = self.network.blockchain().read_header(tx_height) - if not header or header.get('merkle_root') != merkle_root: - # FIXME: we should make a fresh connection to a server to - # recover from this, as this TX will now never verify - self.print_error("merkle verification failed for", tx_hash) + # FIXME: if verification fails below, + # we should make a fresh connection to a server to + # recover from this, as this TX will now never verify + if not header: + self.print_error( + "merkle verification failed for {} (missing header {})" + .format(tx_hash, tx_height)) + return + if header.get('merkle_root') != merkle_root: + self.print_error( + "merkle verification failed for {} (merkle root mismatch {} != {})" + .format(tx_hash, header.get('merkle_root'), merkle_root)) return # we passed all the tests self.merkle_roots[tx_hash] = merkle_root