@@ -286,11 +286,12 @@ def create_self_transfer_multi(
286
286
utxos_to_spend : Optional [list [dict ]] = None ,
287
287
num_outputs = 1 ,
288
288
amount_per_output = 0 ,
289
+ version = 2 ,
289
290
locktime = 0 ,
290
291
sequence = 0 ,
291
292
fee_per_output = 1000 ,
292
293
target_weight = 0 ,
293
- confirmed_only = False
294
+ confirmed_only = False ,
294
295
):
295
296
"""
296
297
Create and return a transaction that spends the given UTXOs and creates a
@@ -313,6 +314,7 @@ def create_self_transfer_multi(
313
314
tx = CTransaction ()
314
315
tx .vin = [CTxIn (COutPoint (int (utxo_to_spend ['txid' ], 16 ), utxo_to_spend ['vout' ]), nSequence = seq ) for utxo_to_spend , seq in zip (utxos_to_spend , sequence )]
315
316
tx .vout = [CTxOut (amount_per_output , bytearray (self ._scriptPubKey )) for _ in range (num_outputs )]
317
+ tx .nVersion = version
316
318
tx .nLockTime = locktime
317
319
318
320
self .sign_tx (tx )
@@ -337,14 +339,15 @@ def create_self_transfer_multi(
337
339
"tx" : tx ,
338
340
}
339
341
340
- def create_self_transfer (self , * ,
342
+ def create_self_transfer (
343
+ self ,
344
+ * ,
341
345
fee_rate = Decimal ("0.003" ),
342
346
fee = Decimal ("0" ),
343
347
utxo_to_spend = None ,
344
- locktime = 0 ,
345
- sequence = 0 ,
346
348
target_weight = 0 ,
347
- confirmed_only = False
349
+ confirmed_only = False ,
350
+ ** kwargs ,
348
351
):
349
352
"""Create and return a tx with the specified fee. If fee is 0, use fee_rate, where the resulting fee may be exact or at most one satoshi higher than needed."""
350
353
utxo_to_spend = utxo_to_spend or self .get_utxo (confirmed_only = confirmed_only )
@@ -360,7 +363,12 @@ def create_self_transfer(self, *,
360
363
send_value = utxo_to_spend ["value" ] - (fee or (fee_rate * vsize / 1000 ))
361
364
362
365
# create tx
363
- tx = self .create_self_transfer_multi (utxos_to_spend = [utxo_to_spend ], locktime = locktime , sequence = sequence , amount_per_output = int (COIN * send_value ), target_weight = target_weight )
366
+ tx = self .create_self_transfer_multi (
367
+ utxos_to_spend = [utxo_to_spend ],
368
+ amount_per_output = int (COIN * send_value ),
369
+ target_weight = target_weight ,
370
+ ** kwargs ,
371
+ )
364
372
if not target_weight :
365
373
assert_equal (tx ["tx" ].get_vsize (), vsize )
366
374
tx ["new_utxo" ] = tx .pop ("new_utxos" )[0 ]
0 commit comments