diff --git a/pybtc/connector/block_loader.py b/pybtc/connector/block_loader.py index 630cb20..d9c7832 100644 --- a/pybtc/connector/block_loader.py +++ b/pybtc/connector/block_loader.py @@ -243,6 +243,15 @@ class Worker: if y["result"] is not None: block = decode_block_tx(y["result"]) for z in block["rawTx"]: + for i in block["rawTx"][z]["vOut"]: + o = b"".join((block["rawTx"][z]["txId"], int_to_bytes(i))) + pointer = (x << 42) + (z << 21) + i + try: + address = block["rawTx"][z]["vOut"][i]["scriptPubKey"] + except: + address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]), + block["rawTx"][z]["vOut"][i]["addressHash"])) + self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i]["value"], address) if not block["rawTx"][z]["coinbase"]: for i in block["rawTx"][z]["vIn"]: inp = block["rawTx"][z]["vIn"][i] @@ -254,15 +263,7 @@ class Worker: self.destroyed_coins[r[0]] = True except: pass - for i in block["rawTx"][z]["vOut"]: - o = b"".join((block["rawTx"][z]["txId"], int_to_bytes(i))) - pointer = (x << 42) + (z << 21) + i - try: - address = block["rawTx"][z]["vOut"][i]["scriptPubKey"] - except: - address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]), - block["rawTx"][z]["vOut"][i]["addressHash"])) - self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i]["value"], address) + blocks[x] = block if blocks: blocks[x]["checkpoint"] = x diff --git a/pybtc/connector/connector.py b/pybtc/connector/connector.py index 8283af0..804feae 100644 --- a/pybtc/connector/connector.py +++ b/pybtc/connector/connector.py @@ -621,22 +621,14 @@ class Connector: tx["vIn"][i]["coin"] = inp["_c_"] c += 1 self.yy += 1 + self.utxo.deleted.add(outpoint) except: - try: - tx["vIn"][i]["coin"] = inp["_c_"] + r = self.utxo.get(outpoint) + if r: + tx["vIn"][i]["coin"] = r c += 1 - self.aa += 1 - try: - self.utxo.get(outpoint) - except: - self.utxo.deleted.add(outpoint) - except: - r = self.utxo.get(outpoint) - if r: - tx["vIn"][i]["coin"] = r - c += 1 - else: - missed.add((outpoint, (block_height << 42) + (block_index << 21) + i, i)) + else: + missed.add((outpoint, (block_height << 42) + (block_index << 21) + i, i)) if missed: await self.utxo.load_utxo()