@@ -110,7 +110,6 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
110
110
ui->groupCustomFee ->setId (ui->radioCustomPerKilobyte , 0 );
111
111
ui->groupCustomFee ->setId (ui->radioCustomAtLeast , 1 );
112
112
ui->groupCustomFee ->button ((int )std::max (0 , std::min (1 , settings.value (" nCustomFeeRadio" ).toInt ())))->setChecked (true );
113
- ui->sliderSmartFee ->setValue (settings.value (" nSmartFeeSliderPosition" ).toInt ());
114
113
ui->customFee ->setValue (settings.value (" nTransactionFee" ).toLongLong ());
115
114
ui->checkBoxMinimumFee ->setChecked (settings.value (" fPayOnlyMinFee" ).toBool ());
116
115
minimizeFeeSection (settings.value (" fFeeSectionMinimized" ).toBool ());
@@ -172,6 +171,13 @@ void SendCoinsDialog::setModel(WalletModel *_model)
172
171
updateMinFeeLabel ();
173
172
updateSmartFeeLabel ();
174
173
updateGlobalFeeVariables ();
174
+
175
+ // set the smartfee-sliders default value (wallets default conf.target or last stored value)
176
+ QSettings settings;
177
+ if (settings.value (" nSmartFeeSliderPosition" ).toInt () == 0 )
178
+ ui->sliderSmartFee ->setValue (ui->sliderSmartFee ->maximum () - model->getDefaultConfirmTarget () + 1 );
179
+ else
180
+ ui->sliderSmartFee ->setValue (settings.value (" nSmartFeeSliderPosition" ).toInt ());
175
181
}
176
182
}
177
183
@@ -229,10 +235,17 @@ void SendCoinsDialog::on_sendButton_clicked()
229
235
// prepare transaction for getting txFee earlier
230
236
WalletModelTransaction currentTransaction (recipients);
231
237
WalletModel::SendCoinsReturn prepareStatus;
232
- if (model->getOptionsModel ()->getCoinControlFeatures ()) // coin control enabled
233
- prepareStatus = model->prepareTransaction (currentTransaction, CoinControlDialog::coinControl);
238
+
239
+ // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
240
+ CCoinControl ctrl;
241
+ if (model->getOptionsModel ()->getCoinControlFeatures ())
242
+ ctrl = *CoinControlDialog::coinControl;
243
+ if (ui->radioSmartFee ->isChecked ())
244
+ ctrl.nConfirmTarget = ui->sliderSmartFee ->maximum () - ui->sliderSmartFee ->value () + 1 ;
234
245
else
235
- prepareStatus = model->prepareTransaction (currentTransaction);
246
+ ctrl.nConfirmTarget = 0 ;
247
+
248
+ prepareStatus = model->prepareTransaction (currentTransaction, &ctrl);
236
249
237
250
// process prepareStatus and on error generate message shown to user
238
251
processSendCoinsReturn (prepareStatus,
@@ -576,6 +589,7 @@ void SendCoinsDialog::updateFeeSectionControls()
576
589
ui->labelFeeEstimation ->setEnabled (ui->radioSmartFee ->isChecked ());
577
590
ui->labelSmartFeeNormal ->setEnabled (ui->radioSmartFee ->isChecked ());
578
591
ui->labelSmartFeeFast ->setEnabled (ui->radioSmartFee ->isChecked ());
592
+ ui->confirmationTargetLabel ->setEnabled (ui->radioSmartFee ->isChecked ());
579
593
ui->checkBoxMinimumFee ->setEnabled (ui->radioCustomFee ->isChecked ());
580
594
ui->labelMinFeeWarning ->setEnabled (ui->radioCustomFee ->isChecked ());
581
595
ui->radioCustomPerKilobyte ->setEnabled (ui->radioCustomFee ->isChecked () && !ui->checkBoxMinimumFee ->isChecked ());
@@ -587,15 +601,17 @@ void SendCoinsDialog::updateGlobalFeeVariables()
587
601
{
588
602
if (ui->radioSmartFee ->isChecked ())
589
603
{
590
- nTxConfirmTarget = defaultConfirmTarget - ui->sliderSmartFee ->value ();
604
+ int nConfirmTarget = ui-> sliderSmartFee -> maximum () - ui->sliderSmartFee ->value () + 1 ;
591
605
payTxFee = CFeeRate (0 );
592
606
593
607
// set nMinimumTotalFee to 0 to not accidentally pay a custom fee
594
608
CoinControlDialog::coinControl->nMinimumTotalFee = 0 ;
609
+
610
+ // show the estimated reuquired time for confirmation
611
+ ui->confirmationTargetLabel ->setText (GUIUtil::formatDurationStr (nConfirmTarget*600 )+" / " +tr (" %n block(s)" , " " , nConfirmTarget));
595
612
}
596
613
else
597
614
{
598
- nTxConfirmTarget = defaultConfirmTarget;
599
615
payTxFee = CFeeRate (ui->customFee ->value ());
600
616
601
617
// if user has selected to set a minimum absolute fee, pass the value to coincontrol
@@ -630,7 +646,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
630
646
if (!model || !model->getOptionsModel ())
631
647
return ;
632
648
633
- int nBlocksToConfirm = defaultConfirmTarget - ui->sliderSmartFee ->value ();
649
+ int nBlocksToConfirm = ui-> sliderSmartFee -> maximum () - ui->sliderSmartFee ->value () + 1 ;
634
650
int estimateFoundAtBlocks = nBlocksToConfirm;
635
651
CFeeRate feeRate = mempool.estimateSmartFee (nBlocksToConfirm, &estimateFoundAtBlocks);
636
652
if (feeRate <= CFeeRate (0 )) // not enough data => minfee
@@ -701,6 +717,8 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
701
717
if (!checked && model) // coin control features disabled
702
718
CoinControlDialog::coinControl->SetNull ();
703
719
720
+ // make sure we set back the confirmation target
721
+ updateGlobalFeeVariables ();
704
722
coinControlUpdateLabels ();
705
723
}
706
724
0 commit comments