30
30
from PyQt6 .QtCore import Qt
31
31
from PyQt6 .QtGui import QIcon
32
32
33
- from PyQt6 .QtWidgets import QHBoxLayout , QVBoxLayout , QLabel , QGridLayout , QPushButton , QToolButton , QMenu
33
+ from PyQt6 .QtWidgets import QHBoxLayout , QVBoxLayout , QLabel , QGridLayout , QPushButton , QToolButton , QMenu , QComboBox
34
34
35
35
from electrum .i18n import _
36
36
from electrum .util import NotEnoughFunds , NoDynamicFeeEstimates
@@ -79,6 +79,8 @@ def __init__(self, *, title='',
79
79
# preview is disabled for lightning channel funding
80
80
self ._allow_preview = allow_preview
81
81
self .is_preview = False
82
+ self ._base_tx = None # for batching
83
+ self .batching_candidates = self .wallet .get_unconfirmed_base_tx_for_batching ([], []) # todo: update it
82
84
83
85
self .locktime_e = LockTimeEdit (self )
84
86
self .locktime_e .valueEdited .connect (self .trigger_update )
@@ -112,7 +114,7 @@ def __init__(self, *, title='',
112
114
self .main_window .gui_object .timer .timeout .connect (self .timer_actions )
113
115
114
116
def is_batching (self ):
115
- return self .config . WALLET_BATCH_RBF and not self .main_window .utxo_list .is_coincontrol_active ()
117
+ return self ._base_tx and not self .main_window .utxo_list .is_coincontrol_active ()
116
118
117
119
def should_show_io (self ):
118
120
return self .config .GUI_QT_TX_EDITOR_SHOW_IO
@@ -151,6 +153,12 @@ def update_fee_target(self):
151
153
def update_feerate_label (self ):
152
154
self .feerate_label .setText (self .feerate_e .text () + ' ' + self .feerate_e .base_unit ())
153
155
156
+ def update_fee_controls (self ):
157
+ self .fee_slider .setEnabled (not self .is_batching ())
158
+ self .fee_combo .setEnabled (not self .is_batching ())
159
+ self .fee_slider .setVisible (not self .is_batching ())
160
+ self .fee_combo .setVisible (not self .is_batching ())
161
+
154
162
def create_fee_controls (self ):
155
163
156
164
self .fee_label = QLabel ('' )
@@ -380,6 +388,15 @@ def create_buttons_bar(self):
380
388
self .ok_button .clicked .connect (self .on_send )
381
389
self .ok_button .setDefault (True )
382
390
buttons = Buttons (CancelButton (self ), self .preview_button , self .ok_button )
391
+
392
+ if self .batching_candidates :
393
+ batching_combo = QComboBox ()
394
+ batching_combo .addItems ([_ ('Not batching' )] + [_ ('Batch with' ) + ' ' + x .txid ()[0 :10 ] for x in self .batching_candidates ])
395
+ buttons .insertWidget (0 , batching_combo )
396
+ def on_batching_combo (x ):
397
+ self ._base_tx = self .batching_candidates [x - 1 ] if x > 0 else None
398
+ self .update_batching ()
399
+ batching_combo .currentIndexChanged .connect (on_batching_combo )
383
400
return buttons
384
401
385
402
def create_top_bar (self , text ):
@@ -419,7 +436,6 @@ def add_cv_action(configvar: 'ConfigVarWithConfig', action: Callable[[], None]):
419
436
_ ('This may result in higher transactions fees.' )
420
437
]))
421
438
self .use_multi_change_menu .setEnabled (self .wallet .use_change )
422
- add_cv_action (self .config .cv .WALLET_BATCH_RBF , self .toggle_batch_rbf )
423
439
add_cv_action (self .config .cv .WALLET_MERGE_DUPLICATE_OUTPUTS , self .toggle_merge_duplicate_outputs )
424
440
add_cv_action (self .config .cv .WALLET_SPEND_CONFIRMED_ONLY , self .toggle_confirmed_only )
425
441
add_cv_action (self .config .cv .WALLET_COIN_CHOOSER_OUTPUT_ROUNDING , self .toggle_output_rounding )
@@ -456,9 +472,8 @@ def toggle_multiple_change(self):
456
472
self .wallet .db .put ('multiple_change' , self .wallet .multiple_change )
457
473
self .trigger_update ()
458
474
459
- def toggle_batch_rbf (self ):
460
- b = not self .config .WALLET_BATCH_RBF
461
- self .config .WALLET_BATCH_RBF = b
475
+ def update_batching (self ):
476
+ self .update_fee_controls ()
462
477
self .set_io_visible ()
463
478
self .resize_to_fit_content ()
464
479
self .trigger_update ()
@@ -581,7 +596,7 @@ def get_messages(self):
581
596
messages .append (_ ('This transaction will spend unconfirmed coins.' ))
582
597
# warn if we merge from mempool
583
598
if self .is_batching ():
584
- messages .append (_ ('Transaction batching is active. The fee will be bumped automatically if needed ' ))
599
+ messages .append (_ ('Transaction batching is active. The fee policy of the selected batch will be used ' ))
585
600
else :
586
601
# warn if we use multiple change outputs
587
602
num_change = sum (int (o .is_change ) for o in self .tx .outputs ())
@@ -652,17 +667,17 @@ def _update_amount_label(self):
652
667
def update_tx (self , * , fallback_to_zero_fee : bool = False ):
653
668
fee_estimator = self .get_fee_estimator ()
654
669
confirmed_only = self .config .WALLET_SPEND_CONFIRMED_ONLY
655
- is_batching = self .is_batching ()
670
+ base_tx = self ._base_tx
656
671
try :
657
- self .tx = self .make_tx (fee_estimator , confirmed_only = confirmed_only , is_batching = is_batching )
672
+ self .tx = self .make_tx (fee_estimator , confirmed_only = confirmed_only , base_tx = base_tx )
658
673
self .not_enough_funds = False
659
674
self .no_dynfee_estimates = False
660
675
except NotEnoughFunds :
661
676
self .not_enough_funds = True
662
677
self .tx = None
663
678
if fallback_to_zero_fee :
664
679
try :
665
- self .tx = self .make_tx (0 , confirmed_only = confirmed_only , is_batching = is_batching )
680
+ self .tx = self .make_tx (0 , confirmed_only = confirmed_only , base_tx = base_tx )
666
681
except BaseException :
667
682
return
668
683
else :
@@ -671,7 +686,7 @@ def update_tx(self, *, fallback_to_zero_fee: bool = False):
671
686
self .no_dynfee_estimates = True
672
687
self .tx = None
673
688
try :
674
- self .tx = self .make_tx (0 , confirmed_only = confirmed_only , is_batching = is_batching )
689
+ self .tx = self .make_tx (0 , confirmed_only = confirmed_only , base_tx = base_tx )
675
690
except NotEnoughFunds :
676
691
self .not_enough_funds = True
677
692
return
@@ -686,7 +701,7 @@ def update_tx(self, *, fallback_to_zero_fee: bool = False):
686
701
def can_pay_assuming_zero_fees (self , confirmed_only ) -> bool :
687
702
# called in send_tab.py
688
703
try :
689
- tx = self .make_tx (0 , confirmed_only = confirmed_only , is_batching = False )
704
+ tx = self .make_tx (0 , confirmed_only = confirmed_only , base_tx = None )
690
705
except NotEnoughFunds :
691
706
return False
692
707
else :
@@ -709,7 +724,7 @@ def create_grid(self):
709
724
grid .addWidget (HelpLabel (_ ("Mining Fee" ) + ": " , msg ), 1 , 0 )
710
725
grid .addLayout (self .fee_hbox , 1 , 1 , 1 , 3 )
711
726
712
- grid .addWidget (HelpLabel (_ ("Fee target " ) + ": " , self .fee_combo .help_msg ), 3 , 0 )
727
+ grid .addWidget (HelpLabel (_ ("Fee policy " ) + ": " , self .fee_combo .help_msg ), 3 , 0 )
713
728
grid .addLayout (self .fee_target_hbox , 3 , 1 , 1 , 3 )
714
729
715
730
grid .setColumnStretch (4 , 1 )
0 commit comments