Browse Source

fix for SDA

pull/9/head
DenioD 5 years ago
parent
commit
0590d14693
  1. 2
      src/camount.cpp
  2. 16
      src/controller.cpp
  3. 2
      src/controller.h
  4. 6
      src/recurring.cpp
  5. 4
      src/settings.cpp
  6. 6
      src/settings.h
  7. 2
      src/websockets.cpp

2
src/camount.cpp

@ -35,7 +35,7 @@ QString CAmount::toDecimalString() const {
QString CAmount::toDecimalUSDString() const { QString CAmount::toDecimalUSDString() const {
double dblAmount = static_cast<double>(this->amount) / COIN; double dblAmount = static_cast<double>(this->amount) / COIN;
double price = Settings::getInstance()->gethushPrice(); double price = Settings::getInstance()->getZECPrice();
return "$" + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); return "$" + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2);
} }

16
src/controller.cpp

@ -29,7 +29,7 @@ Controller::Controller(MainWindow* main) {
priceTimer = new QTimer(main); priceTimer = new QTimer(main);
QObject::connect(priceTimer, &QTimer::timeout, [=]() { QObject::connect(priceTimer, &QTimer::timeout, [=]() {
if (Settings::getInstance()->getAllowFetchPrices()) if (Settings::getInstance()->getAllowFetchPrices())
refreshhushPrice(); refreshZECPrice();
}); });
priceTimer->start(Settings::priceRefreshSpeed); // Every hour 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 we're allowed to get the Hush Price, get the prices
if (Settings::getInstance()->getAllowFetchPrices()) if (Settings::getInstance()->getAllowFetchPrices())
refreshhushPrice(); refreshZECPrice();
// If we're allowed to check for updates, check for a new release // If we're allowed to check for updates, check for a new release
if (Settings::getInstance()->getCheckForUpdates()) if (Settings::getInstance()->getCheckForUpdates())
@ -168,7 +168,7 @@ void Controller::getInfoThenRefresh(bool force) {
auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump()); auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump());
QIcon i(":/icons/res/connected.gif"); QIcon i(":/icons/res/connected.gif");
main->statusLabel->setText(chainName + "(" + QString::number(curBlock) + ")"); 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->statusLabel->setToolTip(tooltip);
main->statusIcon->setPixmap(i.pixmap(16, 16)); main->statusIcon->setPixmap(i.pixmap(16, 16));
main->statusIcon->setToolTip(tooltip); main->statusIcon->setToolTip(tooltip);
@ -537,7 +537,7 @@ void Controller::checkForUpdate(bool silent) {
} }
// Get the hush->USD price from coinmarketcap using their API // Get the hush->USD price from coinmarketcap using their API
void Controller::refreshhushPrice() { void Controller::refreshZECPrice() {
if (!zrpc->haveConnection()) if (!zrpc->haveConnection())
return noConnection(); return noConnection();
@ -562,7 +562,7 @@ void Controller::refreshhushPrice() {
} else { } else {
qDebug() << reply->errorString(); qDebug() << reply->errorString();
} }
Settings::getInstance()->sethushPrice(0); Settings::getInstance()->setZECPrice(0);
return; return;
} }
@ -571,7 +571,7 @@ void Controller::refreshhushPrice() {
auto all = reply->readAll(); auto all = reply->readAll();
auto parsed = json::parse(all, nullptr, false); auto parsed = json::parse(all, nullptr, false);
if (parsed.is_discarded()) { if (parsed.is_discarded()) {
Settings::getInstance()->sethushPrice(0); Settings::getInstance()->setZECPrice(0);
return; return;
} }
@ -585,7 +585,7 @@ void Controller::refreshhushPrice() {
// TODO: support BTC/EUR prices as well // TODO: support BTC/EUR prices as well
//QString price = QString::fromStdString(hush["usd"].get<json::string_t>()); //QString price = QString::fromStdString(hush["usd"].get<json::string_t>());
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]); qDebug() << "HUSH = $" << QString::number((double)hush["usd"]);
Settings::getInstance()->sethushPrice( hush["usd"] ); Settings::getInstance()->setZECPrice( hush["usd"] );
return; return;
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
@ -594,7 +594,7 @@ void Controller::refreshhushPrice() {
} }
// If nothing, then set the price to 0; // If nothing, then set the price to 0;
Settings::getInstance()->sethushPrice(0); Settings::getInstance()->setZECPrice(0);
}); });
} }

2
src/controller.h

@ -36,7 +36,7 @@ public:
void refreshAddresses(); void refreshAddresses();
void checkForUpdate(bool silent = true); void checkForUpdate(bool silent = true);
void refreshhushPrice(); void refreshZECPrice();
//void getZboardTopics(std::function<void(QMap<QString, QString>)> cb); //void getZboardTopics(std::function<void(QMap<QString, QString>)> cb);
void executeStandardUITransaction(Tx tx); void executeStandardUITransaction(Tx tx);

6
src/recurring.cpp

@ -205,7 +205,7 @@ void Recurring::updateInfoWithTx(RecurringPaymentInfo* r, Tx tx) {
r->fromAddr = tx.fromAddr; r->fromAddr = tx.fromAddr;
if (r->currency.isEmpty() || r->currency == "USD") { if (r->currency.isEmpty() || r->currency == "USD") {
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 { else {
r->currency = Settings::getTokenName(); r->currency = Settings::getTokenName();
@ -465,7 +465,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r
double amount = rpi.amt; double amount = rpi.amt;
if (rpi.currency == "USD") { if (rpi.currency == "USD") {
// If there is no price, then fail the payment // If there is no price, then fail the payment
if (Settings::getInstance()->gethushPrice() == 0) { if (Settings::getInstance()->getZECPrice() == 0) {
for (auto paymentNumber: paymentNumbers) { for (auto paymentNumber: paymentNumbers) {
updatePaymentItem(rpi.getHash(), paymentNumber, updatePaymentItem(rpi.getHash(), paymentNumber,
"", QObject::tr("No hush price was available to convert from USD"), "", 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 // Translate it into hush
amount = rpi.amt / Settings::getInstance()->gethushPrice(); amount = rpi.amt / Settings::getInstance()->getZECPrice();
} }
// Build a Tx // Build a Tx

4
src/settings.cpp

@ -102,8 +102,8 @@ bool Settings::isSaplingActive() {
return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0); return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0);
} }
double Settings::gethushPrice() { double Settings::getZECPrice() {
return hushPrice; return ZECPrice;
} }
bool Settings::getCheckForUpdates() { bool Settings::getCheckForUpdates() {

6
src/settings.h

@ -63,8 +63,8 @@ public:
bool isSaplingActive(); bool isSaplingActive();
void sethushPrice(double p) { hushPrice = p; } void setZECPrice(double p) { ZECPrice = p; }
double gethushPrice(); double getZECPrice();
// Static stuff // Static stuff
static const QString txidStatusMessage; static const QString txidStatusMessage;
@ -116,7 +116,7 @@ private:
bool _useEmbedded = false; bool _useEmbedded = false;
bool _headless = false; bool _headless = false;
double hushPrice = 0.0; double ZECPrice = 0.0;
}; };
#endif // SETTINGS_H #endif // SETTINGS_H

2
src/websockets.cpp

@ -760,7 +760,7 @@ void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, std
{"maxspendable", maxSpendable.toDecimalDouble()}, {"maxspendable", maxSpendable.toDecimalDouble()},
{"maxzspendable", maxZSpendable.toDecimalDouble()}, {"maxzspendable", maxZSpendable.toDecimalDouble()},
{"tokenName", Settings::getTokenName()}, {"tokenName", Settings::getTokenName()},
{"hushprice", Settings::getInstance()->gethushPrice()}, {"zecprice", Settings::getInstance()->getZECPrice()},
{"serverversion", QString(APP_VERSION)} {"serverversion", QString(APP_VERSION)}
}).toJson(); }).toJson();
pClient->sendTextMessage(encryptOutgoing(r)); pClient->sendTextMessage(encryptOutgoing(r));

Loading…
Cancel
Save