catch exceptions in script_GetOP
authorThomasV <thomasv@gitorious>
Wed, 23 Oct 2013 09:52:11 +0000 (13:52 +0400)
committerThomasV <thomasv@gitorious>
Wed, 23 Oct 2013 09:52:11 +0000 (13:52 +0400)
backends/bitcoind/blockchain_processor.py
backends/bitcoind/deserialize.py

index 4f8a69a..538478d 100644 (file)
@@ -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
index bacc1a7..7e010d6 100644 (file)
@@ -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