Browse Source

Integrate Tor explorer

custom_themes
Duke 1 year ago
parent
commit
dca66b70ed
  1. 95
      src/mainwindow.cpp
  2. 1
      src/mainwindow.h
  3. 2
      src/sd.h
  4. 27
      src/settings.cpp
  5. 6
      src/settings.h
  6. 12
      src/settings.ui

95
src/mainwindow.cpp

@ -304,21 +304,29 @@ void MainWindow::setupStatusBar() {
menu.addAction("Copy block explorer link", [=]() { menu.addAction("Copy block explorer link", [=]() {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.txExplorerUrl + txid;
url = explorer.testnetTxExplorerUrl + txid; DEBUG("explorer url=" << url);
} else { QGuiApplication::clipboard()->setText(url);
url = explorer.txExplorerUrl + txid; });
} 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); QGuiApplication::clipboard()->setText(url);
}); });
menu.addAction("View tx on block explorer", [=]() { menu.addAction("View tx on block explorer", [=]() {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.txExplorerUrl + txid;
url = explorer.testnetTxExplorerUrl + txid; DEBUG("explorer url=" << url);
} else { QDesktopServices::openUrl(QUrl(url));
url = explorer.txExplorerUrl + txid; });
} 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)); QDesktopServices::openUrl(QUrl(url));
}); });
} }
@ -504,8 +512,8 @@ void MainWindow::setupSettingsModal() {
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
settings.txExplorerUrl->setText(explorer.txExplorerUrl); settings.txExplorerUrl->setText(explorer.txExplorerUrl);
settings.addressExplorerUrl->setText(explorer.addressExplorerUrl); settings.addressExplorerUrl->setText(explorer.addressExplorerUrl);
settings.testnetTxExplorerUrl->setText(explorer.testnetTxExplorerUrl); settings.onionTxExplorerUrl->setText(explorer.onionTxExplorerUrl);
settings.testnetAddressExplorerUrl->setText(explorer.testnetAddressExplorerUrl); settings.onionAddressExplorerUrl->setText(explorer.onionAddressExplorerUrl);
// format systems language // format systems language
QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" QString defaultLocale = QLocale::system().name(); // e.g. "de_DE"
@ -656,8 +664,8 @@ void MainWindow::setupSettingsModal() {
Settings::getInstance()->saveExplorer( Settings::getInstance()->saveExplorer(
settings.txExplorerUrl->text(), settings.txExplorerUrl->text(),
settings.addressExplorerUrl->text(), settings.addressExplorerUrl->text(),
settings.testnetTxExplorerUrl->text(), settings.onionTxExplorerUrl->text(),
settings.testnetAddressExplorerUrl->text()); settings.onionAddressExplorerUrl->text());
// Check to see if rescan or reindex have been enabled // Check to see if rescan or reindex have been enabled
bool showRestartInfo = false; bool showRestartInfo = false;
@ -1393,22 +1401,31 @@ void MainWindow::setupBalancesTab() {
menu.addAction(tr("View on block explorer"), [=] () { menu.addAction(tr("View on block explorer"), [=] () {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.addressExplorerUrl + addr;
url = explorer.testnetAddressExplorerUrl + addr; DEBUG("explorer url=" << url);
} else { QDesktopServices::openUrl(QUrl(url));
url = explorer.addressExplorerUrl + addr; });
}
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)); QDesktopServices::openUrl(QUrl(url));
}); });
menu.addAction("Copy explorer link", [=]() { menu.addAction("Copy explorer link", [=]() {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.addressExplorerUrl + addr;
url = explorer.testnetAddressExplorerUrl + addr; DEBUG("explorer url=" << url);
} else { QGuiApplication::clipboard()->setText(url);
url = explorer.addressExplorerUrl + addr; });
}
menu.addAction("Copy Tor explorer link", [=]() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
url = explorer.onionAddressExplorerUrl + addr;
QGuiApplication::clipboard()->setText(url); QGuiApplication::clipboard()->setText(url);
}); });
@ -1918,22 +1935,32 @@ void MainWindow::setupTransactionsTab() {
menu.addAction(tr("View on block explorer"), [=] () { menu.addAction(tr("View on block explorer"), [=] () {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.txExplorerUrl + txid;
url = explorer.testnetTxExplorerUrl + txid; DEBUG("explorer url=" << url);
} else { QDesktopServices::openUrl(QUrl(url));
url = explorer.txExplorerUrl + txid; });
}
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)); QDesktopServices::openUrl(QUrl(url));
}); });
menu.addAction(tr("Copy block explorer link"), [=] () { menu.addAction(tr("Copy block explorer link"), [=] () {
QString url; QString url;
auto explorer = Settings::getInstance()->getExplorer(); auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) { url = explorer.txExplorerUrl + txid;
url = explorer.testnetTxExplorerUrl + txid; DEBUG("explorer url=" << url);
} else { QGuiApplication::clipboard()->setText(url);
url = explorer.txExplorerUrl + txid; });
}
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); QGuiApplication::clipboard()->setText(url);
}); });

1
src/mainwindow.h

@ -129,7 +129,6 @@ private:
void telegram(); void telegram();
void reportbug(); void reportbug();
void addressBook(); void addressBook();
void postToZBoard();
void importPrivKey(); void importPrivKey();
void exportAllKeys(); void exportAllKeys();
void exportKeys(QString addr = ""); void exportKeys(QString addr = "");

2
src/sd.h

@ -1,5 +1,5 @@
// Copyright 2019-2023 The Hush Developers // Copyright 2019-2023 The Hush Developers
// Released under the GPLv3 // Released under the GPLv3
#define DEBUG(x) (qDebug() << __func__ << ": " << x) #define DEBUG(x) (qDebug() << QString(__func__) << ": " << x)

27
src/settings.cpp

@ -2,6 +2,7 @@
// Released under the GPLv3 // Released under the GPLv3
#include "mainwindow.h" #include "mainwindow.h"
#include "settings.h" #include "settings.h"
#include "sd.h"
extern bool isdragonx; extern bool isdragonx;
@ -45,31 +46,35 @@ Explorer Settings::getExplorer() {
explorer = "https://explorer.dragonx.is"; explorer = "https://explorer.dragonx.is";
} }
auto txExplorerUrl = s.value("explorer/txExplorerUrl", explorer + "/tx/").toString(); QString onionExplorer = "http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion";
auto addressExplorerUrl = s.value("explorer/addressExplorerUrl", explorer + "/address/").toString(); 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 onionTxExplorerUrl = s.value("explorer/onionTxExplorerUrl", onionExplorer + "/tx/").toString();
auto testnetAddressExplorerUrl = s.value("explorer/testnetAddressExplorerUrl").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 // Some users have the old malicious explorer URL saved in their config file, help them out
if (txExplorerUrl == "https://explorer.myhush.org/tx/") { if (txExplorerUrl == "https://explorer.myhush.org/tx/") {
txExplorerUrl = explorer + "/tx/"; txExplorerUrl = explorer + "/tx/";
saveExplorer(txExplorerUrl, addressExplorerUrl, testnetTxExplorerUrl, testnetAddressExplorerUrl); saveExplorer(txExplorerUrl, addressExplorerUrl, onionTxExplorerUrl, onionAddressExplorerUrl);
} }
if (addressExplorerUrl == "https://explorer.myhush.org/address/") { if (addressExplorerUrl == "https://explorer.myhush.org/address/") {
addressExplorerUrl = explorer + "/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; QSettings s;
s.setValue("explorer/txExplorerUrl", txExplorerUrl); s.setValue("explorer/txExplorerUrl", txExplorerUrl);
s.setValue("explorer/addressExplorerUrl", addressExplorerUrl); s.setValue("explorer/addressExplorerUrl", addressExplorerUrl);
s.setValue("explorer/testnetTxExplorerUrl", testnetTxExplorerUrl); s.setValue("explorer/onionTxExplorerUrl", onionTxExplorerUrl);
s.setValue("explorer/testnetAddressExplorerUrl", testnetAddressExplorerUrl); s.setValue("explorer/onionAddressExplorerUrl", onionAddressExplorerUrl);
//DEBUG("saving explorer values: " << txExplorerUrl << " " << addressExplorerUrl << " " << onionTxExplorerUrl << " " << onionAddressExplorerUrl );
} }
Config Settings::getSettings() { Config Settings::getSettings() {

6
src/settings.h

@ -15,8 +15,8 @@ struct Config {
struct Explorer { struct Explorer {
QString txExplorerUrl; QString txExplorerUrl;
QString addressExplorerUrl; QString addressExplorerUrl;
QString testnetTxExplorerUrl; QString onionTxExplorerUrl;
QString testnetAddressExplorerUrl; QString onionAddressExplorerUrl;
}; };
struct ToFields; struct ToFields;
@ -38,7 +38,7 @@ public:
static Settings* getInstance(); static Settings* getInstance();
Explorer getExplorer(); 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(); Config getSettings();
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password); void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);

12
src/settings.ui

@ -704,10 +704,10 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Testnet Tx Explorer URL</string> <string>Onion Tx Explorer URL</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit" name="testnetTxExplorerUrl"> <widget class="QLineEdit" name="onionTxExplorerUrl">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>9</x> <x>9</x>
@ -717,7 +717,7 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">https://explorer.testnet.z.cash/tx/</string> <string notr="true">http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion/tx/</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_17"> <widget class="QLabel" name="label_17">
@ -730,10 +730,10 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Testnet Address Explorer URL</string> <string>Onion Address Explorer URL</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit" name="testnetAddressExplorerUrl"> <widget class="QLineEdit" name="onionAddressExplorerUrl">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>9</x> <x>9</x>
@ -743,7 +743,7 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">https://explorer.testnet.hush.is/address/</string> <string notr="true">http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion/tx/</string>
</property> </property>
</widget> </widget>
</widget> </widget>

Loading…
Cancel
Save