diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 34be7b2..ff2db2a 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -304,21 +304,29 @@ void MainWindow::setupStatusBar() { menu.addAction("Copy block explorer link", [=]() { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetTxExplorerUrl + txid; - } else { - url = explorer.txExplorerUrl + txid; - } + url = explorer.txExplorerUrl + txid; + DEBUG("explorer url=" << url); + QGuiApplication::clipboard()->setText(url); + }); + menu.addAction("Copy Tor block explorer link", [=]() { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionTxExplorerUrl + txid; + DEBUG("explorer url=" << url); QGuiApplication::clipboard()->setText(url); }); menu.addAction("View tx on block explorer", [=]() { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetTxExplorerUrl + txid; - } else { - url = explorer.txExplorerUrl + txid; - } + url = explorer.txExplorerUrl + txid; + DEBUG("explorer url=" << url); + QDesktopServices::openUrl(QUrl(url)); + }); + menu.addAction("View tx via Tor block explorer", [=]() { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionTxExplorerUrl + txid; + DEBUG("explorer url=" << url); QDesktopServices::openUrl(QUrl(url)); }); } @@ -504,8 +512,8 @@ void MainWindow::setupSettingsModal() { auto explorer = Settings::getInstance()->getExplorer(); settings.txExplorerUrl->setText(explorer.txExplorerUrl); settings.addressExplorerUrl->setText(explorer.addressExplorerUrl); - settings.testnetTxExplorerUrl->setText(explorer.testnetTxExplorerUrl); - settings.testnetAddressExplorerUrl->setText(explorer.testnetAddressExplorerUrl); + settings.onionTxExplorerUrl->setText(explorer.onionTxExplorerUrl); + settings.onionAddressExplorerUrl->setText(explorer.onionAddressExplorerUrl); // format systems language QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" @@ -656,8 +664,8 @@ void MainWindow::setupSettingsModal() { Settings::getInstance()->saveExplorer( settings.txExplorerUrl->text(), settings.addressExplorerUrl->text(), - settings.testnetTxExplorerUrl->text(), - settings.testnetAddressExplorerUrl->text()); + settings.onionTxExplorerUrl->text(), + settings.onionAddressExplorerUrl->text()); // Check to see if rescan or reindex have been enabled bool showRestartInfo = false; @@ -1393,22 +1401,31 @@ void MainWindow::setupBalancesTab() { menu.addAction(tr("View on block explorer"), [=] () { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetAddressExplorerUrl + addr; - } else { - url = explorer.addressExplorerUrl + addr; - } + url = explorer.addressExplorerUrl + addr; + DEBUG("explorer url=" << url); + QDesktopServices::openUrl(QUrl(url)); + }); + + menu.addAction(tr("View on Tor block explorer"), [=] () { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionAddressExplorerUrl + addr; + DEBUG("explorer url=" << url); QDesktopServices::openUrl(QUrl(url)); }); menu.addAction("Copy explorer link", [=]() { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetAddressExplorerUrl + addr; - } else { - url = explorer.addressExplorerUrl + addr; - } + url = explorer.addressExplorerUrl + addr; + DEBUG("explorer url=" << url); + QGuiApplication::clipboard()->setText(url); + }); + + menu.addAction("Copy Tor explorer link", [=]() { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionAddressExplorerUrl + addr; QGuiApplication::clipboard()->setText(url); }); @@ -1918,22 +1935,32 @@ void MainWindow::setupTransactionsTab() { menu.addAction(tr("View on block explorer"), [=] () { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetTxExplorerUrl + txid; - } else { - url = explorer.txExplorerUrl + txid; - } + url = explorer.txExplorerUrl + txid; + DEBUG("explorer url=" << url); + QDesktopServices::openUrl(QUrl(url)); + }); + + menu.addAction(tr("View on Tor block explorer"), [=] () { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionTxExplorerUrl + txid; + DEBUG("explorer url=" << url); QDesktopServices::openUrl(QUrl(url)); }); menu.addAction(tr("Copy block explorer link"), [=] () { QString url; auto explorer = Settings::getInstance()->getExplorer(); - if (Settings::getInstance()->isTestnet()) { - url = explorer.testnetTxExplorerUrl + txid; - } else { - url = explorer.txExplorerUrl + txid; - } + url = explorer.txExplorerUrl + txid; + DEBUG("explorer url=" << url); + QGuiApplication::clipboard()->setText(url); + }); + + menu.addAction(tr("Copy Tor block explorer link"), [=] () { + QString url; + auto explorer = Settings::getInstance()->getExplorer(); + url = explorer.onionTxExplorerUrl + txid; + DEBUG("explorer url=" << url); QGuiApplication::clipboard()->setText(url); }); diff --git a/src/mainwindow.h b/src/mainwindow.h index 6054578..988c914 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,7 +129,6 @@ private: void telegram(); void reportbug(); void addressBook(); - void postToZBoard(); void importPrivKey(); void exportAllKeys(); void exportKeys(QString addr = ""); diff --git a/src/sd.h b/src/sd.h index 418f9b4..5c5b535 100644 --- a/src/sd.h +++ b/src/sd.h @@ -1,5 +1,5 @@ // Copyright 2019-2023 The Hush Developers // Released under the GPLv3 -#define DEBUG(x) (qDebug() << __func__ << ": " << x) +#define DEBUG(x) (qDebug() << QString(__func__) << ": " << x) diff --git a/src/settings.cpp b/src/settings.cpp index 38947c6..3d8dd11 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2,6 +2,7 @@ // Released under the GPLv3 #include "mainwindow.h" #include "settings.h" +#include "sd.h" extern bool isdragonx; @@ -45,31 +46,35 @@ Explorer Settings::getExplorer() { explorer = "https://explorer.dragonx.is"; } - auto txExplorerUrl = s.value("explorer/txExplorerUrl", explorer + "/tx/").toString(); - auto addressExplorerUrl = s.value("explorer/addressExplorerUrl", explorer + "/address/").toString(); - - auto testnetTxExplorerUrl = s.value("explorer/testnetTxExplorerUrl").toString(); - auto testnetAddressExplorerUrl = s.value("explorer/testnetAddressExplorerUrl").toString(); + QString onionExplorer = "http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion"; + auto txExplorerUrl = s.value("explorer/txExplorerUrl", explorer + "/tx/").toString(); + auto addressExplorerUrl = s.value("explorer/addressExplorerUrl", explorer + "/address/").toString(); + auto onionTxExplorerUrl = s.value("explorer/onionTxExplorerUrl", onionExplorer + "/tx/").toString(); + auto onionAddressExplorerUrl = s.value("explorer/onionAddressExplorerUrl", onionExplorer + "/address/").toString(); // Some users have the old malicious explorer URL saved in their config file, help them out if (txExplorerUrl == "https://explorer.myhush.org/tx/") { txExplorerUrl = explorer + "/tx/"; - saveExplorer(txExplorerUrl, addressExplorerUrl, testnetTxExplorerUrl, testnetAddressExplorerUrl); + saveExplorer(txExplorerUrl, addressExplorerUrl, onionTxExplorerUrl, onionAddressExplorerUrl); } if (addressExplorerUrl == "https://explorer.myhush.org/address/") { addressExplorerUrl = explorer + "/address/"; - saveExplorer(txExplorerUrl, addressExplorerUrl, testnetTxExplorerUrl, testnetAddressExplorerUrl); + saveExplorer(txExplorerUrl, addressExplorerUrl, onionTxExplorerUrl, onionAddressExplorerUrl); } - return Explorer{txExplorerUrl, addressExplorerUrl, testnetTxExplorerUrl, testnetAddressExplorerUrl}; + //DEBUG("explorer values: " << txExplorerUrl << " " << addressExplorerUrl << " " << onionTxExplorerUrl << " " << onionAddressExplorerUrl ); + DEBUG("onionTxExplorerUrl=" % onionTxExplorerUrl); + DEBUG("onionAddressExplorerUrl=" % onionAddressExplorerUrl); + return Explorer{txExplorerUrl, addressExplorerUrl, onionTxExplorerUrl, onionAddressExplorerUrl}; } -void Settings::saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& testnetTxExplorerUrl, const QString& testnetAddressExplorerUrl) { +void Settings::saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& onionTxExplorerUrl, const QString& onionAddressExplorerUrl) { QSettings s; s.setValue("explorer/txExplorerUrl", txExplorerUrl); s.setValue("explorer/addressExplorerUrl", addressExplorerUrl); - s.setValue("explorer/testnetTxExplorerUrl", testnetTxExplorerUrl); - s.setValue("explorer/testnetAddressExplorerUrl", testnetAddressExplorerUrl); + s.setValue("explorer/onionTxExplorerUrl", onionTxExplorerUrl); + s.setValue("explorer/onionAddressExplorerUrl", onionAddressExplorerUrl); + //DEBUG("saving explorer values: " << txExplorerUrl << " " << addressExplorerUrl << " " << onionTxExplorerUrl << " " << onionAddressExplorerUrl ); } Config Settings::getSettings() { diff --git a/src/settings.h b/src/settings.h index cd22b0f..a3b1a74 100644 --- a/src/settings.h +++ b/src/settings.h @@ -15,8 +15,8 @@ struct Config { struct Explorer { QString txExplorerUrl; QString addressExplorerUrl; - QString testnetTxExplorerUrl; - QString testnetAddressExplorerUrl; + QString onionTxExplorerUrl; + QString onionAddressExplorerUrl; }; struct ToFields; @@ -38,7 +38,7 @@ public: static Settings* getInstance(); Explorer getExplorer(); - void saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& testnetTxExplorerUrl, const QString& testnetAddressExplorerUrl); + void saveExplorer(const QString& txExplorerUrl, const QString& addressExplorerUrl, const QString& onionTxExplorerUrl, const QString& onionAddressExplorerUrl); Config getSettings(); void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password); diff --git a/src/settings.ui b/src/settings.ui index 34e2ebd..32eedb9 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -704,10 +704,10 @@ - Testnet Tx Explorer URL + Onion Tx Explorer URL - + 9 @@ -717,7 +717,7 @@ - https://explorer.testnet.z.cash/tx/ + http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion/tx/ @@ -730,10 +730,10 @@ - Testnet Address Explorer URL + Onion Address Explorer URL - + 9 @@ -743,7 +743,7 @@ - https://explorer.testnet.hush.is/address/ + http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion/tx/