From e205657eefcd8c140c22da2acea72c9ccc4fa391 Mon Sep 17 00:00:00 2001 From: 4tochka Date: Wed, 8 May 2019 00:05:56 +0400 Subject: [PATCH] connector --- pybtc/connector/connector.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pybtc/connector/connector.py b/pybtc/connector/connector.py index 8cf53cb..48a0f79 100644 --- a/pybtc/connector/connector.py +++ b/pybtc/connector/connector.py @@ -594,8 +594,20 @@ class Connector: if self.tx_handler and not self.cache_loading: await self.tx_handler(tx, stxo, block_time, block_height, block_index) - # if self.utxo: - # self.put_utxo(tx, block_height, block_index) + if self.utxo: + # self.put_utxo(tx, block_height, block_index) + + for i in tx["vOut"]: + out = tx["vOut"][i] + if out["nType"] in (3, 8): + continue + pointer = (block_height << 42) + (block_index << 21) + i + try: + address = out["scriptPubKey"] + except: + address = b"".join((bytes([out["nType"]]), out["addressHash"])) + outpoint = b"".join((tx["txId"], int_to_bytes(i))) + self.utxo.set(outpoint, pointer, out["value"], address) self.tx_cache.set(tx["txId"], True) try: