Skip to content

Commit 9490bd7

Browse files
committed
Merge pull request #7096
ff723da [Qt] improve minimum absolute fee option - Only display the minimum absolute fee control if CoinControl is enabled (Jonas Schnelli) 31b508a [Qt] make use of the nMinimumTotalFee (absolute) in coincontrols fee calculation (Jonas Schnelli) 80462dd [Qt] use ASYMP_UTF8 (≈) whenever we show a fee that is not absolute (Jonas Schnelli) ecc7c82 Move fPayAtLeastCustomFee function to CC (Pieter Wuille)
2 parents eb3d1b3 + ff723da commit 9490bd7

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

src/coincontrol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class CCoinControl
1616
bool fAllowOtherInputs;
1717
//! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
1818
bool fAllowWatchOnly;
19+
//! Minimum absolute fee (not per kilobyte)
20+
CAmount nMinimumTotalFee;
1921

2022
CCoinControl()
2123
{
@@ -28,6 +30,7 @@ class CCoinControl
2830
fAllowOtherInputs = false;
2931
fAllowWatchOnly = false;
3032
setSelected.clear();
33+
nMinimumTotalFee = 0;
3134
}
3235

3336
bool HasSelected() const

src/qt/coincontroldialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
549549

550550
// Fee
551551
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
552+
if (nPayFee > 0 && coinControl->nMinimumTotalFee > nPayFee)
553+
nPayFee = coinControl->nMinimumTotalFee;
554+
552555

553556
// Allow free? (require at least hard-coded threshold and default to that if no estimate)
554557
double dPriorityNeeded = std::max(mempoolEstimatePriority, AllowFreeThreshold());
@@ -619,7 +622,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
619622
l6->setText(sPriorityLabel); // Priority
620623
l7->setText(fDust ? tr("yes") : tr("no")); // Dust
621624
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
622-
if (nPayFee > 0 && !(payTxFee.GetFeePerK() > 0 && fPayAtLeastCustomFee && nBytes < 1000))
625+
if (nPayFee > 0 && (coinControl->nMinimumTotalFee < nPayFee))
623626
{
624627
l3->setText(ASYMP_UTF8 + l3->text());
625628
l4->setText(ASYMP_UTF8 + l4->text());

src/qt/sendcoinsdialog.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ void SendCoinsDialog::updateFeeSectionControls()
585585
ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked());
586586
ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked());
587587
ui->radioCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
588-
ui->radioCustomAtLeast ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
588+
ui->radioCustomAtLeast ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked() && CoinControlDialog::coinControl->HasSelected());
589589
ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
590590
}
591591

@@ -600,7 +600,10 @@ void SendCoinsDialog::updateGlobalFeeVariables()
600600
{
601601
nTxConfirmTarget = defaultConfirmTarget;
602602
payTxFee = CFeeRate(ui->customFee->value());
603-
fPayAtLeastCustomFee = ui->radioCustomAtLeast->isChecked();
603+
604+
// if user has selected to set a minimum absolute fee, pass the value to coincontrol
605+
// set nMinimumTotalFee to 0 in case of user has selected that the fee is per KB
606+
CoinControlDialog::coinControl->nMinimumTotalFee = ui->radioCustomAtLeast->isChecked() ? ui->customFee->value() : 0;
604607
}
605608

606609
fSendFreeTransactions = ui->checkBoxFreeTx->isChecked();
@@ -707,8 +710,7 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
707710
if (!checked && model) // coin control features disabled
708711
CoinControlDialog::coinControl->SetNull();
709712

710-
if (checked)
711-
coinControlUpdateLabels();
713+
coinControlUpdateLabels();
712714
}
713715

714716
// Coin Control: button inputs -> show actual coin control dialog
@@ -782,9 +784,24 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
782784
// Coin Control: update labels
783785
void SendCoinsDialog::coinControlUpdateLabels()
784786
{
785-
if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
787+
if (!model || !model->getOptionsModel())
786788
return;
787789

790+
if (model->getOptionsModel()->getCoinControlFeatures())
791+
{
792+
// enable minium absolute fee UI controls
793+
ui->radioCustomAtLeast->setVisible(true);
794+
795+
// only enable the feature if inputs are selected
796+
ui->radioCustomAtLeast->setEnabled(CoinControlDialog::coinControl->HasSelected());
797+
}
798+
else
799+
{
800+
// in case coin control is disabled (=default), hide minimum absolute fee UI controls
801+
ui->radioCustomAtLeast->setVisible(false);
802+
return;
803+
}
804+
788805
// set pay amounts
789806
CoinControlDialog::payAmounts.clear();
790807
CoinControlDialog::fSubtractFeeFromAmount = false;

src/wallet/wallet.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
4141
unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
4242
bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE;
4343
bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
44-
bool fPayAtLeastCustomFee = false;
4544

4645
/**
4746
* Fees smaller than this (in satoshi) are considered zero fee (for transaction creation)
@@ -2096,6 +2095,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
20962095
}
20972096

20982097
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
2098+
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
2099+
nFeeNeeded = coinControl->nMinimumTotalFee;
2100+
}
20992101

21002102
// If we made it here and we aren't even able to meet the relay fee on the next pass, give up
21012103
// because we must be at the maximum allowed fee.
@@ -2191,9 +2193,6 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
21912193
{
21922194
// payTxFee is user-set "I want to pay this much"
21932195
CAmount nFeeNeeded = payTxFee.GetFee(nTxBytes);
2194-
// user selected total at least (default=true)
2195-
if (fPayAtLeastCustomFee && nFeeNeeded > 0 && nFeeNeeded < payTxFee.GetFeePerK())
2196-
nFeeNeeded = payTxFee.GetFeePerK();
21972196
// User didn't set: use -txconfirmtarget to estimate...
21982197
if (nFeeNeeded == 0) {
21992198
int estimateFoundTarget = nConfirmTarget;

src/wallet/wallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ extern CAmount maxTxFee;
3535
extern unsigned int nTxConfirmTarget;
3636
extern bool bSpendZeroConfChange;
3737
extern bool fSendFreeTransactions;
38-
extern bool fPayAtLeastCustomFee;
3938

4039
static const unsigned int DEFAULT_KEYPOOL_SIZE = 100;
4140
//! -paytxfee default

0 commit comments

Comments
 (0)