#74 Add Tor Support
This commit is contained in:
@@ -550,6 +550,9 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectZcashConf() {
|
|||||||
if (name == "daemon" && value == "1") {
|
if (name == "daemon" && value == "1") {
|
||||||
zcashconf->zcashDaemon = true;
|
zcashconf->zcashDaemon = true;
|
||||||
}
|
}
|
||||||
|
if (name == "proxy") {
|
||||||
|
zcashconf->proxy = value;
|
||||||
|
}
|
||||||
if (name == "testnet" &&
|
if (name == "testnet" &&
|
||||||
value == "1" &&
|
value == "1" &&
|
||||||
zcashconf->port.isEmpty()) {
|
zcashconf->port.isEmpty()) {
|
||||||
@@ -581,7 +584,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::loadFromSettings() {
|
|||||||
if (username.isEmpty() || password.isEmpty())
|
if (username.isEmpty() || password.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, false, "", ConnectionType::UISettingsZCashD};
|
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, false, "", "", ConnectionType::UISettingsZCashD};
|
||||||
|
|
||||||
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ struct ConnectionConfig {
|
|||||||
bool usingZcashConf;
|
bool usingZcashConf;
|
||||||
bool zcashDaemon;
|
bool zcashDaemon;
|
||||||
QString zcashDir;
|
QString zcashDir;
|
||||||
|
QString proxy;
|
||||||
|
|
||||||
ConnectionType connType;
|
ConnectionType connType;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -393,6 +393,17 @@ void MainWindow::setupSettingsModal() {
|
|||||||
// Auto shielding
|
// Auto shielding
|
||||||
settings.chkAutoShield->setChecked(Settings::getInstance()->getAutoShield());
|
settings.chkAutoShield->setChecked(Settings::getInstance()->getAutoShield());
|
||||||
|
|
||||||
|
// Use Tor
|
||||||
|
bool isUsingTor = !rpc->getConnection()->config->proxy.isEmpty();
|
||||||
|
settings.chkTor->setChecked(isUsingTor);
|
||||||
|
if (rpc->getEZcashD() == nullptr) {
|
||||||
|
settings.chkTor->setEnabled(false);
|
||||||
|
settings.lblTor->setEnabled(false);
|
||||||
|
QString tooltip = tr("Tor configuration is available only when running an embedded zcashd.");
|
||||||
|
settings.chkTor->setToolTip(tooltip);
|
||||||
|
settings.lblTor->setToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
// Connection Settings
|
// Connection Settings
|
||||||
QIntValidator validator(0, 65535);
|
QIntValidator validator(0, 65535);
|
||||||
settings.port->setValidator(&validator);
|
settings.port->setValidator(&validator);
|
||||||
@@ -435,6 +446,25 @@ void MainWindow::setupSettingsModal() {
|
|||||||
// Auto shield
|
// Auto shield
|
||||||
Settings::getInstance()->setAutoShield(settings.chkAutoShield->isChecked());
|
Settings::getInstance()->setAutoShield(settings.chkAutoShield->isChecked());
|
||||||
|
|
||||||
|
if (!isUsingTor && settings.chkTor->isChecked()) {
|
||||||
|
// If "use tor" was previously unchecked and now checked
|
||||||
|
Settings::addToZcashConf(zcashConfLocation, "proxy=127.0.0.1:9050");
|
||||||
|
rpc->getConnection()->config->proxy = "proxy=127.0.0.1:9050";
|
||||||
|
|
||||||
|
QMessageBox::information(this, tr("Enable Tor"),
|
||||||
|
tr("Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet."),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
if (isUsingTor && !settings.chkTor->isChecked()) {
|
||||||
|
// If "use tor" was previously checked and now is unchecked
|
||||||
|
Settings::removeFromZcashConf(zcashConfLocation, "proxy");
|
||||||
|
rpc->getConnection()->config->proxy.clear();
|
||||||
|
|
||||||
|
QMessageBox::information(this, tr("Disable Tor"),
|
||||||
|
tr("Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet."),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
|
||||||
if (zcashConfLocation.isEmpty()) {
|
if (zcashConfLocation.isEmpty()) {
|
||||||
// Save settings
|
// Save settings
|
||||||
Settings::getInstance()->saveSettings(
|
Settings::getInstance()->saveSettings(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|||||||
@@ -201,6 +201,50 @@ QString Settings::getDonationAddr(bool sapling) {
|
|||||||
return "zcEgrceTwvoiFdEvPWcsJHAMrpLsprMF6aRJiQa3fan5ZphyXLPuHghnEPrEPRoEVzUy65GnMVyCTRdkT6BYBepnXh6NBYs";
|
return "zcEgrceTwvoiFdEvPWcsJHAMrpLsprMF6aRJiQa3fan5ZphyXLPuHghnEPrEPRoEVzUy65GnMVyCTRdkT6BYBepnXh6NBYs";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::addToZcashConf(QString confLocation, QString line) {
|
||||||
|
QFile file(confLocation);
|
||||||
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Append))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
out << line << "\n";
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::removeFromZcashConf(QString confLocation, QString option) {
|
||||||
|
// To remove an option, we'll create a new file, and copy over everything but the option.
|
||||||
|
QFile file(confLocation);
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QList<QString> lines;
|
||||||
|
QTextStream in(&file);
|
||||||
|
while (!in.atEnd()) {
|
||||||
|
QString line = in.readLine();
|
||||||
|
auto s = line.indexOf("=");
|
||||||
|
QString name = line.left(s).trimmed().toLower();
|
||||||
|
if (name != option) {
|
||||||
|
qDebug() << "Copied " << line;
|
||||||
|
lines.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
QFile newfile(confLocation);
|
||||||
|
if (!newfile.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QTextStream out(&newfile);
|
||||||
|
for (QString line : lines) {
|
||||||
|
out << line << endl;
|
||||||
|
}
|
||||||
|
newfile.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
double Settings::getMinerFee() {
|
double Settings::getMinerFee() {
|
||||||
return 0.0001;
|
return 0.0001;
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ public:
|
|||||||
|
|
||||||
static bool isValidAddress(QString addr);
|
static bool isValidAddress(QString addr);
|
||||||
|
|
||||||
|
static bool addToZcashConf(QString confLocation, QString line);
|
||||||
|
static bool removeFromZcashConf(QString confLocation, QString option);
|
||||||
|
|
||||||
static const QString labelRegExp;
|
static const QString labelRegExp;
|
||||||
|
|
||||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
static const int updateSpeed = 20 * 1000; // 20 sec
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>460</width>
|
<width>540</width>
|
||||||
<height>464</height>
|
<height>504</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>460</width>
|
<width>540</width>
|
||||||
<height>464</height>
|
<height>500</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -145,10 +145,10 @@
|
|||||||
<string>Options</string>
|
<string>Options</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="10" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="lblTor">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
|
<string>Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -162,6 +162,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -182,14 +192,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkCustomFees">
|
||||||
|
<property name="text">
|
||||||
|
<string>Allow custom fees</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0" colspan="2">
|
||||||
<widget class="Line" name="line_2">
|
<widget class="Line" name="line_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0" colspan="2">
|
<item row="12" column="0" colspan="2">
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@@ -202,13 +229,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QCheckBox" name="chkCustomFees">
|
|
||||||
<property name="text">
|
|
||||||
<string>Allow custom fees</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -219,16 +239,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="text">
|
|
||||||
<string>Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy.</string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0" colspan="2">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="chkAutoShield">
|
<widget class="QCheckBox" name="chkAutoShield">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -243,6 +253,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkTor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect via Tor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user