From 4a82994032a48db0fc4be814091215c69891ab17 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 23 Oct 2013 13:52:11 +0400 Subject: [PATCH] catch exceptions in script_GetOP --- backends/bitcoind/blockchain_processor.py | 15 +++++++++++---- backends/bitcoind/deserialize.py | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) 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 -- 1.7.1