Skip to content

Commit dddd7c4

Browse files
author
MacroFake
committed
test: Drop spent utxos in MiniWallet scan_tx
1 parent fa04ff6 commit dddd7c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/functional/test_framework/wallet.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,16 @@ def rescan_utxos(self):
116116
self._utxos.append(self._create_utxo(txid=utxo["txid"], vout=utxo["vout"], value=utxo["amount"], height=utxo["height"]))
117117

118118
def scan_tx(self, tx):
119-
"""Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
119+
"""Scan the tx and adjust the internal list of owned utxos"""
120+
for spent in tx["vin"]:
121+
# Mark spent. This may happen when the caller has ownership of a
122+
# utxo that remained in this wallet. For example, by passing
123+
# mark_as_spent=False to get_utxo or by using an utxo returned by a
124+
# create_self_transfer* call.
125+
try:
126+
self.get_utxo(txid=spent["txid"], vout=spent["vout"])
127+
except StopIteration:
128+
pass
120129
for out in tx['vout']:
121130
if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
122131
self._utxos.append(self._create_utxo(txid=tx["txid"], vout=out["n"], value=out["value"], height=0))

0 commit comments

Comments
 (0)