@@ -225,14 +225,17 @@ def _change_outputs(self, tx: PartialTransaction, change_addrs, fee_estimator_nu
225
225
c .is_change = True
226
226
return change
227
227
228
- def _construct_tx_from_selected_buckets (self , * , buckets : Sequence [Bucket ],
229
- base_tx : PartialTransaction , change_addrs ,
230
- fee_estimator_w , dust_threshold ,
231
- base_weight ) -> Tuple [PartialTransaction , List [PartialTxOutput ]]:
228
+ def _construct_tx_from_selected_buckets (
229
+ self , * , buckets : Sequence [Bucket ],
230
+ base_tx : PartialTransaction , change_addrs ,
231
+ fee_estimator_w , dust_threshold ,
232
+ base_weight ,
233
+ BIP69_sort : bool ,
234
+ ) -> Tuple [PartialTransaction , List [PartialTxOutput ]]:
232
235
# make a copy of base_tx so it won't get mutated
233
- tx = PartialTransaction .from_io (base_tx .inputs ()[:], base_tx .outputs ()[:])
236
+ tx = PartialTransaction .from_io (base_tx .inputs ()[:], base_tx .outputs ()[:], BIP69_sort = BIP69_sort )
234
237
235
- tx .add_inputs ([coin for b in buckets for coin in b .coins ])
238
+ tx .add_inputs ([coin for b in buckets for coin in b .coins ], BIP69_sort = BIP69_sort )
236
239
tx_weight = self ._get_tx_weight (buckets , base_weight = base_weight )
237
240
238
241
# change is sent back to sending address unless specified
@@ -246,7 +249,7 @@ def _construct_tx_from_selected_buckets(self, *, buckets: Sequence[Bucket],
246
249
output_weight = 4 * Transaction .estimated_output_size_for_address (change_addrs [0 ])
247
250
fee_estimator_numchange = lambda count : fee_estimator_w (tx_weight + count * output_weight )
248
251
change = self ._change_outputs (tx , change_addrs , fee_estimator_numchange , dust_threshold )
249
- tx .add_outputs (change )
252
+ tx .add_outputs (change , BIP69_sort = BIP69_sort )
250
253
251
254
return tx , change
252
255
@@ -296,7 +299,7 @@ def make_tx(
296
299
self .p = PRNG (b'' .join (sorted (utxos )))
297
300
298
301
# Copy the outputs so when adding change we don't modify "outputs"
299
- base_tx = PartialTransaction .from_io (inputs [:], outputs [:])
302
+ base_tx = PartialTransaction .from_io (inputs [:], outputs [:], BIP69_sort = BIP69_sort )
300
303
input_value = base_tx .input_value ()
301
304
302
305
# Weight of the transaction with no inputs and no change
@@ -327,13 +330,15 @@ def sufficient_funds(buckets, *, bucket_value_sum):
327
330
return total_input >= spent_amount + fee_estimator_w (total_weight )
328
331
329
332
def tx_from_buckets (buckets ):
330
- return self ._construct_tx_from_selected_buckets (buckets = buckets ,
331
- base_tx = base_tx ,
332
- change_addrs = change_addrs ,
333
- fee_estimator_w = fee_estimator_w ,
334
- dust_threshold = dust_threshold ,
335
- base_weight = base_weight )
336
-
333
+ return self ._construct_tx_from_selected_buckets (
334
+ buckets = buckets ,
335
+ base_tx = base_tx ,
336
+ change_addrs = change_addrs ,
337
+ fee_estimator_w = fee_estimator_w ,
338
+ dust_threshold = dust_threshold ,
339
+ base_weight = base_weight ,
340
+ BIP69_sort = BIP69_sort ,
341
+ )
337
342
# Collect the coins into buckets
338
343
all_buckets = self .bucketize_coins (coins , fee_estimator_vb = fee_estimator_vb )
339
344
# Filter some buckets out. Only keep those that have positive effective value.
@@ -349,8 +354,6 @@ def tx_from_buckets(buckets):
349
354
self .logger .info (f"using { len (tx .inputs ())} inputs" )
350
355
self .logger .info (f"using buckets: { [bucket .desc for bucket in scored_candidate .buckets ]} " )
351
356
352
- if BIP69_sort :
353
- tx .BIP69_sort ()
354
357
return tx
355
358
356
359
def choose_buckets (self , buckets : List [Bucket ],
0 commit comments