@@ -57,6 +57,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
57
57
ui(new Ui::SendCoinsDialog),
58
58
clientModel(nullptr ),
59
59
model(nullptr ),
60
+ m_coin_control(new CCoinControl),
60
61
fNewRecipientAllowed(true ),
61
62
fFeeMinimized(true ),
62
63
platformStyle(_platformStyle)
@@ -259,14 +260,9 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
259
260
m_current_transaction = MakeUnique<WalletModelTransaction>(recipients);
260
261
WalletModel::SendCoinsReturn prepareStatus;
261
262
262
- // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
263
- CCoinControl ctrl;
264
- if (model->getOptionsModel ()->getCoinControlFeatures ())
265
- ctrl = *CoinControlDialog::coinControl ();
263
+ updateCoinControlState (*m_coin_control);
266
264
267
- updateCoinControlState (ctrl);
268
-
269
- prepareStatus = model->prepareTransaction (*m_current_transaction, ctrl);
265
+ prepareStatus = model->prepareTransaction (*m_current_transaction, *m_coin_control);
270
266
271
267
// process prepareStatus and on error generate message shown to user
272
268
processSendCoinsReturn (prepareStatus,
@@ -454,7 +450,7 @@ void SendCoinsDialog::on_sendButton_clicked()
454
450
}
455
451
if (!send_failure) {
456
452
accept ();
457
- CoinControlDialog::coinControl () ->UnSelectAll ();
453
+ m_coin_control ->UnSelectAll ();
458
454
coinControlUpdateLabels ();
459
455
}
460
456
fNewRecipientAllowed = true ;
@@ -466,7 +462,7 @@ void SendCoinsDialog::clear()
466
462
m_current_transaction.reset ();
467
463
468
464
// Clear coin control settings
469
- CoinControlDialog::coinControl () ->UnSelectAll ();
465
+ m_coin_control ->UnSelectAll ();
470
466
ui->checkBoxCoinControlChange ->setChecked (false );
471
467
ui->lineEditCoinControlChange ->clear ();
472
468
coinControlUpdateLabels ();
@@ -689,17 +685,11 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
689
685
690
686
void SendCoinsDialog::useAvailableBalance (SendCoinsEntry* entry)
691
687
{
692
- // Get CCoinControl instance if CoinControl is enabled or create a new one.
693
- CCoinControl coin_control;
694
- if (model->getOptionsModel ()->getCoinControlFeatures ()) {
695
- coin_control = *CoinControlDialog::coinControl ();
696
- }
697
-
698
688
// Include watch-only for wallets without private key
699
- coin_control. fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
689
+ m_coin_control-> fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
700
690
701
691
// Calculate available amount to send.
702
- CAmount amount = model->wallet ().getAvailableBalance (coin_control );
692
+ CAmount amount = model->wallet ().getAvailableBalance (*m_coin_control );
703
693
for (int i = 0 ; i < ui->entries ->count (); ++i) {
704
694
SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries ->itemAt (i)->widget ());
705
695
if (e && !e->isHidden () && e != entry) {
@@ -758,12 +748,11 @@ void SendCoinsDialog::updateSmartFeeLabel()
758
748
{
759
749
if (!model || !model->getOptionsModel ())
760
750
return ;
761
- CCoinControl coin_control;
762
- updateCoinControlState (coin_control);
763
- coin_control.m_feerate .reset (); // Explicitly use only fee estimation rate for smart fee labels
751
+ updateCoinControlState (*m_coin_control);
752
+ m_coin_control->m_feerate .reset (); // Explicitly use only fee estimation rate for smart fee labels
764
753
int returned_target;
765
754
FeeReason reason;
766
- CFeeRate feeRate = CFeeRate (model->wallet ().getMinimumFee (1000 , coin_control , &returned_target, &reason));
755
+ CFeeRate feeRate = CFeeRate (model->wallet ().getMinimumFee (1000 , *m_coin_control , &returned_target, &reason));
767
756
768
757
ui->labelSmartFee ->setText (BitcoinUnits::formatWithUnit (model->getOptionsModel ()->getDisplayUnit (), feeRate.GetFeePerK ()) + " /kB" );
769
758
@@ -834,16 +823,15 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
834
823
ui->frameCoinControl ->setVisible (checked);
835
824
836
825
if (!checked && model) // coin control features disabled
837
- CoinControlDialog::coinControl () ->SetNull ();
826
+ m_coin_control ->SetNull ();
838
827
839
828
coinControlUpdateLabels ();
840
829
}
841
830
842
831
// Coin Control: button inputs -> show actual coin control dialog
843
832
void SendCoinsDialog::coinControlButtonClicked ()
844
833
{
845
- CoinControlDialog dlg (platformStyle);
846
- dlg.setModel (model);
834
+ CoinControlDialog dlg (*m_coin_control, model, platformStyle);
847
835
dlg.exec ();
848
836
coinControlUpdateLabels ();
849
837
}
@@ -853,7 +841,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
853
841
{
854
842
if (state == Qt::Unchecked)
855
843
{
856
- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
844
+ m_coin_control ->destChange = CNoDestination ();
857
845
ui->labelCoinControlChangeLabel ->clear ();
858
846
}
859
847
else
@@ -869,7 +857,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
869
857
if (model && model->getAddressTableModel ())
870
858
{
871
859
// Default to no change address until verified
872
- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
860
+ m_coin_control ->destChange = CNoDestination ();
873
861
ui->labelCoinControlChangeLabel ->setStyleSheet (" QLabel{color:red;}" );
874
862
875
863
const CTxDestination dest = DecodeDestination (text.toStdString ());
@@ -892,7 +880,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
892
880
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
893
881
894
882
if (btnRetVal == QMessageBox::Yes)
895
- CoinControlDialog::coinControl () ->destChange = dest;
883
+ m_coin_control ->destChange = dest;
896
884
else
897
885
{
898
886
ui->lineEditCoinControlChange ->setText (" " );
@@ -911,7 +899,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
911
899
else
912
900
ui->labelCoinControlChangeLabel ->setText (tr (" (no label)" ));
913
901
914
- CoinControlDialog::coinControl () ->destChange = dest;
902
+ m_coin_control ->destChange = dest;
915
903
}
916
904
}
917
905
}
@@ -923,7 +911,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
923
911
if (!model || !model->getOptionsModel ())
924
912
return ;
925
913
926
- updateCoinControlState (*CoinControlDialog::coinControl () );
914
+ updateCoinControlState (*m_coin_control );
927
915
928
916
// set pay amounts
929
917
CoinControlDialog::payAmounts.clear ();
@@ -941,10 +929,10 @@ void SendCoinsDialog::coinControlUpdateLabels()
941
929
}
942
930
}
943
931
944
- if (CoinControlDialog::coinControl () ->HasSelected ())
932
+ if (m_coin_control ->HasSelected ())
945
933
{
946
934
// actual coin control calculation
947
- CoinControlDialog::updateLabels (model, this );
935
+ CoinControlDialog::updateLabels (*m_coin_control, model, this );
948
936
949
937
// show coin control stats
950
938
ui->labelCoinControlAutomaticallySelected ->hide ();
0 commit comments