more branding, some fixes
This commit is contained in:
@@ -508,11 +508,12 @@ void Controller::refreshhushPrice() {
|
||||
if (!zrpc->haveConnection())
|
||||
return noConnection();
|
||||
|
||||
// TODO: use/render all this data
|
||||
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);
|
||||
|
||||
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this->main);
|
||||
QNetworkReply *reply = manager->get(req);
|
||||
|
||||
@@ -524,34 +525,41 @@ void Controller::refreshhushPrice() {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
||||
if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) {
|
||||
qDebug() << QString::fromStdString(parsed["error"]["message"]);
|
||||
qDebug() << QString::fromStdString(parsed["error"]["message"]);
|
||||
} else {
|
||||
qDebug() << reply->errorString();
|
||||
}
|
||||
Settings::getInstance()->sethushPrice(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "No network errors";
|
||||
auto all = reply->readAll();
|
||||
|
||||
auto parsed = json::parse(all, nullptr, false);
|
||||
if (parsed.is_discarded()) {
|
||||
Settings::getInstance()->sethushPrice(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const json& item : parsed.get<json::array_t>()) {
|
||||
if (item["symbol"].get<json::string_t>() == Settings::getTokenName().toStdString()) {
|
||||
QString price = QString::fromStdString(item["price_usd"].get<json::string_t>());
|
||||
qDebug() << Settings::getTokenName() << " Price=" << price;
|
||||
Settings::getInstance()->sethushPrice(price.toDouble());
|
||||
qDebug() << "Parsed JSON";
|
||||
|
||||
return;
|
||||
}
|
||||
const json& item = parsed.get<json::object_t>();
|
||||
const json& hush = item["hush"].get<json::object_t>();
|
||||
|
||||
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<json::string_t>());
|
||||
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 (...) {
|
||||
} 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");
|
||||
qDebug() << QString("Caught something nasty: ") << e.what();
|
||||
}
|
||||
|
||||
// If nothing, then set the price to 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ void LiteInterface::createNewZaddr(bool, const std::function<void(json)>& cb) {
|
||||
if (conn == nullptr)
|
||||
return;
|
||||
|
||||
conn->doRPCWithDefaultErrorHandling("new", "zs", cb);
|
||||
conn->doRPCWithDefaultErrorHandling("new", "zs1", cb);
|
||||
}
|
||||
|
||||
void LiteInterface::createNewTaddr(const std::function<void(json)>& cb) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@@ -935,7 +935,7 @@
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>You are currently not mining</string>
|
||||
<string>This is a Lightwallet, you cant mine with it!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -953,7 +953,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="numconnections">
|
||||
<widget class="QLabel" name="version">
|
||||
<property name="text">
|
||||
<string>Loading...</string>
|
||||
</property>
|
||||
@@ -962,12 +962,12 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="heightLabel">
|
||||
<property name="text">
|
||||
<string>Block height</string>
|
||||
<string>Blockheight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="solrate">
|
||||
<widget class="QLabel" name="Vendor">
|
||||
<property name="text">
|
||||
<string>Loading...</string>
|
||||
</property>
|
||||
@@ -976,19 +976,19 @@
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Network solution rate</string>
|
||||
<string>Version hushd light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Connections</string>
|
||||
<string>Vendor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="blockheight">
|
||||
<widget class="QLabel" name="blockHeight">
|
||||
<property name="text">
|
||||
<string>Loading...</string>
|
||||
</property>
|
||||
@@ -1122,17 +1122,17 @@
|
||||
<property name="text">
|
||||
<string>&Send Duke Feedback</string>
|
||||
</property>
|
||||
</action>
|
||||
</action>
|
||||
<action name="actionDiscord">
|
||||
<property name="text">
|
||||
<string>&Hush Discord</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWebsite">
|
||||
</action>
|
||||
<action name="actionWebsite">
|
||||
<property name="text">
|
||||
<string>&Hush Website</string>
|
||||
</property>
|
||||
</action>
|
||||
</action>
|
||||
<action name="actionCheck_for_Updates">
|
||||
<property name="text">
|
||||
<string>Check github.com for &updates</string>
|
||||
|
||||
Reference in New Issue
Block a user