34
34
satoshi_round ,
35
35
)
36
36
37
+ DEFAULT_FEE = Decimal ("0.0001" )
37
38
38
39
class MiniWalletMode (Enum ):
39
40
"""Determines the transaction type the MiniWallet is creating and spending.
@@ -181,13 +182,13 @@ def sendrawtransaction(self, *, from_node, tx_hex):
181
182
from_node .sendrawtransaction (tx_hex )
182
183
self .scan_tx (from_node .decoderawtransaction (tx_hex ))
183
184
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 ):
185
186
"""Build a transaction that spends parent_txid.vout[n] and produces one output with
186
187
amount = parent_value with a fee deducted.
187
188
Return tuple (CTransaction object, raw hex, nValue, scriptPubKey of the output created).
188
189
"""
189
190
inputs = [{"txid" : parent_txid , "vout" : n }]
190
- my_value = parent_value - Decimal ( "0.0001" )
191
+ my_value = parent_value - fee
191
192
outputs = {address : my_value }
192
193
rawtx = node .createrawtransaction (inputs , outputs )
193
194
prevtxs = [{
@@ -201,12 +202,12 @@ def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_l
201
202
tx = tx_from_hex (signedtx ["hex" ])
202
203
return (tx , signedtx ["hex" ], my_value , tx .vout [0 ].scriptPubKey .hex ())
203
204
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 ):
205
206
"""Creates a transaction that spends the first output of each parent in parents_tx."""
206
207
num_parents = len (parents_tx )
207
208
total_value = sum (values )
208
209
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 }
210
211
rawtx_child = node .createrawtransaction (inputs , outputs )
211
212
prevtxs = []
212
213
for i in range (num_parents ):
0 commit comments