From 0832091e4e93e2f8b87e521681549063e0bfa052 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 2 Dec 2019 11:02:54 -0800 Subject: [PATCH] start adding plumbing for a market tab --- README.md | 2 ++ src/mainwindow.cpp | 9 +++++++-- src/mainwindow.h | 3 ++- src/mainwindow.ui | 21 +++++++++++++++++++++ src/rpc.cpp | 7 +++++-- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73e3496..6349bc6 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ This is experimental software under active development! SilentDragon contacts a few different external websites to get various bits of data. + * coingecko.com for price data API * explorer.myhush.org for explorer links * dexstats.info for address utilities + * wormhole.myhush.org for Wormhole services This means your IP address is known to these servers. Enable Tor setting in SilentDragon to prevent this, or better yet, use TAILS: https://tails.boum.org/ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 12793af..c32f44a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -119,7 +119,8 @@ MainWindow::MainWindow(QWidget *parent) : setupTransactionsTab(); setupReceiveTab(); setupBalancesTab(); - setupZcashdTab(); + setupHushTab(); + setupMarketTab(); rpc = new RPC(this); qDebug() << "Created RPC"; @@ -914,10 +915,14 @@ void MainWindow::setupBalancesTab() { }); } -void MainWindow::setupZcashdTab() { +void MainWindow::setupHushTab() { ui->hushlogo->setBasePixmap(QPixmap(":/img/res/zcashdlogo.gif")); } +void MainWindow::setupMarketTab() { + qDebug() << "Setting up market tab"; +} + void MainWindow::setupTransactionsTab() { // Double click opens up memo if one exists QObject::connect(ui->transactionsTable, &QTableView::doubleClicked, [=] (auto index) { diff --git a/src/mainwindow.h b/src/mainwindow.h index ea37011..5228629 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -80,7 +80,8 @@ private: void setupTransactionsTab(); void setupReceiveTab(); void setupBalancesTab(); - void setupZcashdTab(); + void setupHushTab(); + void setupMarketTab(); void slot_change_theme(const QString& themeName); void setupTurnstileDialog(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 4d1245e..7089f99 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -935,6 +935,26 @@ + + + Market + + + + + + + + 0 + + + + + + + + + @@ -1370,6 +1390,7 @@ + diff --git a/src/rpc.cpp b/src/rpc.cpp index 616aca8..2e654fd 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1090,7 +1090,8 @@ void RPC::refreshZECPrice() { 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"); + QString price_feed = "https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur%2Ceth%2Cgbp%2Ccny%2Cjpy%2Crub%2Ccad%2Csgd%2Cchf%2Cinr%2Caud%2Cinr&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"; + QUrl cmcURL(price_feed); QNetworkRequest req; req.setUrl(cmcURL); QNetworkReply *reply = conn->restclient->get(req); @@ -1130,7 +1131,9 @@ void RPC::refreshZECPrice() { // TODO: support BTC/EUR prices as well //QString price = QString::fromStdString(hush["usd"].get()); qDebug() << "HUSH = $" << QString::number((double)hush["usd"]); - qDebug() << "HUSH = " << QString::number((double)hush["btc"]) << " sat "; + qDebug() << "HUSH = " << QString::number((double)hush["eur"]) << " EUR"; + qDebug() << "HUSH = " << QString::number((int) 100000000 * (double) hush["btc"]) << " sat "; + //TODO: based on current fiat selection, store that fiat price Settings::getInstance()->setZECPrice( hush["usd"] ); Settings::getInstance()->setBTCPrice( (unsigned int) 100000000 * (double)hush["btc"] );