From e3d3b7914e2ea21ebbc56a87e4c7fd8f23a87057 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 22 Jun 2019 23:13:30 -0400 Subject: [PATCH] Render USD total, work on feedback and show version/port info in hushd tab --- res/Info.plist | 4 +- src/mainwindow.ui | 108 ++++++++++++++++++++++++++++++++++++++++++++++ src/rpc.cpp | 9 ++++ src/sendtab.cpp | 4 +- src/settings.cpp | 3 +- 5 files changed, 124 insertions(+), 4 deletions(-) diff --git a/res/Info.plist b/res/Info.plist index bf15917..9df118f 100644 --- a/res/Info.plist +++ b/res/Info.plist @@ -29,10 +29,10 @@ CFBundleURLName - zcash URI + hush URI CFBundleURLSchemes - zcash + hush diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 67e9d45..48679d7 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -148,6 +148,47 @@ + + + + + + + + 0 + 0 + + + + + 75 + true + + + + + + + + + + + + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + @@ -1083,6 +1124,73 @@ + + + + Version + + + + + + + Loading... + + + + + + + | + + + + + + + + P2P Port + + + + + + + Loading... + + + + + + + | + + + + + + + + + RPC Port + + + + + + + Loading... + + + + + + + | + + + + diff --git a/src/rpc.cpp b/src/rpc.cpp index d42895a..7812521 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -398,6 +398,7 @@ void RPC::noConnection() { ui->balSheilded->setText(""); ui->balTransparent->setText(""); ui->balTotal->setText(""); + ui->balUSDTotal->setText(""); ui->balSheilded->setToolTip(""); ui->balTransparent->setToolTip(""); @@ -556,6 +557,8 @@ void RPC::getInfoThenRefresh(bool force) { static int lastBlock = 0; int curBlock = reply["blocks"].get(); int version = reply["version"].get(); + int p2pport = reply["p2pport"].get(); + int rpcport = reply["rpcport"].get(); int notarized = reply["notarized"].get(); int protocolversion = reply["protocolversion"].get(); int lag = curBlock - notarized; @@ -568,8 +571,11 @@ void RPC::getInfoThenRefresh(bool force) { ui->notarizedhashvalue->setText( ntzhash ); ui->notarizedtxidvalue->setText( ntztxid ); ui->lagvalue->setText( QString::number(lag) ); + ui->version->setText( QString::number(version) ); ui->kmdversion->setText( kmdver ); ui->protocolversion->setText( QString::number(protocolversion) ); + ui->p2pport->setText( QString::number(p2pport) ); + ui->rpcport->setText( QString::number(rpcport) ); if ( force || (curBlock != lastBlock) ) { // Something changed, so refresh everything. @@ -779,6 +785,9 @@ void RPC::refreshBalances() { ui->balSheilded ->setToolTip(Settings::getUSDFormat(balZ)); ui->balTransparent->setToolTip(Settings::getUSDFormat(balT)); ui->balTotal ->setToolTip(Settings::getUSDFormat(balTotal)); + + ui->balUSDTotal ->setText(Settings::getUSDFormat(balTotal)); + ui->balUSDTotal ->setToolTip(Settings::getUSDFormat(balTotal)); }); // 2. Get the UTXOs diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 0d70be2..6076eeb 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -454,7 +454,7 @@ Tx MainWindow::createTxFromSendPage() { addr = AddressBook::addressFromAddressLabel(addr); // If address is sprout, then we can't send change to sapling, because of turnstile. - sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr); + //sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr); double amt = ui->sendToWidgets->findChild(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble(); totalAmt += amt; @@ -473,6 +473,7 @@ Tx MainWindow::createTxFromSendPage() { if (Settings::getInstance()->getAutoShield() && sendChangeToSapling) { auto saplingAddr = std::find_if(rpc->getAllZAddresses()->begin(), rpc->getAllZAddresses()->end(), [=](auto i) -> bool { // We're finding a sapling address that is not one of the To addresses, because zcash doesn't allow duplicated addresses + // TODO: Should we disable this in Hush? What are the privacy and chain analysis considerations? bool isSapling = Settings::getInstance()->isSaplingAddress(i); if (!isSapling) return false; @@ -685,6 +686,7 @@ void MainWindow::sendButton() { } QString MainWindow::doSendTxValidations(Tx tx) { + //TODO: Feedback fromAddr is empty for some reason if (!Settings::isValidAddress(tx.fromAddr)) return QString(tr("From Address is Invalid")); for (auto toAddr : tx.toAddrs) { diff --git a/src/settings.cpp b/src/settings.cpp index 803870f..b45662d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -270,9 +270,10 @@ QString Settings::getZboardAddr() { } bool Settings::isValidAddress(QString addr) { - QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive); + QRegExp zsexp("^zs1[a-z0-9]{75}$", Qt::CaseInsensitive); QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive); QRegExp texp("^R[a-z0-9]{33}$", Qt::CaseInsensitive); + qDebug() << "isValidAddress(" << addr << ")"; return texp.exactMatch(addr) || ztsexp.exactMatch(addr) || zsexp.exactMatch(addr); }