HUSHPrice
This commit is contained in:
@@ -43,7 +43,7 @@ double CAmount::getDblAmount() const
|
|||||||
|
|
||||||
QString CAmount::toDecimalUSDString() const
|
QString CAmount::toDecimalUSDString() const
|
||||||
{
|
{
|
||||||
double price = Settings::getInstance()->getZECPrice();
|
double price = Settings::getInstance()->getHUSHPrice();
|
||||||
return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2);
|
return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,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())
|
||||||
refreshZECPrice();
|
refreshHUSHPrice();
|
||||||
|
|
||||||
});
|
});
|
||||||
priceTimer->start(Settings::priceRefreshSpeed); // Every 5 Min
|
priceTimer->start(Settings::priceRefreshSpeed); // Every 5 Min
|
||||||
@@ -89,7 +89,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()) {
|
||||||
refreshZECPrice();
|
refreshHUSHPrice();
|
||||||
supplyUpdate();
|
supplyUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ void Controller::getInfoThenRefresh(bool force)
|
|||||||
|
|
||||||
if (Settings::getInstance()->get_currency_name() == "USD")
|
if (Settings::getInstance()->get_currency_name() == "USD")
|
||||||
{
|
{
|
||||||
double price = Settings::getInstance()->getZECPrice();
|
double price = Settings::getInstance()->getHUSHPrice();
|
||||||
double volume = Settings::getInstance()->getUSDVolume();
|
double volume = Settings::getInstance()->getUSDVolume();
|
||||||
double cap = Settings::getInstance()->getUSDCAP();
|
double cap = Settings::getInstance()->getUSDCAP();
|
||||||
main->statusLabel->setText(
|
main->statusLabel->setText(
|
||||||
@@ -546,7 +546,7 @@ void Controller::getInfoThenRefresh(bool force)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
main->statusLabel->setText(
|
main->statusLabel->setText(
|
||||||
" HUSH/USD=$" + QString::number(Settings::getInstance()->getZECPrice(),'f',2 )
|
" HUSH/USD=$" + QString::number(Settings::getInstance()->getHUSHPrice(),'f',2 )
|
||||||
);
|
);
|
||||||
ui->volumeExchange->setText(
|
ui->volumeExchange->setText(
|
||||||
" $ " + QString::number((double) Settings::getInstance()->getUSDVolume() ,'f',2)
|
" $ " + QString::number((double) Settings::getInstance()->getUSDVolume() ,'f',2)
|
||||||
@@ -1626,7 +1626,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::refreshZECPrice()
|
void Controller::refreshHUSHPrice()
|
||||||
{
|
{
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
@@ -1652,7 +1652,7 @@ void Controller::refreshZECPrice()
|
|||||||
else
|
else
|
||||||
qDebug() << reply->errorString();
|
qDebug() << reply->errorString();
|
||||||
|
|
||||||
Settings::getInstance()->setZECPrice(0);
|
Settings::getInstance()->setHUSHPrice(0);
|
||||||
Settings::getInstance()->setEURPrice(0);
|
Settings::getInstance()->setEURPrice(0);
|
||||||
Settings::getInstance()->setBTCPrice(0);
|
Settings::getInstance()->setBTCPrice(0);
|
||||||
Settings::getInstance()->setCNYPrice(0);
|
Settings::getInstance()->setCNYPrice(0);
|
||||||
@@ -1693,7 +1693,7 @@ void Controller::refreshZECPrice()
|
|||||||
auto parsed = json::parse(all, nullptr, false);
|
auto parsed = json::parse(all, nullptr, false);
|
||||||
if (parsed.is_discarded())
|
if (parsed.is_discarded())
|
||||||
{
|
{
|
||||||
Settings::getInstance()->setZECPrice(0);
|
Settings::getInstance()->setHUSHPrice(0);
|
||||||
Settings::getInstance()->setEURPrice(0);
|
Settings::getInstance()->setEURPrice(0);
|
||||||
Settings::getInstance()->setBTCPrice(0);
|
Settings::getInstance()->setBTCPrice(0);
|
||||||
Settings::getInstance()->setCNYPrice(0);
|
Settings::getInstance()->setCNYPrice(0);
|
||||||
@@ -1736,7 +1736,7 @@ void Controller::refreshZECPrice()
|
|||||||
{
|
{
|
||||||
qDebug() << "Found hush key in price json";
|
qDebug() << "Found hush key in price json";
|
||||||
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]);
|
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]);
|
||||||
Settings::getInstance()->setZECPrice( hush["usd"] );
|
Settings::getInstance()->setHUSHPrice( hush["usd"] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hush["eur"] >= 0)
|
if (hush["eur"] >= 0)
|
||||||
@@ -1940,7 +1940,7 @@ void Controller::refreshZECPrice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If nothing, then set the price to 0;
|
// If nothing, then set the price to 0;
|
||||||
Settings::getInstance()->setZECPrice(0);
|
Settings::getInstance()->setHUSHPrice(0);
|
||||||
Settings::getInstance()->setEURPrice(0);
|
Settings::getInstance()->setEURPrice(0);
|
||||||
Settings::getInstance()->setBTCPrice(0);
|
Settings::getInstance()->setBTCPrice(0);
|
||||||
Settings::getInstance()->setCNYPrice(0);
|
Settings::getInstance()->setCNYPrice(0);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
int _lag;
|
int _lag;
|
||||||
|
|
||||||
void checkForUpdate(bool silent = true);
|
void checkForUpdate(bool silent = true);
|
||||||
void refreshZECPrice();
|
void refreshHUSHPrice();
|
||||||
void refreshEURPrice();
|
void refreshEURPrice();
|
||||||
void refreshBTCPrice();
|
void refreshBTCPrice();
|
||||||
void refreshCNYPrice();
|
void refreshCNYPrice();
|
||||||
|
|||||||
@@ -279,7 +279,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()->getZECPrice();
|
r->amt = tx.toAddrs[0].amount.toqint64() * Settings::getInstance()->getHUSHPrice();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r->currency = Settings::getTokenName();
|
r->currency = Settings::getTokenName();
|
||||||
@@ -547,7 +547,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()->getZECPrice() == 0) {
|
if (Settings::getInstance()->getHUSHPrice() == 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"),
|
||||||
@@ -559,7 +559,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Translate it into hush
|
// Translate it into hush
|
||||||
amount = rpi.amt / Settings::getInstance()->getZECPrice();
|
amount = rpi.amt / Settings::getInstance()->getHUSHPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a Tx
|
// Build a Tx
|
||||||
|
|||||||
@@ -144,8 +144,8 @@ bool Settings::isSaplingActive() {
|
|||||||
return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0);
|
return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Settings::getZECPrice() {
|
double Settings::getHUSHPrice() {
|
||||||
return ZECPrice;
|
return HUSHPrice;
|
||||||
}
|
}
|
||||||
double Settings::getEURPrice() {
|
double Settings::getEURPrice() {
|
||||||
return EURPrice;
|
return EURPrice;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
bool isSaplingActive();
|
bool isSaplingActive();
|
||||||
|
|
||||||
void setZECPrice(double p) { ZECPrice = p; }
|
void setHUSHPrice(double p) { HUSHPrice = p; }
|
||||||
void setEURPrice(double p) { EURPrice = p; }
|
void setEURPrice(double p) { EURPrice = p; }
|
||||||
void setBTCPrice(double p) { BTCPrice = p; }
|
void setBTCPrice(double p) { BTCPrice = p; }
|
||||||
void setCNYPrice(double p) { CNYPrice = p; }
|
void setCNYPrice(double p) { CNYPrice = p; }
|
||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
void setINRCAP(double p) { INRCAP = p; }
|
void setINRCAP(double p) { INRCAP = p; }
|
||||||
void setGBPCAP(double p) { GBPCAP = p; }
|
void setGBPCAP(double p) { GBPCAP = p; }
|
||||||
void setAUDCAP(double p) { AUDCAP = p; }
|
void setAUDCAP(double p) { AUDCAP = p; }
|
||||||
double getZECPrice();
|
double getHUSHPrice();
|
||||||
double getEURPrice();
|
double getEURPrice();
|
||||||
double getBTCPrice();
|
double getBTCPrice();
|
||||||
double getCNYPrice();
|
double getCNYPrice();
|
||||||
@@ -195,7 +195,7 @@ private:
|
|||||||
bool _useEmbedded = false;
|
bool _useEmbedded = false;
|
||||||
bool _headless = false;
|
bool _headless = false;
|
||||||
|
|
||||||
double ZECPrice = 0.0;
|
double HUSHPrice = 0.0;
|
||||||
double BTCPrice = 0.0;
|
double BTCPrice = 0.0;
|
||||||
double EURPrice = 0.0;
|
double EURPrice = 0.0;
|
||||||
double CNYPrice = 0.0;
|
double CNYPrice = 0.0;
|
||||||
|
|||||||
@@ -904,7 +904,10 @@ 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()},
|
||||||
{"zecprice", Settings::getInstance()->getZECPrice()},
|
// changing this to hushprice is a backward incompatible change that requires
|
||||||
|
// changing SDL, litewalletd and SDA in unison, and would break older clients
|
||||||
|
// so we just leave it for now
|
||||||
|
{"zecprice", Settings::getInstance()->getHUSHPrice()},
|
||||||
{"serverversion", QString(APP_VERSION)}
|
{"serverversion", QString(APP_VERSION)}
|
||||||
}).toJson();
|
}).toJson();
|
||||||
pClient->sendTextMessage(encryptOutgoing(r));
|
pClient->sendTextMessage(encryptOutgoing(r));
|
||||||
|
|||||||
Reference in New Issue
Block a user