From 0590d14693e81a843268db402648782d2fdbebda Mon Sep 17 00:00:00 2001 From: DenioD Date: Wed, 30 Oct 2019 15:50:47 +0100 Subject: [PATCH] fix for SDA --- src/camount.cpp | 2 +- src/controller.cpp | 16 ++++++++-------- src/controller.h | 2 +- src/recurring.cpp | 6 +++--- src/settings.cpp | 4 ++-- src/settings.h | 6 +++--- src/websockets.cpp | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/camount.cpp b/src/camount.cpp index 9d85888..9c4b590 100644 --- a/src/camount.cpp +++ b/src/camount.cpp @@ -35,7 +35,7 @@ QString CAmount::toDecimalString() const { QString CAmount::toDecimalUSDString() const { double dblAmount = static_cast(this->amount) / COIN; - double price = Settings::getInstance()->gethushPrice(); + double price = Settings::getInstance()->getZECPrice(); return "$" + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); } diff --git a/src/controller.cpp b/src/controller.cpp index 97ddb37..5b58a15 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -29,7 +29,7 @@ Controller::Controller(MainWindow* main) { priceTimer = new QTimer(main); QObject::connect(priceTimer, &QTimer::timeout, [=]() { if (Settings::getInstance()->getAllowFetchPrices()) - refreshhushPrice(); + refreshZECPrice(); }); priceTimer->start(Settings::priceRefreshSpeed); // Every hour @@ -69,7 +69,7 @@ void Controller::setConnection(Connection* c) { // If we're allowed to get the Hush Price, get the prices if (Settings::getInstance()->getAllowFetchPrices()) - refreshhushPrice(); + refreshZECPrice(); // If we're allowed to check for updates, check for a new release if (Settings::getInstance()->getCheckForUpdates()) @@ -168,7 +168,7 @@ void Controller::getInfoThenRefresh(bool force) { auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump()); QIcon i(":/icons/res/connected.gif"); main->statusLabel->setText(chainName + "(" + QString::number(curBlock) + ")"); - main->statusLabel->setText(" HUSH/USD=$" + QString::number( (double) Settings::getInstance()->gethushPrice() )); + main->statusLabel->setText(" HUSH/USD=$" + QString::number( (double) Settings::getInstance()->getZECPrice() )); main->statusLabel->setToolTip(tooltip); main->statusIcon->setPixmap(i.pixmap(16, 16)); main->statusIcon->setToolTip(tooltip); @@ -537,7 +537,7 @@ void Controller::checkForUpdate(bool silent) { } // Get the hush->USD price from coinmarketcap using their API -void Controller::refreshhushPrice() { +void Controller::refreshZECPrice() { if (!zrpc->haveConnection()) return noConnection(); @@ -562,7 +562,7 @@ void Controller::refreshhushPrice() { } else { qDebug() << reply->errorString(); } - Settings::getInstance()->sethushPrice(0); + Settings::getInstance()->setZECPrice(0); return; } @@ -571,7 +571,7 @@ void Controller::refreshhushPrice() { auto all = reply->readAll(); auto parsed = json::parse(all, nullptr, false); if (parsed.is_discarded()) { - Settings::getInstance()->sethushPrice(0); + Settings::getInstance()->setZECPrice(0); return; } @@ -585,7 +585,7 @@ void Controller::refreshhushPrice() { // TODO: support BTC/EUR prices as well //QString price = QString::fromStdString(hush["usd"].get()); qDebug() << "HUSH = $" << QString::number((double)hush["usd"]); - Settings::getInstance()->sethushPrice( hush["usd"] ); + Settings::getInstance()->setZECPrice( hush["usd"] ); return; } } catch (const std::exception& e) { @@ -594,7 +594,7 @@ void Controller::refreshhushPrice() { } // If nothing, then set the price to 0; - Settings::getInstance()->sethushPrice(0); + Settings::getInstance()->setZECPrice(0); }); } diff --git a/src/controller.h b/src/controller.h index 1286ff4..d9ceceb 100644 --- a/src/controller.h +++ b/src/controller.h @@ -36,7 +36,7 @@ public: void refreshAddresses(); void checkForUpdate(bool silent = true); - void refreshhushPrice(); + void refreshZECPrice(); //void getZboardTopics(std::function)> cb); void executeStandardUITransaction(Tx tx); diff --git a/src/recurring.cpp b/src/recurring.cpp index 57aeb48..5941e52 100644 --- a/src/recurring.cpp +++ b/src/recurring.cpp @@ -205,7 +205,7 @@ void Recurring::updateInfoWithTx(RecurringPaymentInfo* r, Tx tx) { r->fromAddr = tx.fromAddr; if (r->currency.isEmpty() || r->currency == "USD") { r->currency = "USD"; - r->amt = tx.toAddrs[0].amount.toqint64() * Settings::getInstance()->gethushPrice(); + r->amt = tx.toAddrs[0].amount.toqint64() * Settings::getInstance()->getZECPrice(); } else { r->currency = Settings::getTokenName(); @@ -465,7 +465,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r double amount = rpi.amt; if (rpi.currency == "USD") { // If there is no price, then fail the payment - if (Settings::getInstance()->gethushPrice() == 0) { + if (Settings::getInstance()->getZECPrice() == 0) { for (auto paymentNumber: paymentNumbers) { updatePaymentItem(rpi.getHash(), paymentNumber, "", QObject::tr("No hush price was available to convert from USD"), @@ -475,7 +475,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r } // Translate it into hush - amount = rpi.amt / Settings::getInstance()->gethushPrice(); + amount = rpi.amt / Settings::getInstance()->getZECPrice(); } // Build a Tx diff --git a/src/settings.cpp b/src/settings.cpp index bc76852..6b8fa76 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -102,8 +102,8 @@ bool Settings::isSaplingActive() { return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0); } -double Settings::gethushPrice() { - return hushPrice; +double Settings::getZECPrice() { + return ZECPrice; } bool Settings::getCheckForUpdates() { diff --git a/src/settings.h b/src/settings.h index ffd3781..75abd31 100644 --- a/src/settings.h +++ b/src/settings.h @@ -63,8 +63,8 @@ public: bool isSaplingActive(); - void sethushPrice(double p) { hushPrice = p; } - double gethushPrice(); + void setZECPrice(double p) { ZECPrice = p; } + double getZECPrice(); // Static stuff static const QString txidStatusMessage; @@ -116,7 +116,7 @@ private: bool _useEmbedded = false; bool _headless = false; - double hushPrice = 0.0; + double ZECPrice = 0.0; }; #endif // SETTINGS_H diff --git a/src/websockets.cpp b/src/websockets.cpp index d35d959..cd9d5ad 100644 --- a/src/websockets.cpp +++ b/src/websockets.cpp @@ -760,7 +760,7 @@ void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, std {"maxspendable", maxSpendable.toDecimalDouble()}, {"maxzspendable", maxZSpendable.toDecimalDouble()}, {"tokenName", Settings::getTokenName()}, - {"hushprice", Settings::getInstance()->gethushPrice()}, + {"zecprice", Settings::getInstance()->getZECPrice()}, {"serverversion", QString(APP_VERSION)} }).toJson(); pClient->sendTextMessage(encryptOutgoing(r));