@@ -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)
@@ -262,14 +263,9 @@ void SendCoinsDialog::on_sendButton_clicked()
262263 WalletModelTransaction currentTransaction (recipients);
263264 WalletModel::SendCoinsReturn prepareStatus;
264265
265- // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
266- CCoinControl ctrl;
267- if (model->getOptionsModel ()->getCoinControlFeatures ())
268- ctrl = *CoinControlDialog::coinControl ();
266+ updateCoinControlState (*m_coin_control);
269267
270- updateCoinControlState (ctrl);
271-
272- prepareStatus = model->prepareTransaction (currentTransaction, ctrl);
268+ prepareStatus = model->prepareTransaction (currentTransaction, *m_coin_control);
273269
274270 // process prepareStatus and on error generate message shown to user
275271 processSendCoinsReturn (prepareStatus,
@@ -413,7 +409,7 @@ void SendCoinsDialog::on_sendButton_clicked()
413409 }
414410 if (!send_failure) {
415411 accept ();
416- CoinControlDialog::coinControl () ->UnSelectAll ();
412+ m_coin_control ->UnSelectAll ();
417413 coinControlUpdateLabels ();
418414 }
419415 fNewRecipientAllowed = true ;
@@ -422,7 +418,7 @@ void SendCoinsDialog::on_sendButton_clicked()
422418void SendCoinsDialog::clear ()
423419{
424420 // Clear coin control settings
425- CoinControlDialog::coinControl () ->UnSelectAll ();
421+ m_coin_control ->UnSelectAll ();
426422 ui->checkBoxCoinControlChange ->setChecked (false );
427423 ui->lineEditCoinControlChange ->clear ();
428424 coinControlUpdateLabels ();
@@ -645,17 +641,11 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
645641
646642void SendCoinsDialog::useAvailableBalance (SendCoinsEntry* entry)
647643{
648- // Get CCoinControl instance if CoinControl is enabled or create a new one.
649- CCoinControl coin_control;
650- if (model->getOptionsModel ()->getCoinControlFeatures ()) {
651- coin_control = *CoinControlDialog::coinControl ();
652- }
653-
654644 // Include watch-only for wallets without private key
655- coin_control. fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
645+ m_coin_control-> fAllowWatchOnly = model->wallet ().privateKeysDisabled ();
656646
657647 // Calculate available amount to send.
658- CAmount amount = model->wallet ().getAvailableBalance (coin_control );
648+ CAmount amount = model->wallet ().getAvailableBalance (*m_coin_control );
659649 for (int i = 0 ; i < ui->entries ->count (); ++i) {
660650 SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries ->itemAt (i)->widget ());
661651 if (e && !e->isHidden () && e != entry) {
@@ -714,12 +704,11 @@ void SendCoinsDialog::updateSmartFeeLabel()
714704{
715705 if (!model || !model->getOptionsModel ())
716706 return ;
717- CCoinControl coin_control;
718- updateCoinControlState (coin_control);
719- coin_control.m_feerate .reset (); // Explicitly use only fee estimation rate for smart fee labels
707+ updateCoinControlState (*m_coin_control);
708+ m_coin_control->m_feerate .reset (); // Explicitly use only fee estimation rate for smart fee labels
720709 int returned_target;
721710 FeeReason reason;
722- CFeeRate feeRate = CFeeRate (model->wallet ().getMinimumFee (1000 , coin_control , &returned_target, &reason));
711+ CFeeRate feeRate = CFeeRate (model->wallet ().getMinimumFee (1000 , *m_coin_control , &returned_target, &reason));
723712
724713 ui->labelSmartFee ->setText (BitcoinUnits::formatWithUnit (model->getOptionsModel ()->getDisplayUnit (), feeRate.GetFeePerK ()) + " /kB" );
725714
@@ -790,16 +779,15 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
790779 ui->frameCoinControl ->setVisible (checked);
791780
792781 if (!checked && model) // coin control features disabled
793- CoinControlDialog::coinControl () ->SetNull ();
782+ m_coin_control ->SetNull ();
794783
795784 coinControlUpdateLabels ();
796785}
797786
798787// Coin Control: button inputs -> show actual coin control dialog
799788void SendCoinsDialog::coinControlButtonClicked ()
800789{
801- CoinControlDialog dlg (platformStyle);
802- dlg.setModel (model);
790+ CoinControlDialog dlg (*m_coin_control, model, platformStyle);
803791 dlg.exec ();
804792 coinControlUpdateLabels ();
805793}
@@ -809,7 +797,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
809797{
810798 if (state == Qt::Unchecked)
811799 {
812- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
800+ m_coin_control ->destChange = CNoDestination ();
813801 ui->labelCoinControlChangeLabel ->clear ();
814802 }
815803 else
@@ -825,7 +813,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
825813 if (model && model->getAddressTableModel ())
826814 {
827815 // Default to no change address until verified
828- CoinControlDialog::coinControl () ->destChange = CNoDestination ();
816+ m_coin_control ->destChange = CNoDestination ();
829817 ui->labelCoinControlChangeLabel ->setStyleSheet (" QLabel{color:red;}" );
830818
831819 const CTxDestination dest = DecodeDestination (text.toStdString ());
@@ -848,7 +836,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
848836 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
849837
850838 if (btnRetVal == QMessageBox::Yes)
851- CoinControlDialog::coinControl () ->destChange = dest;
839+ m_coin_control ->destChange = dest;
852840 else
853841 {
854842 ui->lineEditCoinControlChange ->setText (" " );
@@ -867,7 +855,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
867855 else
868856 ui->labelCoinControlChangeLabel ->setText (tr (" (no label)" ));
869857
870- CoinControlDialog::coinControl () ->destChange = dest;
858+ m_coin_control ->destChange = dest;
871859 }
872860 }
873861 }
@@ -879,7 +867,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
879867 if (!model || !model->getOptionsModel ())
880868 return ;
881869
882- updateCoinControlState (*CoinControlDialog::coinControl () );
870+ updateCoinControlState (*m_coin_control );
883871
884872 // set pay amounts
885873 CoinControlDialog::payAmounts.clear ();
@@ -897,10 +885,10 @@ void SendCoinsDialog::coinControlUpdateLabels()
897885 }
898886 }
899887
900- if (CoinControlDialog::coinControl () ->HasSelected ())
888+ if (m_coin_control ->HasSelected ())
901889 {
902890 // actual coin control calculation
903- CoinControlDialog::updateLabels (model, this );
891+ CoinControlDialog::updateLabels (*m_coin_control, model, this );
904892
905893 // show coin control stats
906894 ui->labelCoinControlAutomaticallySelected ->hide ();
0 commit comments