Changeset View
Changeset View
Standalone View
Standalone View
src/qt/sendcoinsdialog.cpp
Show All 13 Lines | |||||
#include <qt/coincontroldialog.h> | #include <qt/coincontroldialog.h> | ||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <qt/optionsmodel.h> | #include <qt/optionsmodel.h> | ||||
#include <qt/platformstyle.h> | #include <qt/platformstyle.h> | ||||
#include <qt/sendcoinsentry.h> | #include <qt/sendcoinsentry.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <validation.h> // mempool and minRelayTxFee | |||||
#include <wallet/coincontrol.h> | #include <wallet/coincontrol.h> | ||||
#include <wallet/fees.h> | #include <wallet/fees.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
#include <QScrollBar> | #include <QScrollBar> | ||||
#include <QSettings> | #include <QSettings> | ||||
#include <QTextDocument> | #include <QTextDocument> | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | if (_model && _model->getOptionsModel()) { | ||||
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(coinControlUpdateLabels())); | SLOT(coinControlUpdateLabels())); | ||||
ui->customFee->setSingleStep(GetMinimumFee(1000, g_mempool)); | ui->customFee->setSingleStep(model->node().getMinimumFee(1000)); | ||||
updateFeeSectionControls(); | updateFeeSectionControls(); | ||||
updateMinFeeLabel(); | updateMinFeeLabel(); | ||||
updateSmartFeeLabel(); | updateSmartFeeLabel(); | ||||
// 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) { | ||||
▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | switch (sendCoinsReturn.status) { | ||||
tr("The transaction was rejected with the following reason: %1") | tr("The transaction was rejected with the following reason: %1") | ||||
.arg(sendCoinsReturn.reasonCommitFailed); | .arg(sendCoinsReturn.reasonCommitFailed); | ||||
msgParams.second = CClientUIInterface::MSG_ERROR; | msgParams.second = CClientUIInterface::MSG_ERROR; | ||||
break; | break; | ||||
case WalletModel::AbsurdFee: | case WalletModel::AbsurdFee: | ||||
msgParams.first = | msgParams.first = | ||||
tr("A fee higher than %1 is considered an absurdly high fee.") | tr("A fee higher than %1 is considered an absurdly high fee.") | ||||
.arg(BitcoinUnits::formatWithUnit( | .arg(BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), maxTxFee)); | model->getOptionsModel()->getDisplayUnit(), | ||||
model->node().getMaxTxFee())); | |||||
break; | break; | ||||
case WalletModel::PaymentRequestExpired: | case WalletModel::PaymentRequestExpired: | ||||
msgParams.first = tr("Payment request expired."); | msgParams.first = tr("Payment request expired."); | ||||
msgParams.second = CClientUIInterface::MSG_ERROR; | msgParams.second = CClientUIInterface::MSG_ERROR; | ||||
break; | break; | ||||
// included to prevent a compiler warning. | // included to prevent a compiler warning. | ||||
case WalletModel::OK: | case WalletModel::OK: | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (amount > Amount::zero()) { | ||||
entry->setAmount(amount); | entry->setAmount(amount); | ||||
} else { | } else { | ||||
entry->setAmount(Amount::zero()); | entry->setAmount(Amount::zero()); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::setMinimumFee() { | void SendCoinsDialog::setMinimumFee() { | ||||
ui->radioCustomPerKilobyte->setChecked(true); | ui->radioCustomPerKilobyte->setChecked(true); | ||||
ui->customFee->setValue(GetMinimumFee(1000, g_mempool)); | ui->customFee->setValue(model->node().getMinimumFee(1000)); | ||||
} | } | ||||
void SendCoinsDialog::updateFeeSectionControls() { | void SendCoinsDialog::updateFeeSectionControls() { | ||||
ui->labelSmartFee->setEnabled(ui->radioSmartFee->isChecked()); | ui->labelSmartFee->setEnabled(ui->radioSmartFee->isChecked()); | ||||
ui->labelSmartFee2->setEnabled(ui->radioSmartFee->isChecked()); | ui->labelSmartFee2->setEnabled(ui->radioSmartFee->isChecked()); | ||||
ui->labelFeeEstimation->setEnabled(ui->radioSmartFee->isChecked()); | ui->labelFeeEstimation->setEnabled(ui->radioSmartFee->isChecked()); | ||||
ui->checkBoxMinimumFee->setEnabled(ui->radioCustomFee->isChecked()); | ui->checkBoxMinimumFee->setEnabled(ui->radioCustomFee->isChecked()); | ||||
ui->labelMinFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ui->labelMinFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ||||
Show All 21 Lines | |||||
} | } | ||||
void SendCoinsDialog::updateMinFeeLabel() { | void SendCoinsDialog::updateMinFeeLabel() { | ||||
if (model && model->getOptionsModel()) { | if (model && model->getOptionsModel()) { | ||||
ui->checkBoxMinimumFee->setText( | ui->checkBoxMinimumFee->setText( | ||||
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)) + | model->node().getMinimumFee(1000)) + | ||||
"/kB")); | "/kB")); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::updateCoinControlState(CCoinControl &ctrl) { | void SendCoinsDialog::updateCoinControlState(CCoinControl &ctrl) { | ||||
if (ui->radioCustomFee->isChecked()) { | if (ui->radioCustomFee->isChecked()) { | ||||
ctrl.m_feerate = CFeeRate(ui->customFee->value()); | ctrl.m_feerate = CFeeRate(ui->customFee->value()); | ||||
} else { | } else { | ||||
ctrl.m_feerate.reset(); | 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 = model->node().estimateSmartFee(); | ||||
ui->labelSmartFee->setText( | ui->labelSmartFee->setText( | ||||
BitcoinUnits::formatWithUnit( | BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), | model->getOptionsModel()->getDisplayUnit(), | ||||
std::max(feeRate.GetFeePerK(), GetMinimumFee(1000, g_mempool))) + | std::max(feeRate.GetFeePerK(), model->node().getMinimumFee(1000))) + | ||||
"/kB"); | "/kB"); | ||||
// not enough data => minfee | // not enough data => minfee | ||||
if (feeRate <= CFeeRate(Amount::zero())) { | 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->labelSmartFee2->hide(); | ui->labelSmartFee2->hide(); | ||||
▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines |