aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-09-09 10:37:39 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-09-09 10:39:05 +0200
commitfaba790bd40b5a9e8849997785020790ff60571b (patch)
tree7905254a1196467e41a10d91e894a5551acd09c8 /test/functional/test_framework
parentfa65a11d0c9a34ff7f4cc4efd53367794e751749 (diff)
downloadbitcoin-faba790bd40b5a9e8849997785020790ff60571b.tar.xz
test: MiniWallet: Default fee_rate in send_self_transfer, Pass in utxo_to_spend
Adds two new features to MiniWallet: * The fee rate is irrelevant sometimes, so just set an arbitrary default * The utxo to spend needs to be selected manually sometimes
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/wallet.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 56ff69dc14..ae6aa6bdca 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -40,17 +40,17 @@ class MiniWallet:
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
return blocks
- def send_self_transfer(self, *, fee_rate, from_node):
+ 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."""
self._utxos = sorted(self._utxos, key=lambda k: k['value'])
- largest_utxo = self._utxos.pop() # Pick the largest utxo and hope it covers the fee
+ utxo_to_spend = utxo_to_spend or self._utxos.pop() # Pick the largest utxo (if none provided) and hope it covers the fee
vsize = Decimal(96)
- send_value = satoshi_round(largest_utxo['value'] - fee_rate * (vsize / 1000))
- fee = largest_utxo['value'] - send_value
+ send_value = satoshi_round(utxo_to_spend['value'] - fee_rate * (vsize / 1000))
+ fee = utxo_to_spend['value'] - send_value
assert send_value > 0
tx = CTransaction()
- tx.vin = [CTxIn(COutPoint(int(largest_utxo['txid'], 16), largest_utxo['vout']))]
+ tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']))]
tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
tx.wit.vtxinwit = [CTxInWitness()]
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]