@@ -175,26 +175,20 @@ void SendCoinsDialog::setModel(WalletModel *_model)
175
175
ui->confTargetSelector ->addItem (tr (" %1 (%2 blocks)" ).arg (GUIUtil::formatNiceTimeOffset (n*Params ().GetConsensus ().nPowTargetSpacing )).arg (n));
176
176
}
177
177
connect (ui->confTargetSelector , SIGNAL (currentIndexChanged (int )), this , SLOT (updateSmartFeeLabel ()));
178
- connect (ui->confTargetSelector , SIGNAL (currentIndexChanged (int )), this , SLOT (updateGlobalFeeVariables ()));
179
178
connect (ui->confTargetSelector , SIGNAL (currentIndexChanged (int )), this , SLOT (coinControlUpdateLabels ()));
180
179
connect (ui->groupFee , SIGNAL (buttonClicked (int )), this , SLOT (updateFeeSectionControls ()));
181
- connect (ui->groupFee , SIGNAL (buttonClicked (int )), this , SLOT (updateGlobalFeeVariables ()));
182
180
connect (ui->groupFee , SIGNAL (buttonClicked (int )), this , SLOT (coinControlUpdateLabels ()));
183
- connect (ui->groupCustomFee , SIGNAL (buttonClicked (int )), this , SLOT (updateGlobalFeeVariables ()));
184
181
connect (ui->groupCustomFee , SIGNAL (buttonClicked (int )), this , SLOT (coinControlUpdateLabels ()));
185
- connect (ui->customFee , SIGNAL (valueChanged ()), this , SLOT (updateGlobalFeeVariables ()));
186
182
connect (ui->customFee , SIGNAL (valueChanged ()), this , SLOT (coinControlUpdateLabels ()));
187
183
connect (ui->checkBoxMinimumFee , SIGNAL (stateChanged (int )), this , SLOT (setMinimumFee ()));
188
184
connect (ui->checkBoxMinimumFee , SIGNAL (stateChanged (int )), this , SLOT (updateFeeSectionControls ()));
189
- connect (ui->checkBoxMinimumFee , SIGNAL (stateChanged (int )), this , SLOT (updateGlobalFeeVariables ()));
190
185
connect (ui->checkBoxMinimumFee , SIGNAL (stateChanged (int )), this , SLOT (coinControlUpdateLabels ()));
191
186
connect (ui->optInRBF , SIGNAL (stateChanged (int )), this , SLOT (updateSmartFeeLabel ()));
192
187
connect (ui->optInRBF , SIGNAL (stateChanged (int )), this , SLOT (coinControlUpdateLabels ()));
193
188
ui->customFee ->setSingleStep (CWallet::GetRequiredFee (1000 ));
194
189
updateFeeSectionControls ();
195
190
updateMinFeeLabel ();
196
191
updateSmartFeeLabel ();
197
- updateGlobalFeeVariables ();
198
192
199
193
// set default rbf checkbox state
200
194
ui->optInRBF ->setCheckState (model->getDefaultWalletRbf () ? Qt::Checked : Qt::Unchecked);
@@ -274,12 +268,8 @@ void SendCoinsDialog::on_sendButton_clicked()
274
268
CCoinControl ctrl;
275
269
if (model->getOptionsModel ()->getCoinControlFeatures ())
276
270
ctrl = *CoinControlDialog::coinControl;
277
- if (ui->radioSmartFee ->isChecked ()) {
278
- ctrl.m_confirm_target = getConfTargetForIndex (ui->confTargetSelector ->currentIndex ());
279
- } else {
280
- ctrl.m_confirm_target = boost::none;
281
- }
282
- ctrl.signalRbf = ui->optInRBF ->isChecked ();
271
+
272
+ updateCoinControlState (ctrl);
283
273
284
274
prepareStatus = model->prepareTransaction (currentTransaction, ctrl);
285
275
@@ -636,18 +626,6 @@ void SendCoinsDialog::updateFeeSectionControls()
636
626
ui->customFee ->setEnabled (ui->radioCustomFee ->isChecked () && !ui->checkBoxMinimumFee ->isChecked ());
637
627
}
638
628
639
- void SendCoinsDialog::updateGlobalFeeVariables ()
640
- {
641
- if (ui->radioSmartFee ->isChecked ())
642
- {
643
- payTxFee = CFeeRate (0 );
644
- }
645
- else
646
- {
647
- payTxFee = CFeeRate (ui->customFee ->value ());
648
- }
649
- }
650
-
651
629
void SendCoinsDialog::updateFeeMinimizedLabel ()
652
630
{
653
631
if (!model || !model->getOptionsModel ())
@@ -669,15 +647,30 @@ void SendCoinsDialog::updateMinFeeLabel()
669
647
);
670
648
}
671
649
650
+ void SendCoinsDialog::updateCoinControlState (CCoinControl& ctrl)
651
+ {
652
+ if (ui->radioCustomFee ->isChecked ()) {
653
+ ctrl.m_feerate = CFeeRate (ui->customFee ->value ());
654
+ } else {
655
+ ctrl.m_feerate = boost::none;
656
+ }
657
+ // Avoid using global defaults when sending money from the GUI
658
+ // Either custom fee will be used or if not selected, the confirmation target from dropdown box
659
+ ctrl.m_confirm_target = getConfTargetForIndex (ui->confTargetSelector ->currentIndex ());
660
+ ctrl.signalRbf = ui->optInRBF ->isChecked ();
661
+ }
662
+
672
663
void SendCoinsDialog::updateSmartFeeLabel ()
673
664
{
674
665
if (!model || !model->getOptionsModel ())
675
666
return ;
676
-
677
- int nBlocksToConfirm = getConfTargetForIndex (ui->confTargetSelector ->currentIndex ());
667
+ CCoinControl coin_control;
668
+ updateCoinControlState (coin_control);
669
+ coin_control.m_feerate = boost::none; // Explicitly use only fee estimation rate for smart fee labels
678
670
FeeCalculation feeCalc;
679
- bool conservative_estimate = CalculateEstimateType (FeeEstimateMode::UNSET, ui->optInRBF ->isChecked ());
680
- CFeeRate feeRate = ::feeEstimator.estimateSmartFee (nBlocksToConfirm, &feeCalc, ::mempool, conservative_estimate);
671
+ bool conservative_estimate = CalculateEstimateType (FeeEstimateMode::UNSET, coin_control.signalRbf );
672
+ CFeeRate feeRate = ::feeEstimator.estimateSmartFee (*coin_control.m_confirm_target , &feeCalc, ::mempool, conservative_estimate);
673
+
681
674
if (feeRate <= CFeeRate (0 )) // not enough data => minfee
682
675
{
683
676
ui->labelSmartFee ->setText (BitcoinUnits::formatWithUnit (model->getOptionsModel ()->getDisplayUnit (),
@@ -752,8 +745,6 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
752
745
if (!checked && model) // coin control features disabled
753
746
CoinControlDialog::coinControl->SetNull ();
754
747
755
- // make sure we set back the confirmation target
756
- updateGlobalFeeVariables ();
757
748
coinControlUpdateLabels ();
758
749
}
759
750
@@ -844,15 +835,11 @@ void SendCoinsDialog::coinControlUpdateLabels()
844
835
if (!model || !model->getOptionsModel ())
845
836
return ;
846
837
838
+ updateCoinControlState (*CoinControlDialog::coinControl);
839
+
847
840
// set pay amounts
848
841
CoinControlDialog::payAmounts.clear ();
849
842
CoinControlDialog::fSubtractFeeFromAmount = false ;
850
- if (ui->radioSmartFee ->isChecked ()) {
851
- CoinControlDialog::coinControl->m_confirm_target = getConfTargetForIndex (ui->confTargetSelector ->currentIndex ());
852
- } else {
853
- CoinControlDialog::coinControl->m_confirm_target = boost::none;
854
- }
855
- CoinControlDialog::coinControl->signalRbf = ui->optInRBF ->isChecked ();
856
843
857
844
for (int i = 0 ; i < ui->entries ->count (); ++i)
858
845
{
0 commit comments