test: run mempool_spend_coinbase.py even with wallet disabled

This commit is contained in:
Michael Dietz
2020-11-13 16:55:20 -06:00
parent 79a3b59cc7
commit 21f2433601
2 changed files with 30 additions and 15 deletions

View File

@@ -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."""