@@ -57,6 +57,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
5757 ui(new Ui::SendCoinsDialog),
5858 clientModel(nullptr ),
5959 model(nullptr ),
60+ m_coin_control(new CCoinControl),
6061 fNewRecipientAllowed(true ),
6162 fFeeMinimized(true ),
6263 platformStyle(_platformStyle)
@@ -259,14 +260,9 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
259260 m_current_transaction = MakeUnique<WalletModelTransaction>(recipients);
260261 WalletModel::SendCoinsReturn prepareStatus;
261262
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);
266264
267- updateCoinControlState (ctrl);
268-
269- prepareStatus = model->prepareTransaction (*m_current_transaction, ctrl);
265+ prepareStatus = model->prepareTransaction (*m_current_transaction, *m_coin_control);
270266
271267 // process prepareStatus and on error generate message shown to user
272268 processSendCoinsReturn (prepareStatus,
@@ -454,7 +450,7 @@ void SendCoinsDialog::on_sendButton_clicked()
454450 }
455451 if (!send_failure) {
456452 accept ();
457- CoinControlDialog::coinControl () ->UnSelectAll ();
453+ m_coin_control ->UnSelectAll ();
458454 coinControlUpdateLabels ();
459455 }
460456 fNewRecipientAllowed = true ;
@@ -466,7 +462,7 @@ void SendCoinsDialog::clear()
466462 m_current_transaction.reset ();
467463
468464 // Clear coin control settings
469- CoinControlDialog::coinControl () ->UnSelectAll ();
465+ m_coin_control ->UnSelectAll ();
470466 ui->checkBoxCoinControlChange ->setChecked (false );
471467 ui->lineEditCoinControlChange ->clear ();
472468 coinControlUpdateLabels ();
@@ -689,17 +685,11 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
689685
690686void SendCoinsDialog::useAvailableBalance (SendCoinsEntry* entry)
691687{
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-
698688 // Include watch-only for wallets without private key
699- coin_control. fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
689+ m_coin_control-> fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
700690
701691 // Calculate available amount to send.
702- CAmount amount = model->wallet ().getAvailableBalance (coin_control );
692+ CAmount amount = model->wallet ().getAvailableBalance (*m_coin_control );
703693 for (int i = 0 ; i < ui->entries ->count (); ++i) {
704694 SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries ->itemAt (i)->widget ());
705695 if (e && !e->isHidden () && e != entry) {
@@ -758,12 +748,11 @@ void SendCoinsDialog::updateSmartFeeLabel()
758748{
759749 if (!model || !model->getOptionsModel ())
760750 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
764753 int returned_target;
765754 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));
767756
768757 ui->labelSmartFee ->setText (BitcoinUnits::formatWithUnit (model->getOptionsModel ()->getDisplayUnit (), feeRate.GetFeePerK ()) + " /kB" );
769758
@@ -834,16 +823,15 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
834823 ui->frameCoinControl ->setVisible (checked);
835824
836825 if (!checked && model) // coin control features disabled
837- CoinControlDialog::coinControl () ->SetNull ();
826+ m_coin_control ->SetNull ();
838827
839828 coinControlUpdateLabels ();
840829}
841830
842831// Coin Control: button inputs -> show actual coin control dialog
843832void SendCoinsDialog::coinControlButtonClicked ()
844833{
845- CoinControlDialog dlg (platformStyle);
846- dlg.setModel (model);
834+ CoinControlDialog dlg (*m_coin_control, model, platformStyle);
847835 dlg.exec ();
848836 coinControlUpdateLabels ();
849837}
@@ -853,7 +841,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
853841{
854842 if (state == Qt::Unchecked)
855843 {
856- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
844+ m_coin_control ->destChange = CNoDestination ();
857845 ui->labelCoinControlChangeLabel ->clear ();
858846 }
859847 else
@@ -869,7 +857,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
869857 if (model && model->getAddressTableModel ())
870858 {
871859 // Default to no change address until verified
872- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
860+ m_coin_control ->destChange = CNoDestination ();
873861 ui->labelCoinControlChangeLabel ->setStyleSheet (" QLabel{color:red;}" );
874862
875863 const CTxDestination dest = DecodeDestination (text.toStdString ());
@@ -892,7 +880,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
892880 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
893881
894882 if (btnRetVal == QMessageBox::Yes)
895- CoinControlDialog::coinControl () ->destChange = dest;
883+ m_coin_control ->destChange = dest;
896884 else
897885 {
898886 ui->lineEditCoinControlChange ->setText (" " );
@@ -911,7 +899,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
911899 else
912900 ui->labelCoinControlChangeLabel ->setText (tr (" (no label)" ));
913901
914- CoinControlDialog::coinControl () ->destChange = dest;
902+ m_coin_control ->destChange = dest;
915903 }
916904 }
917905 }
@@ -923,7 +911,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
923911 if (!model || !model->getOptionsModel ())
924912 return ;
925913
926- updateCoinControlState (*CoinControlDialog::coinControl () );
914+ updateCoinControlState (*m_coin_control );
927915
928916 // set pay amounts
929917 CoinControlDialog::payAmounts.clear ();
@@ -941,10 +929,10 @@ void SendCoinsDialog::coinControlUpdateLabels()
941929 }
942930 }
943931
944- if (CoinControlDialog::coinControl () ->HasSelected ())
932+ if (m_coin_control ->HasSelected ())
945933 {
946934 // actual coin control calculation
947- CoinControlDialog::updateLabels (model, this );
935+ CoinControlDialog::updateLabels (*m_coin_control, model, this );
948936
949937 // show coin control stats
950938 ui->labelCoinControlAutomaticallySelected ->hide ();
0 commit comments