|
|
@ -1,5 +1,5 @@ |
|
|
|
// Copyright 2019-2021 The Hush developers
|
|
|
|
// GPLv3
|
|
|
|
// Released under the GPLv3
|
|
|
|
#include "connection.h" |
|
|
|
#include "mainwindow.h" |
|
|
|
#include "settings.h" |
|
|
@ -82,11 +82,11 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) { |
|
|
|
// We're going to attempt to connect to the one in the background one last time
|
|
|
|
// and see if that works, else throw an error
|
|
|
|
main->logger->write("Unknown problem while trying to start hushd!"); |
|
|
|
QTimer::singleShot(2000, [=]() { doAutoConnect(/* don't attempt to start ezcashd */ false); }); |
|
|
|
QTimer::singleShot(2000, [=]() { doAutoConnect(/* don't attempt to start ehushd */ false); }); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// We tried to start ezcashd previously, and it didn't work. So, show the error.
|
|
|
|
// 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) { |
|
|
@ -98,7 +98,7 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) { |
|
|
|
explanation = QString() % QObject::tr("Couldn't start the embedded hushd.\n\n" |
|
|
|
"Please try restarting.\n\nIf you previously started hushd with custom arguments, you might need to reset HUSH3.conf.\n\n" |
|
|
|
"If all else fails, please run hushd manually.") % |
|
|
|
(ezcashd ? QObject::tr("The process returned") + ":\n\n" % ezcashd->errorString() : QString("")); |
|
|
|
(ehushd ? QObject::tr("The process returned") + ":\n\n" % ehushd->errorString() : QString("")); |
|
|
|
} |
|
|
|
|
|
|
|
this->showError(explanation); |
|
|
@ -328,8 +328,8 @@ bool ConnectionLoader::startEmbeddedZcashd() { |
|
|
|
// Static because it needs to survive even after this method returns.
|
|
|
|
static QString processStdErrOutput; |
|
|
|
|
|
|
|
if (ezcashd != nullptr) { |
|
|
|
if (ezcashd->state() == QProcess::NotRunning) { |
|
|
|
if (ehushd != nullptr) { |
|
|
|
if (ehushd->state() == QProcess::NotRunning) { |
|
|
|
if (!processStdErrOutput.isEmpty()) { |
|
|
|
QMessageBox::critical(main, QObject::tr("hushd error"), "hushd said: " + processStdErrOutput, |
|
|
|
QMessageBox::Ok); |
|
|
@ -357,23 +357,23 @@ bool ConnectionLoader::startEmbeddedZcashd() { |
|
|
|
main->logger->write("Found hushd at " + hushdProgram); |
|
|
|
} |
|
|
|
|
|
|
|
ezcashd = std::shared_ptr<QProcess>(new QProcess(main)); |
|
|
|
QObject::connect(ezcashd.get(), &QProcess::started, [=] () { |
|
|
|
ehushd = std::shared_ptr<QProcess>(new QProcess(main)); |
|
|
|
QObject::connect(ehushd.get(), &QProcess::started, [=] () { |
|
|
|
qDebug() << "Embedded hushd started via " << hushdProgram; |
|
|
|
}); |
|
|
|
|
|
|
|
QObject::connect(ezcashd.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), |
|
|
|
QObject::connect(ehushd.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), |
|
|
|
[=](int exitCode, QProcess::ExitStatus exitStatus) { |
|
|
|
qDebug() << "hushd finished with code " << exitCode << "," << exitStatus; |
|
|
|
}); |
|
|
|
|
|
|
|
QObject::connect(ezcashd.get(), &QProcess::errorOccurred, [&] (QProcess::ProcessError error) { |
|
|
|
QObject::connect(ehushd.get(), &QProcess::errorOccurred, [&] (QProcess::ProcessError error) { |
|
|
|
qDebug() << "Couldn't start hushd at " << hushdProgram << ":" << error; |
|
|
|
}); |
|
|
|
|
|
|
|
std::weak_ptr<QProcess> weak_obj(ezcashd); |
|
|
|
std::weak_ptr<QProcess> weak_obj(ehushd); |
|
|
|
auto ptr_main(main); |
|
|
|
QObject::connect(ezcashd.get(), &QProcess::readyReadStandardError, [weak_obj, ptr_main]() { |
|
|
|
QObject::connect(ehushd.get(), &QProcess::readyReadStandardError, [weak_obj, ptr_main]() { |
|
|
|
auto output = weak_obj.lock()->readAllStandardError(); |
|
|
|
ptr_main->logger->write("hushd stderr:" + output); |
|
|
|
processStdErrOutput.append(output); |
|
|
@ -386,18 +386,18 @@ bool ConnectionLoader::startEmbeddedZcashd() { |
|
|
|
// Finally, actually start the full node
|
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
qDebug() << "Starting on Linux: " + hushdProgram + " " + params; |
|
|
|
ezcashd->start(hushdProgram, arguments); |
|
|
|
ehushd->start(hushdProgram, arguments); |
|
|
|
#elif defined(Q_OS_DARWIN) |
|
|
|
qDebug() << "Starting on Darwin: " + hushdProgram + " " + params; |
|
|
|
ezcashd->start(hushdProgram, arguments); |
|
|
|
ehushd->start(hushdProgram, arguments); |
|
|
|
#elif defined(Q_OS_WIN64) |
|
|
|
qDebug() << "Starting on Win64: " + hushdProgram + " " + params; |
|
|
|
ezcashd->setWorkingDirectory(appPath.absolutePath()); |
|
|
|
ezcashd->start(hushdProgram, arguments); |
|
|
|
ehushd->setWorkingDirectory(appPath.absolutePath()); |
|
|
|
ehushd->start(hushdProgram, arguments); |
|
|
|
#else |
|
|
|
qDebug() << "Starting on Unknown OS(!): " + hushdProgram + " " + params; |
|
|
|
ezcashd->setWorkingDirectory(appPath.absolutePath()); |
|
|
|
ezcashd->start(hushdProgram, arguments); |
|
|
|
ehushd->setWorkingDirectory(appPath.absolutePath()); |
|
|
|
ehushd->start(hushdProgram, arguments); |
|
|
|
#endif // Q_OS_LINUX
|
|
|
|
|
|
|
|
main->logger->write("Started via " + hushdProgram + " " + params); |
|
|
@ -433,7 +433,7 @@ void ConnectionLoader::doManualConnect() { |
|
|
|
} |
|
|
|
|
|
|
|
void ConnectionLoader::doRPCSetConnection(Connection* conn) { |
|
|
|
rpc->setEZcashd(ezcashd); |
|
|
|
rpc->setEZcashd(ehushd); |
|
|
|
rpc->setConnection(conn); |
|
|
|
|
|
|
|
d->accept(); |
|
|
@ -652,7 +652,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectZcashConf() { |
|
|
|
|
|
|
|
auto zcashconf = new ConnectionConfig(); |
|
|
|
zcashconf->host = "127.0.0.1"; |
|
|
|
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD; |
|
|
|
zcashconf->connType = ConnectionType::DetectedConfExternalHushD; |
|
|
|
zcashconf->usingZcashConf = true; |
|
|
|
zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath(); |
|
|
|
zcashconf->zcashDaemon = false; |
|
|
|