Fix reorgs with unspendable TXOs
This commit is contained in:
parent
10e0ff2e01
commit
67bb01bf2c
@ -669,15 +669,19 @@ class BlockProcessor(server.db.DB):
|
|||||||
s_pack = pack
|
s_pack = pack
|
||||||
put_utxo = self.utxo_cache.__setitem__
|
put_utxo = self.utxo_cache.__setitem__
|
||||||
spend_utxo = self.spend_utxo
|
spend_utxo = self.spend_utxo
|
||||||
|
script_hash168 = self.coin.hash168_from_script()
|
||||||
|
|
||||||
rtxs = reversed(txs)
|
rtxs = reversed(txs)
|
||||||
rtx_hashes = reversed(tx_hashes)
|
rtx_hashes = reversed(tx_hashes)
|
||||||
|
|
||||||
for tx_hash, tx in zip(rtx_hashes, rtxs):
|
for tx_hash, tx in zip(rtx_hashes, rtxs):
|
||||||
# Spend the outputs
|
|
||||||
for idx, txout in enumerate(tx.outputs):
|
for idx, txout in enumerate(tx.outputs):
|
||||||
cache_value = spend_utxo(tx_hash, idx)
|
# Spend the TX outputs. Be careful with unspendable
|
||||||
touched.add(cache_value[:21])
|
# outputs - we didn't save those in the first place.
|
||||||
|
hash168 = script_hash168(txout.pk_script)
|
||||||
|
if hash168:
|
||||||
|
cache_value = spend_utxo(tx_hash, idx)
|
||||||
|
touched.add(cache_value[:21])
|
||||||
|
|
||||||
# Restore the inputs
|
# Restore the inputs
|
||||||
if not tx.is_coinbase:
|
if not tx.is_coinbase:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user