@@ -207,11 +207,12 @@ def send_self_transfer_multi(self, **kwargs):
207
207
return {'new_utxos' : [self .get_utxo (txid = txid , vout = vout ) for vout in range (len (tx .vout ))],
208
208
'txid' : txid , 'hex' : tx .serialize ().hex (), 'tx' : tx }
209
209
210
- def create_self_transfer_multi (self , * , from_node , utxos_to_spend , num_outputs = 1 , fee_per_output = 1000 ):
210
+ def create_self_transfer_multi (self , * , from_node , utxos_to_spend = None , num_outputs = 1 , fee_per_output = 1000 ):
211
211
"""
212
212
Create and return a transaction that spends the given UTXOs and creates a
213
213
certain number of outputs with equal amounts.
214
214
"""
215
+ utxos_to_spend = utxos_to_spend or [self .get_utxo ()]
215
216
# create simple tx template (1 input, 1 output)
216
217
tx = self .create_self_transfer (fee_rate = 0 , from_node = from_node , utxo_to_spend = utxos_to_spend [0 ], mempool_valid = False )['tx' ]
217
218
@@ -227,8 +228,8 @@ def create_self_transfer_multi(self, *, from_node, utxos_to_spend, num_outputs=1
227
228
# adapt output amounts (use fixed fee per output)
228
229
inputs_value_total = sum ([int (COIN * utxo ['value' ]) for utxo in utxos_to_spend ])
229
230
outputs_value_total = inputs_value_total - fee_per_output * num_outputs
230
- for i in range ( num_outputs ) :
231
- tx . vout [ i ] .nValue = outputs_value_total // num_outputs
231
+ for o in tx . vout :
232
+ o .nValue = outputs_value_total // num_outputs
232
233
return tx
233
234
234
235
def create_self_transfer (self , * , fee_rate = Decimal ("0.003" ), from_node = None , utxo_to_spend = None , mempool_valid = True , locktime = 0 , sequence = 0 ):
0 commit comments