diff options
author | MacroFake <falke.marco@gmail.com> | 2022-06-23 12:24:51 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-06-27 11:08:29 +0200 |
commit | dddd7c4d390f54c5528986716c7c4089c4652ae9 (patch) | |
tree | b05cc446a84262989fe8a7bce5388c7d578de478 /test/functional/test_framework | |
parent | fa04ff61b6c209e48bce7d581466356e84617637 (diff) | |
download | bitcoin-dddd7c4d390f54c5528986716c7c4089c4652ae9.tar.xz |
test: Drop spent utxos in MiniWallet scan_tx
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r-- | test/functional/test_framework/wallet.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 435c985406..4c3fdbe2f5 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -116,7 +116,16 @@ class MiniWallet: self._utxos.append(self._create_utxo(txid=utxo["txid"], vout=utxo["vout"], value=utxo["amount"], height=utxo["height"])) def scan_tx(self, tx): - """Scan the tx for self._scriptPubKey outputs and add them to self._utxos""" + """Scan the tx and adjust the internal list of owned utxos""" + for spent in tx["vin"]: + # Mark spent. This may happen when the caller has ownership of a + # utxo that remained in this wallet. For example, by passing + # mark_as_spent=False to get_utxo or by using an utxo returned by a + # create_self_transfer* call. + try: + self.get_utxo(txid=spent["txid"], vout=spent["vout"]) + except StopIteration: + pass for out in tx['vout']: if out['scriptPubKey']['hex'] == self._scriptPubKey.hex(): self._utxos.append(self._create_utxo(txid=tx["txid"], vout=out["n"], value=out["value"], height=0)) |