Changeset View
Changeset View
Standalone View
Standalone View
src/qt/sendcoinsdialog.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, | ||||
if (!settings.contains("nFeeRadio")) { | if (!settings.contains("nFeeRadio")) { | ||||
// recommended | // recommended | ||||
settings.setValue("nFeeRadio", 0); | settings.setValue("nFeeRadio", 0); | ||||
} | } | ||||
if (!settings.contains("nTransactionFee")) { | if (!settings.contains("nTransactionFee")) { | ||||
settings.setValue("nTransactionFee", | settings.setValue("nTransactionFee", | ||||
qint64(DEFAULT_PAY_TX_FEE / SATOSHI)); | qint64(DEFAULT_PAY_TX_FEE / SATOSHI)); | ||||
} | } | ||||
if (!settings.contains("fPayOnlyMinFee")) { | |||||
settings.setValue("fPayOnlyMinFee", false); | |||||
} | |||||
ui->groupFee->setId(ui->radioSmartFee, 0); | ui->groupFee->setId(ui->radioSmartFee, 0); | ||||
ui->groupFee->setId(ui->radioCustomFee, 1); | ui->groupFee->setId(ui->radioCustomFee, 1); | ||||
ui->groupFee | ui->groupFee | ||||
->button( | ->button( | ||||
std::max<int>(0, std::min(1, settings.value("nFeeRadio").toInt()))) | std::max<int>(0, std::min(1, settings.value("nFeeRadio").toInt()))) | ||||
->setChecked(true); | ->setChecked(true); | ||||
ui->customFee->SetAllowEmpty(false); | |||||
ui->customFee->setValue( | ui->customFee->setValue( | ||||
int64_t(settings.value("nTransactionFee").toLongLong()) * SATOSHI); | int64_t(settings.value("nTransactionFee").toLongLong()) * SATOSHI); | ||||
ui->checkBoxMinimumFee->setChecked( | |||||
settings.value("fPayOnlyMinFee").toBool()); | |||||
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool()); | minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool()); | ||||
// Set the model properly. | // Set the model properly. | ||||
setModel(model); | setModel(model); | ||||
} | } | ||||
void SendCoinsDialog::setClientModel(ClientModel *_clientModel) { | void SendCoinsDialog::setClientModel(ClientModel *_clientModel) { | ||||
this->clientModel = _clientModel; | this->clientModel = _clientModel; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | #else | ||||
&QButtonGroup::buttonClicked); | &QButtonGroup::buttonClicked); | ||||
#endif | #endif | ||||
connect(ui->groupFee, buttonClickedEvent, this, | connect(ui->groupFee, buttonClickedEvent, this, | ||||
&SendCoinsDialog::updateFeeSectionControls); | &SendCoinsDialog::updateFeeSectionControls); | ||||
connect(ui->groupFee, buttonClickedEvent, this, | connect(ui->groupFee, buttonClickedEvent, this, | ||||
&SendCoinsDialog::coinControlUpdateLabels); | &SendCoinsDialog::coinControlUpdateLabels); | ||||
connect(ui->customFee, &BitcoinAmountField::valueChanged, this, | connect(ui->customFee, &BitcoinAmountField::valueChanged, this, | ||||
&SendCoinsDialog::coinControlUpdateLabels); | &SendCoinsDialog::coinControlUpdateLabels); | ||||
connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, | Amount requiredFee = model->wallet().getRequiredFee(1000); | ||||
&SendCoinsDialog::setMinimumFee); | ui->customFee->SetMinValue(requiredFee); | ||||
connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, | if (ui->customFee->value() < requiredFee) { | ||||
&SendCoinsDialog::updateFeeSectionControls); | ui->customFee->setValue(requiredFee); | ||||
connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, | } | ||||
&SendCoinsDialog::coinControlUpdateLabels); | ui->customFee->setSingleStep(requiredFee); | ||||
ui->customFee->setSingleStep(model->wallet().getRequiredFee(1000)); | |||||
updateFeeSectionControls(); | updateFeeSectionControls(); | ||||
updateMinFeeLabel(); | |||||
updateSmartFeeLabel(); | updateSmartFeeLabel(); | ||||
if (model->wallet().privateKeysDisabled()) { | if (model->wallet().privateKeysDisabled()) { | ||||
ui->sendButton->setText(tr("Cr&eate Unsigned")); | ui->sendButton->setText(tr("Cr&eate Unsigned")); | ||||
ui->sendButton->setToolTip( | ui->sendButton->setToolTip( | ||||
tr("Creates a Partially Signed Bitcoin Transaction (PSBT) for " | tr("Creates a Partially Signed Bitcoin Transaction (PSBT) for " | ||||
"use with e.g. an offline %1 wallet, or a PSBT-compatible " | "use with e.g. an offline %1 wallet, or a PSBT-compatible " | ||||
"hardware wallet.") | "hardware wallet.") | ||||
.arg(PACKAGE_NAME)); | .arg(PACKAGE_NAME)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
SendCoinsDialog::~SendCoinsDialog() { | SendCoinsDialog::~SendCoinsDialog() { | ||||
QSettings settings; | QSettings settings; | ||||
settings.setValue("fFeeSectionMinimized", fFeeMinimized); | settings.setValue("fFeeSectionMinimized", fFeeMinimized); | ||||
settings.setValue("nFeeRadio", ui->groupFee->checkedId()); | settings.setValue("nFeeRadio", ui->groupFee->checkedId()); | ||||
settings.setValue("nTransactionFee", | settings.setValue("nTransactionFee", | ||||
qint64(ui->customFee->value() / SATOSHI)); | qint64(ui->customFee->value() / SATOSHI)); | ||||
settings.setValue("fPayOnlyMinFee", ui->checkBoxMinimumFee->isChecked()); | |||||
delete ui; | delete ui; | ||||
} | } | ||||
bool SendCoinsDialog::PrepareSendText(QString &question_string, | bool SendCoinsDialog::PrepareSendText(QString &question_string, | ||||
QString &informative_text, | QString &informative_text, | ||||
QString &detailed_text) { | QString &detailed_text) { | ||||
QList<SendCoinsRecipient> recipients; | QList<SendCoinsRecipient> recipients; | ||||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | if (model && model->getOptionsModel()) { | ||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), balance)); | model->getOptionsModel()->getDisplayUnit(), balance)); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::updateDisplayUnit() { | void SendCoinsDialog::updateDisplayUnit() { | ||||
setBalance(model->wallet().getBalances()); | setBalance(model->wallet().getBalances()); | ||||
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); | ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); | ||||
updateMinFeeLabel(); | |||||
updateSmartFeeLabel(); | updateSmartFeeLabel(); | ||||
} | } | ||||
void SendCoinsDialog::processSendCoinsReturn( | void SendCoinsDialog::processSendCoinsReturn( | ||||
const WalletModel::SendCoinsReturn &sendCoinsReturn, | const WalletModel::SendCoinsReturn &sendCoinsReturn, | ||||
const QString &msgArg) { | const QString &msgArg) { | ||||
QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams; | QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams; | ||||
// Default to a warning message, override if error message is needed | // Default to a warning message, override if error message is needed | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | void SendCoinsDialog::useAvailableBalance(SendCoinsEntry *entry) { | ||||
if (amount > Amount::zero()) { | if (amount > Amount::zero()) { | ||||
entry->checkSubtractFeeFromAmount(); | entry->checkSubtractFeeFromAmount(); | ||||
entry->setAmount(amount); | entry->setAmount(amount); | ||||
} else { | } else { | ||||
entry->setAmount(Amount::zero()); | entry->setAmount(Amount::zero()); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::setMinimumFee() { | |||||
ui->customFee->setValue(model->wallet().getRequiredFee(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->labelCustomFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ||||
ui->labelMinFeeWarning->setEnabled(ui->radioCustomFee->isChecked()); | ui->labelCustomPerKilobyte->setEnabled(ui->radioCustomFee->isChecked()); | ||||
ui->labelCustomPerKilobyte->setEnabled( | ui->customFee->setEnabled(ui->radioCustomFee->isChecked()); | ||||
ui->radioCustomFee->isChecked() && | |||||
!ui->checkBoxMinimumFee->isChecked()); | |||||
ui->customFee->setEnabled(ui->radioCustomFee->isChecked() && | |||||
!ui->checkBoxMinimumFee->isChecked()); | |||||
} | } | ||||
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 { | ||||
ui->labelFeeMinimized->setText( | ui->labelFeeMinimized->setText( | ||||
BitcoinUnits::formatWithUnit( | BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), | model->getOptionsModel()->getDisplayUnit(), | ||||
ui->customFee->value()) + | ui->customFee->value()) + | ||||
"/kB"); | "/kB"); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::updateMinFeeLabel() { | |||||
if (model && model->getOptionsModel()) { | |||||
ui->checkBoxMinimumFee->setText( | |||||
tr("Pay only the required fee of %1") | |||||
.arg(BitcoinUnits::formatWithUnit( | |||||
model->getOptionsModel()->getDisplayUnit(), | |||||
model->wallet().getRequiredFee(1000)) + | |||||
"/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(); | ||||
} | } | ||||
// Include watch-only for wallets without private key | // Include watch-only for wallets without private key | ||||
ctrl.fAllowWatchOnly = model->wallet().privateKeysDisabled(); | ctrl.fAllowWatchOnly = model->wallet().privateKeysDisabled(); | ||||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |