#36 - Format decimals properly
This commit is contained in:
@@ -567,24 +567,13 @@ void MainWindow::sendButton() {
|
||||
}
|
||||
|
||||
QString MainWindow::doSendTxValidations(Tx tx) {
|
||||
// 1. Addresses have valid format.
|
||||
QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive);
|
||||
QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive);
|
||||
QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive);
|
||||
QRegExp texp("^t[a-z0-9]{34}$", Qt::CaseInsensitive);
|
||||
|
||||
auto matchesAnyAddr = [&] (QString addr) {
|
||||
return zcexp.exactMatch(addr) ||
|
||||
texp.exactMatch(addr) ||
|
||||
ztsexp.exactMatch(addr) ||
|
||||
zsexp.exactMatch(addr);
|
||||
};
|
||||
|
||||
if (!matchesAnyAddr(tx.fromAddr)) return QString("From Address is Invalid");
|
||||
if (!Settings::isValidAddress(tx.fromAddr)) return QString("From Address is Invalid");
|
||||
|
||||
for (auto toAddr : tx.toAddrs) {
|
||||
if (!matchesAnyAddr(toAddr.addr))
|
||||
return QString("Recipient Address ") % toAddr.addr.left(100) % " is Invalid";
|
||||
if (!Settings::isValidAddress(toAddr.addr)) {
|
||||
QString addr = (toAddr.addr.length() > 100 ? toAddr.addr.left(100) + "..." : toAddr.addr);
|
||||
return QString("Recipient Address ") % addr % " is Invalid";
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
||||
@@ -110,7 +110,13 @@ QString Settings::getUSDFormat(double bal) {
|
||||
}
|
||||
|
||||
QString Settings::getZECDisplayFormat(double bal) {
|
||||
return QString::number(bal, 'g', 8) % " " % Settings::getTokenName();
|
||||
// This is idiotic. Why doesn't QString have a way to do this?
|
||||
QString f = QString::number(bal, 'f', 8);
|
||||
while (f.contains(".") && (f.right(1) == "0" || f.right(1) == ".")) {
|
||||
f = f.left(f.length() - 1);
|
||||
}
|
||||
|
||||
return f % " " % Settings::getTokenName();
|
||||
}
|
||||
|
||||
QString Settings::getZECUSDDisplayFormat(double bal) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
static QString getZboardAddr();
|
||||
static double getDevFee();
|
||||
static double getTotalFee();
|
||||
|
||||
|
||||
static bool isValidAddress(QString addr);
|
||||
|
||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
private:
|
||||
// This class can only be accessed through Settings::getInstance()
|
||||
Settings() = default;
|
||||
~Settings();
|
||||
~Settings() = default;
|
||||
|
||||
static Settings* instance;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user