Skip to content

Commit 2b6b26e

Browse files
committed
[test] parameterizable fee for make_chain and create_child_with_parents
1 parent 313c09f commit 2b6b26e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/functional/test_framework/wallet.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
satoshi_round,
3535
)
3636

37+
DEFAULT_FEE = Decimal("0.0001")
3738

3839
class MiniWalletMode(Enum):
3940
"""Determines the transaction type the MiniWallet is creating and spending.
@@ -181,13 +182,13 @@ def sendrawtransaction(self, *, from_node, tx_hex):
181182
from_node.sendrawtransaction(tx_hex)
182183
self.scan_tx(from_node.decoderawtransaction(tx_hex))
183184

184-
def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None):
185+
def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None, fee=DEFAULT_FEE):
185186
"""Build a transaction that spends parent_txid.vout[n] and produces one output with
186187
amount = parent_value with a fee deducted.
187188
Return tuple (CTransaction object, raw hex, nValue, scriptPubKey of the output created).
188189
"""
189190
inputs = [{"txid": parent_txid, "vout": n}]
190-
my_value = parent_value - Decimal("0.0001")
191+
my_value = parent_value - fee
191192
outputs = {address : my_value}
192193
rawtx = node.createrawtransaction(inputs, outputs)
193194
prevtxs = [{
@@ -201,12 +202,12 @@ def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_l
201202
tx = tx_from_hex(signedtx["hex"])
202203
return (tx, signedtx["hex"], my_value, tx.vout[0].scriptPubKey.hex())
203204

204-
def create_child_with_parents(node, address, privkeys, parents_tx, values, locking_scripts):
205+
def create_child_with_parents(node, address, privkeys, parents_tx, values, locking_scripts, fee=DEFAULT_FEE):
205206
"""Creates a transaction that spends the first output of each parent in parents_tx."""
206207
num_parents = len(parents_tx)
207208
total_value = sum(values)
208209
inputs = [{"txid": tx.rehash(), "vout": 0} for tx in parents_tx]
209-
outputs = {address : total_value - num_parents * Decimal("0.0001")}
210+
outputs = {address : total_value - fee}
210211
rawtx_child = node.createrawtransaction(inputs, outputs)
211212
prevtxs = []
212213
for i in range(num_parents):

0 commit comments

Comments
 (0)