Skip to content

Commit

Permalink
Fixed some addresses not getting any utxos due to invalid outpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
chiguireitor committed Jan 6, 2021
1 parent c9b4098 commit 74a457d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions counterpartylib/lib/backend/addrindexrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,8 @@ def run(self):
retry_count = 0
parsed = True
except Exception as e:
logging.warning("Got an exception parsing addrindexrs data")
logging.warning(e)
logging.warning(data.decode('utf-8'))
if retry_count <= 0:
raise e
self.message_result = None
retry_count -= 1
finally:
Expand Down Expand Up @@ -377,6 +376,9 @@ def unpack_outpoint(outpoint):
return (txid, int(vout))

def unpack_vout(outpoint, tx, block_count):
if tx is None:
return None

vout = tx["vout"][outpoint[1]]
height = -1
if "confirmations" in tx and tx["confirmations"] > 0:
Expand Down Expand Up @@ -407,7 +409,8 @@ def get_unspent_txouts(source):
# each item on the result array is like
# {"tx_hash": hex_encoded_hash}
batch = getrawtransaction_batch([x[0] for x in result], verbose=True, skip_missing=True)
batch = [unpack_vout(outpoint, batch[outpoint[0]], block_count) for outpoint in result]
batch = [unpack_vout(outpoint, batch[outpoint[0]], block_count) for outpoint in result if outpoint[0] in batch]
batch = [x for x in batch if x is not None]

return batch
else:
Expand Down

0 comments on commit 74a457d

Please sign in to comment.