diff --git a/silentdragonlite b/silentdragonlite index 80f0fce..53f6094 100755 Binary files a/silentdragonlite and b/silentdragonlite differ diff --git a/src/controller.cpp b/src/controller.cpp index 0b360b6..62a2bee 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -337,7 +337,7 @@ void Controller::refreshTransactions() { for (auto o: it["outgoing_metadata"].get()) { QString address = QString::fromStdString(o["address"]); - double amount = -1 * o["value"].get() /10000000;// Sent items are -ve + double amount = it["value"].get(); // Sent items are -ve QString memo; if (!o["memo"].is_null()) { @@ -515,7 +515,7 @@ void Controller::refreshhushPrice() { return noConnection(); // TODO: use/render all this data - QUrl cmcURL("ncies=btc%2Cusd%2Ceur&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); + QUrl cmcURL("https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); QNetworkRequest req; req.setUrl(cmcURL); @@ -540,6 +540,7 @@ void Controller::refreshhushPrice() { } qDebug() << "No network errors"; + auto all = reply->readAll(); auto parsed = json::parse(all, nullptr, false); if (parsed.is_discarded()) { @@ -550,20 +551,17 @@ void Controller::refreshhushPrice() { qDebug() << "Parsed JSON"; const json& item = parsed.get(); - const json& hush = item["Hush"].get(); + const json& hush = item["hush"].get(); - if (hush["usd"] >= 0) { + if (hush["usd"] >= 0) { qDebug() << "Found hush key in price json"; // TODO: support BTC/EUR prices as well - QString price = QString::fromStdString(hush["usd"].get()); + //QString price = QString::fromStdString(hush["usd"].get()); qDebug() << "HUSH = $" << QString::number((double)hush["usd"]); Settings::getInstance()->sethushPrice( hush["usd"] ); - - return; - } else { - qDebug() << "No hush key found in JSON! API might be down or we are rate-limited\n"; + } - } catch (const std::exception& e) { + } catch (const std::exception& e) { // If anything at all goes wrong, just set the price to 0 and move on. qDebug() << QString("Caught something nasty: ") << e.what(); } @@ -571,6 +569,7 @@ void Controller::refreshhushPrice() { // If nothing, then set the price to 0; Settings::getInstance()->sethushPrice(0); }); + } void Controller::shutdownhushd() { diff --git a/src/settings.cpp b/src/settings.cpp index ab9a1c6..baea9c1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -214,15 +214,15 @@ void Settings::openTxInExplorer(QString txid) { QDesktopServices::openUrl(QUrl(url)); } -QString Settings::getUSDFormat(double bal) { - return "$" + QLocale(QLocale::English).toString(bal, 'f', 2); -} QString Settings::getUSDFromhushAmount(double bal) { return getUSDFormat(bal * Settings::getInstance()->gethushPrice()); } +QString Settings::getUSDFormat(double bal) { + return "$" + QLocale(QLocale::English).toString(bal * Settings::getInstance()->gethushPrice(), 'f', 2); +} QString Settings::getDecimalString(double amt) { QString f = QString::number(amt, 'f', 8); @@ -242,13 +242,14 @@ QString Settings::gethushDisplayFormat(double bal) { } QString Settings::gethushUSDDisplayFormat(double bal) { - auto usdFormat = getUSDFromhushAmount(bal); + auto usdFormat = getUSDFormat(bal); if (!usdFormat.isEmpty()) - return gethushDisplayFormat(bal) % " (" % usdFormat % ")"; + return gethushDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")"; else return gethushDisplayFormat(bal); } + const QString Settings::txidStatusMessage = QString(QObject::tr("Tx submitted (right click to copy) txid:")); QString Settings::getTokenName() {