#36 - Format decimals properly
This commit is contained in:
@@ -567,24 +567,13 @@ void MainWindow::sendButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString MainWindow::doSendTxValidations(Tx tx) {
|
QString MainWindow::doSendTxValidations(Tx tx) {
|
||||||
// 1. Addresses have valid format.
|
if (!Settings::isValidAddress(tx.fromAddr)) return QString("From Address is Invalid");
|
||||||
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");
|
|
||||||
|
|
||||||
for (auto toAddr : tx.toAddrs) {
|
for (auto toAddr : tx.toAddrs) {
|
||||||
if (!matchesAnyAddr(toAddr.addr))
|
if (!Settings::isValidAddress(toAddr.addr)) {
|
||||||
return QString("Recipient Address ") % toAddr.addr.left(100) % " is Invalid";
|
QString addr = (toAddr.addr.length() > 100 ? toAddr.addr.left(100) + "..." : toAddr.addr);
|
||||||
|
return QString("Recipient Address ") % addr % " is Invalid";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
|
|||||||
@@ -110,7 +110,13 @@ QString Settings::getUSDFormat(double bal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getZECDisplayFormat(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) {
|
QString Settings::getZECUSDDisplayFormat(double bal) {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// This class can only be accessed through Settings::getInstance()
|
// This class can only be accessed through Settings::getInstance()
|
||||||
Settings() = default;
|
Settings() = default;
|
||||||
~Settings();
|
~Settings() = default;
|
||||||
|
|
||||||
static Settings* instance;
|
static Settings* instance;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user