Changeset View
Changeset View
Standalone View
Standalone View
src/qt/sendcoinsdialog.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | if (_model && _model->getOptionsModel()) { | ||||
ui->frameCoinControl->setVisible( | ui->frameCoinControl->setVisible( | ||||
_model->getOptionsModel()->getCoinControlFeatures()); | _model->getOptionsModel()->getCoinControlFeatures()); | ||||
coinControlUpdateLabels(); | coinControlUpdateLabels(); | ||||
// fee section | // fee section | ||||
connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, | connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, | ||||
SLOT(updateFeeSectionControls())); | SLOT(updateFeeSectionControls())); | ||||
connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, | connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, | ||||
SLOT(updateGlobalFeeVariables())); | |||||
connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, | |||||
SLOT(coinControlUpdateLabels())); | SLOT(coinControlUpdateLabels())); | ||||
connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, | connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, | ||||
SLOT(updateGlobalFeeVariables())); | |||||
connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, | |||||
SLOT(coinControlUpdateLabels())); | SLOT(coinControlUpdateLabels())); | ||||
connect(ui->customFee, SIGNAL(valueChanged()), this, | connect(ui->customFee, SIGNAL(valueChanged()), this, | ||||
SLOT(updateGlobalFeeVariables())); | |||||
connect(ui->customFee, SIGNAL(valueChanged()), this, | |||||
SLOT(coinControlUpdateLabels())); | SLOT(coinControlUpdateLabels())); | ||||
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | ||||
SLOT(setMinimumFee())); | SLOT(setMinimumFee())); | ||||
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | ||||
SLOT(updateFeeSectionControls())); | SLOT(updateFeeSectionControls())); | ||||
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | ||||
SLOT(updateGlobalFeeVariables())); | |||||
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, | |||||
SLOT(coinControlUpdateLabels())); | SLOT(coinControlUpdateLabels())); | ||||
ui->customFee->setSingleStep(GetMinimumFee(1000, g_mempool)); | ui->customFee->setSingleStep(GetMinimumFee(1000, g_mempool)); | ||||
updateFeeSectionControls(); | updateFeeSectionControls(); | ||||
updateMinFeeLabel(); | updateMinFeeLabel(); | ||||
updateSmartFeeLabel(); | updateSmartFeeLabel(); | ||||
updateGlobalFeeVariables(); | |||||
// Cleanup old confirmation target related settings | // Cleanup old confirmation target related settings | ||||
// TODO: Remove these in 0.20 | // TODO: Remove these in 0.20 | ||||
QSettings settings; | QSettings settings; | ||||
if (settings.value("nSmartFeeSliderPosition").toInt() != 0) { | if (settings.value("nSmartFeeSliderPosition").toInt() != 0) { | ||||
settings.remove("nSmartFeeSliderPosition"); | settings.remove("nSmartFeeSliderPosition"); | ||||
} | } | ||||
if (settings.value("nConfTarget").toInt() != 0) { | if (settings.value("nConfTarget").toInt() != 0) { | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void SendCoinsDialog::on_sendButton_clicked() { | ||||
// Always use a CCoinControl instance, use the CoinControlDialog instance if | // Always use a CCoinControl instance, use the CoinControlDialog instance if | ||||
// CoinControl has been enabled | // CoinControl has been enabled | ||||
CCoinControl ctrl; | CCoinControl ctrl; | ||||
if (model->getOptionsModel()->getCoinControlFeatures()) { | if (model->getOptionsModel()->getCoinControlFeatures()) { | ||||
ctrl = *CoinControlDialog::coinControl; | ctrl = *CoinControlDialog::coinControl; | ||||
} | } | ||||
prepareStatus = model->prepareTransaction(currentTransaction, &ctrl); | updateCoinControlState(ctrl); | ||||
prepareStatus = model->prepareTransaction(currentTransaction, ctrl); | |||||
// process prepareStatus and on error generate message shown to user | // process prepareStatus and on error generate message shown to user | ||||
processSendCoinsReturn( | processSendCoinsReturn( | ||||
prepareStatus, | prepareStatus, | ||||
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), | BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), | ||||
currentTransaction.getTransactionFee())); | currentTransaction.getTransactionFee())); | ||||
if (prepareStatus.status != WalletModel::OK) { | if (prepareStatus.status != WalletModel::OK) { | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | void SendCoinsDialog::updateFeeSectionControls() { | ||||
ui->labelMinFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ui->labelMinFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ||||
ui->radioCustomPerKilobyte->setEnabled( | ui->radioCustomPerKilobyte->setEnabled( | ||||
ui->radioCustomFee->isChecked() && | ui->radioCustomFee->isChecked() && | ||||
!ui->checkBoxMinimumFee->isChecked()); | !ui->checkBoxMinimumFee->isChecked()); | ||||
ui->customFee->setEnabled(ui->radioCustomFee->isChecked() && | ui->customFee->setEnabled(ui->radioCustomFee->isChecked() && | ||||
!ui->checkBoxMinimumFee->isChecked()); | !ui->checkBoxMinimumFee->isChecked()); | ||||
} | } | ||||
void SendCoinsDialog::updateGlobalFeeVariables() { | |||||
if (ui->radioSmartFee->isChecked()) { | |||||
payTxFee = CFeeRate(Amount::zero()); | |||||
} else { | |||||
payTxFee = CFeeRate(Amount(ui->customFee->value())); | |||||
} | |||||
} | |||||
void SendCoinsDialog::updateFeeMinimizedLabel() { | void SendCoinsDialog::updateFeeMinimizedLabel() { | ||||
if (!model || !model->getOptionsModel()) { | if (!model || !model->getOptionsModel()) { | ||||
return; | return; | ||||
} | } | ||||
if (ui->radioSmartFee->isChecked()) { | if (ui->radioSmartFee->isChecked()) { | ||||
ui->labelFeeMinimized->setText(ui->labelSmartFee->text()); | ui->labelFeeMinimized->setText(ui->labelSmartFee->text()); | ||||
} else { | } else { | ||||
Show All 11 Lines | if (model && model->getOptionsModel()) { | ||||
tr("Pay only the required fee of %1") | tr("Pay only the required fee of %1") | ||||
.arg(BitcoinUnits::formatWithUnit( | .arg(BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), | model->getOptionsModel()->getDisplayUnit(), | ||||
GetMinimumFee(1000, g_mempool)) + | GetMinimumFee(1000, g_mempool)) + | ||||
"/kB")); | "/kB")); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::updateCoinControlState(CCoinControl &ctrl) { | |||||
if (ui->radioCustomFee->isChecked()) { | |||||
ctrl.m_feerate = CFeeRate(ui->customFee->value()); | |||||
} else { | |||||
ctrl.m_feerate.reset(); | |||||
} | |||||
} | |||||
void SendCoinsDialog::updateSmartFeeLabel() { | void SendCoinsDialog::updateSmartFeeLabel() { | ||||
if (!model || !model->getOptionsModel()) { | if (!model || !model->getOptionsModel()) { | ||||
return; | return; | ||||
} | } | ||||
CFeeRate feeRate = g_mempool.estimateFee(); | CFeeRate feeRate = g_mempool.estimateFee(); | ||||
// not enough data => minfee | |||||
if (feeRate <= CFeeRate(Amount::zero())) { | |||||
ui->labelSmartFee->setText( | ui->labelSmartFee->setText( | ||||
BitcoinUnits::formatWithUnit( | BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), | model->getOptionsModel()->getDisplayUnit(), | ||||
std::max(CWallet::fallbackFee.GetFeePerK(), | std::max(feeRate.GetFeePerK(), GetMinimumFee(1000, g_mempool))) + | ||||
GetMinimumFee(1000, g_mempool))) + | |||||
"/kB"); | "/kB"); | ||||
// not enough data => minfee | |||||
if (feeRate <= CFeeRate(Amount::zero())) { | |||||
// (Smart fee not initialized yet. This usually takes a few blocks...) | // (Smart fee not initialized yet. This usually takes a few blocks...) | ||||
ui->labelSmartFee2->show(); | ui->labelSmartFee2->show(); | ||||
ui->labelFeeEstimation->setText(""); | ui->labelFeeEstimation->setText(""); | ||||
} else { | } else { | ||||
ui->labelSmartFee->setText( | |||||
BitcoinUnits::formatWithUnit( | |||||
model->getOptionsModel()->getDisplayUnit(), | |||||
std::max(feeRate.GetFeePerK(), | |||||
GetMinimumFee(1000, g_mempool))) + | |||||
"/kB"); | |||||
ui->labelSmartFee2->hide(); | ui->labelSmartFee2->hide(); | ||||
ui->labelFeeEstimation->setText( | ui->labelFeeEstimation->setText( | ||||
tr("Estimated to begin confirmation by next block.")); | tr("Estimated to begin confirmation by next block.")); | ||||
} | } | ||||
updateFeeMinimizedLabel(); | updateFeeMinimizedLabel(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
void SendCoinsDialog::coinControlFeatureChanged(bool checked) { | void SendCoinsDialog::coinControlFeatureChanged(bool checked) { | ||||
ui->frameCoinControl->setVisible(checked); | ui->frameCoinControl->setVisible(checked); | ||||
// coin control features disabled | // coin control features disabled | ||||
if (!checked && model) { | if (!checked && model) { | ||||
CoinControlDialog::coinControl->SetNull(); | CoinControlDialog::coinControl->SetNull(); | ||||
} | } | ||||
// make sure we set back the confirmation target | |||||
updateGlobalFeeVariables(); | |||||
coinControlUpdateLabels(); | coinControlUpdateLabels(); | ||||
} | } | ||||
// Coin Control: button inputs -> show actual coin control dialog | // Coin Control: button inputs -> show actual coin control dialog | ||||
void SendCoinsDialog::coinControlButtonClicked() { | void SendCoinsDialog::coinControlButtonClicked() { | ||||
CoinControlDialog dlg(platformStyle); | CoinControlDialog dlg(platformStyle); | ||||
dlg.setModel(model); | dlg.setModel(model); | ||||
dlg.exec(); | dlg.exec(); | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// Coin Control: update labels | // Coin Control: update labels | ||||
void SendCoinsDialog::coinControlUpdateLabels() { | void SendCoinsDialog::coinControlUpdateLabels() { | ||||
if (!model || !model->getOptionsModel()) { | if (!model || !model->getOptionsModel()) { | ||||
return; | return; | ||||
} | } | ||||
updateCoinControlState(*CoinControlDialog::coinControl); | |||||
// set pay amounts | // set pay amounts | ||||
CoinControlDialog::payAmounts.clear(); | CoinControlDialog::payAmounts.clear(); | ||||
CoinControlDialog::fSubtractFeeFromAmount = false; | CoinControlDialog::fSubtractFeeFromAmount = false; | ||||
for (int i = 0; i < ui->entries->count(); ++i) { | for (int i = 0; i < ui->entries->count(); ++i) { | ||||
SendCoinsEntry *entry = | SendCoinsEntry *entry = | ||||
qobject_cast<SendCoinsEntry *>(ui->entries->itemAt(i)->widget()); | qobject_cast<SendCoinsEntry *>(ui->entries->itemAt(i)->widget()); | ||||
if (entry && !entry->isHidden()) { | if (entry && !entry->isHidden()) { | ||||
SendCoinsRecipient rcp = entry->getValue(); | SendCoinsRecipient rcp = entry->getValue(); | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |