From: ThomasV Date: Wed, 23 Oct 2013 09:52:11 +0000 (+0400) Subject: catch exceptions in script_GetOP X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=4a82994032a48db0fc4be814091215c69891ab17;hp=b7107abf2d6b26dc5f4155158e5def951695b158 catch exceptions in script_GetOP --- diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 4f8a69a..538478d 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -256,8 +256,11 @@ class BlockchainProcessor(Processor): vds = deserialize.BCDataStream() vds.write(raw_tx.decode('hex')) - - return deserialize.parse_Transaction(vds, is_coinbase=False) + try: + return deserialize.parse_Transaction(vds, is_coinbase=False) + except: + print_log("ERROR: cannot parse", txid) + return None def get_history(self, addr, cache_only=False): with self.cache_lock: @@ -457,10 +460,14 @@ class BlockchainProcessor(Processor): is_coinbase = True for raw_tx in txlist: tx_hash = hash_encode(Hash(raw_tx.decode('hex'))) - tx_hashes.append(tx_hash) vds = deserialize.BCDataStream() vds.write(raw_tx.decode('hex')) - tx = deserialize.parse_Transaction(vds, is_coinbase) + try: + tx = deserialize.parse_Transaction(vds, is_coinbase) + except: + print_log("ERROR: cannot parse", tx_hash) + continue + tx_hashes.append(tx_hash) txdict[tx_hash] = tx is_coinbase = False return tx_hashes, txdict diff --git a/backends/bitcoind/deserialize.py b/backends/bitcoind/deserialize.py index bacc1a7..7e010d6 100644 --- a/backends/bitcoind/deserialize.py +++ b/backends/bitcoind/deserialize.py @@ -388,7 +388,10 @@ def get_address_from_input_script(bytes): def get_address_from_output_script(bytes): - decoded = [ x for x in script_GetOp(bytes) ] + try: + decoded = [ x for x in script_GetOp(bytes) ] + except: + return "None" # The Genesis Block, self-payments, and pay-by-IP-address payments look like: # 65 BYTES:... CHECKSIG