mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
gui: Fix manual coin control with multiple wallets loaded
This commit is contained in:
@@ -57,6 +57,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
|
||||
ui(new Ui::SendCoinsDialog),
|
||||
clientModel(nullptr),
|
||||
model(nullptr),
|
||||
m_coin_control(new CCoinControl),
|
||||
fNewRecipientAllowed(true),
|
||||
fFeeMinimized(true),
|
||||
platformStyle(_platformStyle)
|
||||
@@ -259,14 +260,9 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
|
||||
m_current_transaction = MakeUnique<WalletModelTransaction>(recipients);
|
||||
WalletModel::SendCoinsReturn prepareStatus;
|
||||
|
||||
// Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
|
||||
CCoinControl ctrl;
|
||||
if (model->getOptionsModel()->getCoinControlFeatures())
|
||||
ctrl = *CoinControlDialog::coinControl();
|
||||
updateCoinControlState(*m_coin_control);
|
||||
|
||||
updateCoinControlState(ctrl);
|
||||
|
||||
prepareStatus = model->prepareTransaction(*m_current_transaction, ctrl);
|
||||
prepareStatus = model->prepareTransaction(*m_current_transaction, *m_coin_control);
|
||||
|
||||
// process prepareStatus and on error generate message shown to user
|
||||
processSendCoinsReturn(prepareStatus,
|
||||
@@ -454,7 +450,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
}
|
||||
if (!send_failure) {
|
||||
accept();
|
||||
CoinControlDialog::coinControl()->UnSelectAll();
|
||||
m_coin_control->UnSelectAll();
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
fNewRecipientAllowed = true;
|
||||
@@ -466,7 +462,7 @@ void SendCoinsDialog::clear()
|
||||
m_current_transaction.reset();
|
||||
|
||||
// Clear coin control settings
|
||||
CoinControlDialog::coinControl()->UnSelectAll();
|
||||
m_coin_control->UnSelectAll();
|
||||
ui->checkBoxCoinControlChange->setChecked(false);
|
||||
ui->lineEditCoinControlChange->clear();
|
||||
coinControlUpdateLabels();
|
||||
@@ -689,17 +685,11 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
|
||||
|
||||
void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
|
||||
{
|
||||
// Get CCoinControl instance if CoinControl is enabled or create a new one.
|
||||
CCoinControl coin_control;
|
||||
if (model->getOptionsModel()->getCoinControlFeatures()) {
|
||||
coin_control = *CoinControlDialog::coinControl();
|
||||
}
|
||||
|
||||
// Include watch-only for wallets without private key
|
||||
coin_control.fAllowWatchOnly = model->wallet().privateKeysDisabled();
|
||||
m_coin_control->fAllowWatchOnly = model->wallet().privateKeysDisabled();
|
||||
|
||||
// Calculate available amount to send.
|
||||
CAmount amount = model->wallet().getAvailableBalance(coin_control);
|
||||
CAmount amount = model->wallet().getAvailableBalance(*m_coin_control);
|
||||
for (int i = 0; i < ui->entries->count(); ++i) {
|
||||
SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||
if (e && !e->isHidden() && e != entry) {
|
||||
@@ -758,12 +748,11 @@ void SendCoinsDialog::updateSmartFeeLabel()
|
||||
{
|
||||
if(!model || !model->getOptionsModel())
|
||||
return;
|
||||
CCoinControl coin_control;
|
||||
updateCoinControlState(coin_control);
|
||||
coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
|
||||
updateCoinControlState(*m_coin_control);
|
||||
m_coin_control->m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
|
||||
int returned_target;
|
||||
FeeReason reason;
|
||||
CFeeRate feeRate = CFeeRate(model->wallet().getMinimumFee(1000, coin_control, &returned_target, &reason));
|
||||
CFeeRate feeRate = CFeeRate(model->wallet().getMinimumFee(1000, *m_coin_control, &returned_target, &reason));
|
||||
|
||||
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
|
||||
|
||||
@@ -834,7 +823,7 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
|
||||
ui->frameCoinControl->setVisible(checked);
|
||||
|
||||
if (!checked && model) // coin control features disabled
|
||||
CoinControlDialog::coinControl()->SetNull();
|
||||
m_coin_control->SetNull();
|
||||
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
@@ -842,8 +831,7 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
|
||||
// Coin Control: button inputs -> show actual coin control dialog
|
||||
void SendCoinsDialog::coinControlButtonClicked()
|
||||
{
|
||||
CoinControlDialog dlg(platformStyle);
|
||||
dlg.setModel(model);
|
||||
CoinControlDialog dlg(*m_coin_control, model, platformStyle);
|
||||
dlg.exec();
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
@@ -853,7 +841,7 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
|
||||
{
|
||||
if (state == Qt::Unchecked)
|
||||
{
|
||||
CoinControlDialog::coinControl()->destChange = CNoDestination();
|
||||
m_coin_control->destChange = CNoDestination();
|
||||
ui->labelCoinControlChangeLabel->clear();
|
||||
}
|
||||
else
|
||||
@@ -869,7 +857,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||
if (model && model->getAddressTableModel())
|
||||
{
|
||||
// Default to no change address until verified
|
||||
CoinControlDialog::coinControl()->destChange = CNoDestination();
|
||||
m_coin_control->destChange = CNoDestination();
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
|
||||
const CTxDestination dest = DecodeDestination(text.toStdString());
|
||||
@@ -892,7 +880,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||
|
||||
if(btnRetVal == QMessageBox::Yes)
|
||||
CoinControlDialog::coinControl()->destChange = dest;
|
||||
m_coin_control->destChange = dest;
|
||||
else
|
||||
{
|
||||
ui->lineEditCoinControlChange->setText("");
|
||||
@@ -911,7 +899,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||
else
|
||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
||||
|
||||
CoinControlDialog::coinControl()->destChange = dest;
|
||||
m_coin_control->destChange = dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,7 +911,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
|
||||
if (!model || !model->getOptionsModel())
|
||||
return;
|
||||
|
||||
updateCoinControlState(*CoinControlDialog::coinControl());
|
||||
updateCoinControlState(*m_coin_control);
|
||||
|
||||
// set pay amounts
|
||||
CoinControlDialog::payAmounts.clear();
|
||||
@@ -941,10 +929,10 @@ void SendCoinsDialog::coinControlUpdateLabels()
|
||||
}
|
||||
}
|
||||
|
||||
if (CoinControlDialog::coinControl()->HasSelected())
|
||||
if (m_coin_control->HasSelected())
|
||||
{
|
||||
// actual coin control calculation
|
||||
CoinControlDialog::updateLabels(model, this);
|
||||
CoinControlDialog::updateLabels(*m_coin_control, model, this);
|
||||
|
||||
// show coin control stats
|
||||
ui->labelCoinControlAutomaticallySelected->hide();
|
||||
|
||||
Reference in New Issue
Block a user