tfix #4401 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 219c2a363ae59c33489e3e641653be5fdad02f15 DIR parent 3031f594cb05b538e218dab3edf9e17bce599dd7 HTML Author: SomberNight <somber.night@protonmail.com> Date: Sun, 3 Jun 2018 17:17:56 +0200 fix #4401 Diffstat: M lib/blockchain.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- DIR diff --git a/lib/blockchain.py b/lib/blockchain.py t@@ -30,6 +30,11 @@ from .bitcoin import * MAX_TARGET = 0x00000000FFFF0000000000000000000000000000000000000000000000000000 + +class MissingHeader(Exception): + pass + + def serialize_header(res): s = int_to_hex(res.get('version'), 4) \ + rev_hex(res.get('prev_block_hash')) \ t@@ -300,6 +305,8 @@ class Blockchain(util.PrintError): # new target first = self.read_header(index * 2016) last = self.read_header(index * 2016 + 2015) + if not first or not last: + raise MissingHeader() bits = last.get('bits') target = self.bits_to_target(bits) nActualTimespan = last.get('timestamp') - first.get('timestamp') t@@ -343,7 +350,10 @@ class Blockchain(util.PrintError): return False if prev_hash != header.get('prev_block_hash'): return False - target = self.get_target(height // 2016 - 1) + try: + target = self.get_target(height // 2016 - 1) + except MissingHeader: + return False try: self.verify_header(header, prev_hash, target) except BaseException as e: