Skip to content

Commit 1e73c05

Browse files
mxaddictalex v
authored andcommitted
Added clearer error messages for the nRequest amount validation (#609)
* Added clearer error messages for the nRequest amount validation * Added fix for tr calls
1 parent 828cef0 commit 1e73c05

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/qt/communityfundcreatepaymentrequestdialog.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <QMessageBox>
77
#include <string>
88

9+
#include <qt/navcoinunits.h>
10+
911
#include <base58.h>
1012
#include <consensus/cfund.h>
1113
#include <qt/guiconstants.h>
@@ -192,11 +194,18 @@ void CommunityFundCreatePaymentRequestDialog::click_pushButtonSubmitPaymentReque
192194
// Validate requested amount
193195
if (nReqAmount <= 0 || nReqAmount > proposal.GetAvailable(*pcoinsTip, true)) {
194196
QMessageBox msgBox(this);
195-
std::string str = "Cannot create a Payment Request for the requested amount\n";
196-
msgBox.setText(tr(str.c_str()));
197+
QString str = tr("Requested amount must be greater than 0 NAV (Zero)\n");
198+
if (nReqAmount > proposal.GetAvailable(*pcoinsTip, true)) {
199+
str = tr("Requested amount %1 is more than avaible coins in the proposal (%2)\n")
200+
.arg(
201+
NavCoinUnits::formatWithUnit(NavCoinUnits::NAV, nReqAmount),
202+
NavCoinUnits::formatWithUnit(NavCoinUnits::NAV, proposal.GetAvailable(*pcoinsTip, true))
203+
);
204+
}
205+
msgBox.setText(str);
197206
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
198207
msgBox.setIcon(QMessageBox::Warning);
199-
msgBox.setWindowTitle("Invalid Amount");
208+
msgBox.setWindowTitle(tr("Invalid Amount"));
200209
msgBox.exec();
201210
return;
202211
}

0 commit comments

Comments
 (0)