aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/wallet.py
diff options
context:
space:
mode:
authorMichael Dietz <michaeldietz@Michaels-MacBook-Air.local>2020-11-13 16:55:20 -0600
committerMichael Dietz <michaeldietz@Michaels-MacBook-Air.local>2020-11-16 09:05:34 -0600
commit21f24336019d438e225c7bd6653871119883a4ee (patch)
treec8a9b53143f59a5493a73847000b8ea98b7ef011 /test/functional/test_framework/wallet.py
parent79a3b59cc70622fbadc43ade5fce31fcf94d852d (diff)
downloadbitcoin-21f24336019d438e225c7bd6653871119883a4ee.tar.xz
test: run mempool_spend_coinbase.py even with wallet disabled
Diffstat (limited to 'test/functional/test_framework/wallet.py')
-rw-r--r--test/functional/test_framework/wallet.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 39b3bf2a5b..a71f2c69cb 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -40,9 +40,20 @@ class MiniWallet:
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
return blocks
- def get_utxo(self):
- """Return the last utxo. Can be used to get the change output immediately after a send_self_transfer"""
- return self._utxos.pop()
+ def get_utxo(self, *, txid=''):
+ """
+ Returns a utxo and marks it as spent (pops it from the internal list)
+
+ Args:
+ txid (string), optional: get the first utxo we find from a specific transaction
+
+ Note: Can be used to get the change output immediately after a send_self_transfer
+ """
+ index = -1 # by default the last utxo
+ if txid:
+ utxo = next(filter(lambda utxo: txid == utxo['txid'], self._utxos))
+ index = self._utxos.index(utxo)
+ return self._utxos.pop(index)
def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None):
"""Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""