Browse Source

Cleanups

old_duke
Duke Leto 4 years ago
parent
commit
791094077e
  1. 40
      src/connection.cpp
  2. 2
      src/connection.h
  3. 32
      src/mainwindow.cpp
  4. 8
      src/rpc.cpp
  5. 4
      src/sendtab.cpp

40
src/connection.cpp

@ -75,7 +75,7 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) {
main->logger->write("Embedded hushd started up, trying autoconnect in 1 sec");
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
} else {
if (config->zcashDaemon) {
if (config->hushDaemon) {
// hushd is configured to run as a daemon, so we must wait for a few seconds
// to let it start up.
main->logger->write("hushd is daemon=1. Waiting for it to start up");
@ -93,7 +93,7 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) {
// We tried to start ehushd previously, and it didn't work. So, show the error.
main->logger->write("Couldn't start embedded hushd for unknown reason");
QString explanation;
if (config->zcashDaemon) {
if (config->hushDaemon) {
explanation = QString() % QObject::tr("You have hushd set to start as a daemon, which can cause problems "
"with SilentDragon\n\n."
"Please remove the following line from your HUSH3.conf and restart SilentDragon\n"
@ -667,12 +667,12 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectHushConf() {
QTextStream in(&file);
auto zcashconf = new ConnectionConfig();
zcashconf->host = "127.0.0.1";
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD;
zcashconf->usingHushConf = true;
zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath();
zcashconf->zcashDaemon = false;
auto hushconf = new ConnectionConfig();
hushconf->host = "127.0.0.1";
hushconf->connType = ConnectionType::DetectedConfExternalZcashD;
hushconf->usingHushConf = true;
hushconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath();
hushconf->hushDaemon = false;
Settings::getInstance()->setUsingHushConf(confLocation);
@ -683,43 +683,43 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectHushConf() {
QString value = line.right(line.length() - s - 1).trimmed();
if (name == "rpcuser") {
zcashconf->rpcuser = value;
hushconf->rpcuser = value;
}
if (name == "rpcpassword") {
zcashconf->rpcpassword = value;
hushconf->rpcpassword = value;
}
if (name == "rpcport") {
zcashconf->port = value;
hushconf->port = value;
}
if (name == "daemon" && value == "1") {
zcashconf->zcashDaemon = true;
hushconf->hushDaemon = true;
}
if (name == "proxy") {
zcashconf->proxy = value;
hushconf->proxy = value;
}
if (name == "consolidation") {
zcashconf->consolidation = value;
hushconf->consolidation = value;
}
if (name == "deletetx") {
zcashconf->deletetx = value;
hushconf->deletetx = value;
}
if (name == "zindex") {
zcashconf->zindex = value;
hushconf->zindex = value;
}
if (name == "testnet" &&
value == "1" &&
zcashconf->port.isEmpty()) {
zcashconf->port = "18232";
hushconf->port.isEmpty()) {
hushconf->port = "18232";
}
}
// If rpcport is not in the file, and it was not set by the testnet=1 flag, then go to default
if (zcashconf->port.isEmpty()) zcashconf->port = "18031";
if (hushconf->port.isEmpty()) hushconf->port = "18031";
file.close();
// In addition to the HUSH3/HUSH3.conf file, also double check the params.
return std::shared_ptr<ConnectionConfig>(zcashconf);
return std::shared_ptr<ConnectionConfig>(hushconf);
}
/**

2
src/connection.h

@ -21,7 +21,7 @@ struct ConnectionConfig {
QString rpcuser;
QString rpcpassword;
bool usingHushConf;
bool zcashDaemon;
bool hushDaemon;
QString zcashDir;
QString proxy;
QString consolidation;

32
src/mainwindow.cpp

@ -396,9 +396,9 @@ void MainWindow::setupSettingsModal() {
settings.port->setValidator(&validator);
// If values are coming from HUSH3.conf, then disable all the fields
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
if (!zcashConfLocation.isEmpty()) {
settings.confMsg->setText("Settings are being read from \n" + zcashConfLocation);
auto hushConfLocation = Settings::getInstance()->getZcashdConfLocation();
if (!hushConfLocation.isEmpty()) {
settings.confMsg->setText("Settings are being read from \n" + hushConfLocation);
settings.hostname->setEnabled(false);
settings.port->setEnabled(false);
settings.rpcuser->setEnabled(false);
@ -457,7 +457,7 @@ void MainWindow::setupSettingsModal() {
if (!isUsingTor && settings.chkTor->isChecked()) {
// If "use tor" was previously unchecked and now checked
Settings::addToHushConf(zcashConfLocation, "proxy=127.0.0.1:9050");
Settings::addToHushConf(hushConfLocation, "proxy=127.0.0.1:9050");
rpc->getConnection()->config->proxy = "proxy=127.0.0.1:9050";
QMessageBox::information(this, tr("Enable Tor"),
@ -467,7 +467,7 @@ void MainWindow::setupSettingsModal() {
if (isUsingTor && !settings.chkTor->isChecked()) {
// If "use tor" was previously checked and now is unchecked
Settings::removeFromHushConf(zcashConfLocation, "proxy");
Settings::removeFromHushConf(hushConfLocation, "proxy");
rpc->getConnection()->config->proxy.clear();
QMessageBox::information(this, tr("Disable Tor"),
@ -475,7 +475,7 @@ void MainWindow::setupSettingsModal() {
QMessageBox::Ok);
}
if (zcashConfLocation.isEmpty()) {
if (hushConfLocation.isEmpty()) {
// Save settings
Settings::getInstance()->saveSettings(
settings.hostname->text(),
@ -498,55 +498,55 @@ void MainWindow::setupSettingsModal() {
bool showRestartInfo = false;
bool showReindexInfo = false;
if (settings.chkRescan->isChecked()) {
Settings::addToHushConf(zcashConfLocation, "rescan=1");
Settings::addToHushConf(hushConfLocation, "rescan=1");
showRestartInfo = true;
}
if (settings.chkReindex->isChecked()) {
Settings::addToHushConf(zcashConfLocation, "reindex=1");
Settings::addToHushConf(hushConfLocation, "reindex=1");
showRestartInfo = true;
}
if (!rpc->getConnection()->config->consolidation.isEmpty()==false) {
if (settings.chkConso->isChecked()) {
Settings::addToHushConf(zcashConfLocation, "consolidation=1");
Settings::addToHushConf(hushConfLocation, "consolidation=1");
showRestartInfo = true;
}
}
if (!rpc->getConnection()->config->consolidation.isEmpty()) {
if (settings.chkConso->isChecked() == false) {
Settings::removeFromHushConf(zcashConfLocation, "consolidation");
Settings::removeFromHushConf(hushConfLocation, "consolidation");
showRestartInfo = true;
}
}
if (!rpc->getConnection()->config->deletetx.isEmpty() == false) {
if (settings.chkDeletetx->isChecked()) {
Settings::addToHushConf(zcashConfLocation, "deletetx=1");
Settings::addToHushConf(hushConfLocation, "deletetx=1");
showRestartInfo = true;
}
}
if (!rpc->getConnection()->config->deletetx.isEmpty()) {
if (settings.chkDeletetx->isChecked() == false) {
Settings::removeFromHushConf(zcashConfLocation, "deletetx");
Settings::removeFromHushConf(hushConfLocation, "deletetx");
showRestartInfo = true;
}
}
if (!rpc->getConnection()->config->zindex.isEmpty() == false) {
if (settings.chkzindex->isChecked()) {
Settings::addToHushConf(zcashConfLocation, "zindex=1");
Settings::addToHushConf(zcashConfLocation, "reindex=1");
Settings::addToHushConf(hushConfLocation, "zindex=1");
Settings::addToHushConf(hushConfLocation, "reindex=1");
showReindexInfo = true;
}
}
if (!rpc->getConnection()->config->zindex.isEmpty()) {
if (settings.chkzindex->isChecked() == false) {
Settings::removeFromHushConf(zcashConfLocation, "zindex");
Settings::addToHushConf(zcashConfLocation, "reindex=1");
Settings::removeFromHushConf(hushConfLocation, "zindex");
Settings::addToHushConf(hushConfLocation, "reindex=1");
showReindexInfo = true;
}
}

8
src/rpc.cpp

@ -82,9 +82,9 @@ void RPC::setConnection(Connection* c) {
ui->statusBar->showMessage("Ready! Thank you for helping secure the Hush network by running a full node.");
// See if we need to remove the reindex/rescan flags from the zcash.conf file
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
Settings::removeFromHushConf(zcashConfLocation, "rescan");
Settings::removeFromHushConf(zcashConfLocation, "reindex");
auto hushConfLocation = Settings::getInstance()->getZcashdConfLocation();
Settings::removeFromHushConf(hushConfLocation, "rescan");
Settings::removeFromHushConf(hushConfLocation, "reindex");
// Refresh the UI
refreshPrice();
@ -1257,7 +1257,7 @@ void RPC::shutdownHushd() {
if ((ehushd->atEnd() && ehushd->processId() == 0) ||
ehushd->state() == QProcess::NotRunning ||
waitCount > 30 ||
conn->config->zcashDaemon) { // If hushd is daemon, then we don't have to do anything else
conn->config->hushDaemon) { // If hushd is daemon, then we don't have to do anything else
qDebug() << "Ended";
waiter.stop();
QTimer::singleShot(1000, [&]() { d.accept(); });

4
src/sendtab.cpp

@ -512,9 +512,9 @@ Tx MainWindow::createTxFromSendPage() {
}
if (Settings::getInstance()->getAutoShield() && sendChangeToSapling) {
// We're finding a sapling address that is not one of the To addresses, which adds some non-determinism
auto saplingAddr = std::find_if(rpc->getAllZAddresses()->begin(), rpc->getAllZAddresses()->end(), [=](auto i) -> bool {
// We're finding a sapling address that is not one of the To addresses, because zcash doesn't allow duplicated addresses
// TODO: Should we disable this in Hush? What are the privacy and chain analysis considerations?
// TODO: randomize the order we process addresses to add more non-determinism
bool isSapling = Settings::getInstance()->isSaplingAddress(i);
if (!isSapling) return false;

Loading…
Cancel
Save