fix for SDA
This commit is contained in:
@@ -35,7 +35,7 @@ QString CAmount::toDecimalString() const {
|
||||
|
||||
QString CAmount::toDecimalUSDString() const {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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<json::string_t>());
|
||||
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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void refreshAddresses();
|
||||
|
||||
void checkForUpdate(bool silent = true);
|
||||
void refreshhushPrice();
|
||||
void refreshZECPrice();
|
||||
//void getZboardTopics(std::function<void(QMap<QString, QString>)> cb);
|
||||
|
||||
void executeStandardUITransaction(Tx tx);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user