Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Automatically set the lowest possible Custom Fee when user provided fee is too low #2215

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/qt/pivx/sendcustomfeedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ void SendCustomFeeDialog::accept()
inform(tr("Fee too high. Must be below: %1").arg(
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), insaneFee)));
} else if (customFee < CWallet::GetRequiredFee(1000)) {
CAmount nFee;
walletModel->getWalletCustomFee(nFee);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to check for the getWalletCustomFee return boolean value or use the hasWalletCustomFee method before getting the wallet custom fee, so in case of having the wallet custom fee disabled (CWallet::fUseCustomFee), the GUI use the minimum required fee and not the stored value.

In other words, something like:

CAmount nFee = 0;
if (walletModel->hasWalletCustomFee()) {
     walletModel->getWalletCustomFee(nFee);
} else {
     nFee = CWallet::GetRequiredFee(1000);
}

Side topic, a future good work on this area would be to encapsulate every CWallet related function call into the wallet model. None of the widgets should have access to the backend related files/classes, only connect to the models.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can merge this PR, and fix this thing in a quick follow-up PR?

As for the side topic... check #2293 :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool for #2293 👌 .
Ok, np. let's merge this one and will do a quick follow-up PR to fix the problem.

Guess that @MishaPozdnikin isn't around anymore.

ui->lineEditCustomFee->setText(BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), nFee));
inform(tr("Fee too low. Must be at least: %1").arg(
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000))));
} else {
Expand Down