|
|
@ -9,7 +9,15 @@ |
|
|
|
#include "precompiled.h" |
|
|
|
#include "version.h" |
|
|
|
|
|
|
|
extern bool isdragonx; |
|
|
|
extern bool isHSC; |
|
|
|
extern std::string HSC_name; |
|
|
|
extern std::string HSC_ac_name; |
|
|
|
extern std::string HSC_port; |
|
|
|
extern std::string App_title; |
|
|
|
extern std::string HSC_website; |
|
|
|
extern std::string HSC_param; |
|
|
|
extern std::string HSC_app_name; |
|
|
|
extern std::string HSC_website; |
|
|
|
|
|
|
|
ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) { |
|
|
|
qDebug() << __func__; |
|
|
@ -20,8 +28,8 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) { |
|
|
|
d->setWindowFlags(d->windowFlags() & ~(Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)); |
|
|
|
connD = new Ui_ConnectionDialog(); |
|
|
|
connD->setupUi(d); |
|
|
|
if(isdragonx) { |
|
|
|
d->setWindowTitle("SilentDragonX"); |
|
|
|
if (isHSC) { |
|
|
|
d->setWindowTitle(QString::fromStdString(App_title)); |
|
|
|
} |
|
|
|
QMovie *movie1 = new QMovie(":/img/silentdragon-animated-startup-dark.gif");; |
|
|
|
auto theme = Settings::getInstance()->get_theme_name(); |
|
|
@ -68,8 +76,9 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { |
|
|
|
// Refused connection. So try and start embedded hushd
|
|
|
|
if (Settings::getInstance()->useEmbedded()) { |
|
|
|
if (tryEhushdStart) { |
|
|
|
if(isdragonx) { |
|
|
|
this->showInformation(QObject::tr("Starting embedded dragonxd")); |
|
|
|
if(isHSC) { |
|
|
|
std::string start_daemon = "Starting embedded" + HSC_name + "d"; |
|
|
|
this->showInformation(QObject::tr(start_daemon.c_str())); |
|
|
|
} else { |
|
|
|
this->showInformation(QObject::tr("Starting embedded hushd")); |
|
|
|
} |
|
|
@ -101,21 +110,23 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { |
|
|
|
"with SilentDragon\n\n." |
|
|
|
"Please remove the following line from your HUSH3.conf and restart SilentDragon\n" |
|
|
|
"daemon=1"); |
|
|
|
if (isdragonx) { |
|
|
|
explanation = QString() % QObject::tr("You have dragonxd set to start as a daemon, which can cause problems " |
|
|
|
"with SilentDragonX\n\n." |
|
|
|
"Please remove the following line from your DRAGONX.conf and restart SilentDragonX\n" |
|
|
|
"daemon=1"); |
|
|
|
if (isHSC) { |
|
|
|
std::string daemon_error = "You have " + HSC_name + "d set to start as a daemon, which can cause problems " |
|
|
|
"with " + App_title + "\n\n." |
|
|
|
"Please remove the following line from your " + HSC_ac_name + ".conf and restart " + App_title + "\n" |
|
|
|
"daemon=1"; |
|
|
|
explanation = QString() % QObject::tr(daemon_error.c_str()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
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.") % |
|
|
|
(ehushd ? QObject::tr("The process returned") + ":\n\n" % ehushd->errorString() : QString("")); |
|
|
|
if(isdragonx) { |
|
|
|
explanation = QString() % QObject::tr("Couldn't start the embedded dragonxd.\n\n" |
|
|
|
"Please try restarting.\n\nIf you previously started hushd with custom arguments, you might need to reset DRAGONX.conf.\n\n" |
|
|
|
"If all else fails, please run dragonxd manually.") % |
|
|
|
if(isHSC) { |
|
|
|
std::string daemon_error = "Couldn't start the embedded " + HSC_name + "d.\n\n" |
|
|
|
"Please try restarting.\n\nIf you previously started hushd with custom arguments, you might need to reset " + HSC_ac_name + ".conf.\n\n" |
|
|
|
"If all else fails, please run " + HSC_name + "d manually."; |
|
|
|
explanation = QString() % QObject::tr(daemon_error.c_str()) % |
|
|
|
(ehushd ? QObject::tr("The process returned") + ":\n\n" % ehushd->errorString() : QString("")); |
|
|
|
} |
|
|
|
} |
|
|
@ -127,10 +138,12 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { |
|
|
|
main->logger->write("Not using embedded and couldn't connect to hushd"); |
|
|
|
QString explanation = QString() % QObject::tr("Couldn't connect to hushd configured in HUSH3.conf.\n\n" |
|
|
|
"Not starting embedded hushd because --no-embedded was passed"); |
|
|
|
if(isdragonx) { |
|
|
|
main->logger->write("Not using embedded and couldn't connect to dragonxd"); |
|
|
|
QString explanation = QString() % QObject::tr("Couldn't connect to dragonxd configured in DRAGONX.conf.\n\n" |
|
|
|
"Not starting embedded dragonxd because --no-embedded was passed"); |
|
|
|
if(isHSC) { |
|
|
|
std::string error = "Not using embedded and couldn't connect to " + HSC_name + "d"; |
|
|
|
main->logger->write(error.c_str()); |
|
|
|
std::string conf_error = "Couldn't connect to " + HSC_name + "d configured in " + HSC_ac_name + ".conf.\n\n" |
|
|
|
"Not starting embedded " + HSC_name + "d because --no-embedded was passed"; |
|
|
|
QString explanation = QString() % QObject::tr(conf_error.c_str()); |
|
|
|
} |
|
|
|
this->showError(explanation); |
|
|
|
} |
|
|
@ -224,7 +237,8 @@ void ConnectionLoader::createHushConf() { |
|
|
|
|
|
|
|
QFile file(confLocation); |
|
|
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) { |
|
|
|
QString explanation = QString() % (isdragonx ? QObject::tr("Could not create DRAGONX.conf.") : QObject::tr("Could not create HUSH3.conf.") ); |
|
|
|
std::string error = "Could not create" + HSC_ac_name + ".conf."; |
|
|
|
QString explanation = QString() % (isHSC ? QObject::tr(error.c_str()) : QObject::tr("Could not create HUSH3.conf.")); |
|
|
|
main->logger->write(explanation); |
|
|
|
|
|
|
|
this->showError(explanation); |
|
|
@ -233,17 +247,21 @@ void ConnectionLoader::createHushConf() { |
|
|
|
|
|
|
|
QTextStream out(&file); |
|
|
|
|
|
|
|
if(isdragonx) { |
|
|
|
out << "# Autogenerated by Hush SilentDragonX " << APP_VERSION << " https://dragonx.is\n"; |
|
|
|
if (isHSC) { |
|
|
|
std::string str1 = "# Autogenerated by Hush " + App_title + " "; |
|
|
|
std::string str2 = " " + HSC_website; |
|
|
|
out << str1.c_str() << APP_VERSION << str2.c_str(); |
|
|
|
} else { |
|
|
|
out << "# Autogenerated by Hush SilentDragon " << APP_VERSION << " https://hush.is\n"; |
|
|
|
} |
|
|
|
out << "server=1\n"; |
|
|
|
out << "rpcpassword=" % randomPassword() << "\n"; |
|
|
|
|
|
|
|
if(isdragonx) { |
|
|
|
out << "rpcuser=dragonx\n"; |
|
|
|
out << "rpcport=21769\n"; |
|
|
|
if (isHSC) { |
|
|
|
std::string str1 = "rpcuser=" + HSC_name + "\n"; |
|
|
|
std::string str2 = "rpcport=" + HSC_port + "\n"; |
|
|
|
out << str1.c_str(); |
|
|
|
out << str2.c_str(); |
|
|
|
} else { |
|
|
|
out << "rpcuser=hush\n"; |
|
|
|
out << "rpcport=18031\n"; |
|
|
@ -394,8 +412,9 @@ bool ConnectionLoader::startEmbeddedHushd() { |
|
|
|
// params for DRGX are handled below
|
|
|
|
#else |
|
|
|
auto hushdProgram = appPath.absoluteFilePath("hushd"); |
|
|
|
if (isdragonx) { |
|
|
|
hushdProgram = appPath.absoluteFilePath("dragonxd"); |
|
|
|
if (isHSC) { |
|
|
|
std::string daemon = HSC_name + "d"; |
|
|
|
hushdProgram = appPath.absoluteFilePath(daemon.c_str()); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
@ -445,9 +464,9 @@ bool ConnectionLoader::startEmbeddedHushd() { |
|
|
|
qDebug() << "No ASN map file found"; |
|
|
|
} |
|
|
|
*/ |
|
|
|
if(isdragonx) { |
|
|
|
if (isHSC) { |
|
|
|
// dragonxd bash script cannot be used on windows, so specify exact chain params
|
|
|
|
params += " -ac_name=DRAGONX -ac_algo=randomx -ac_halving=3500000 -ac_reward=300000000 -ac_blocktime=36 -ac_private=1 -addnode=176.126.87.241"; |
|
|
|
params += QString::fromStdString(HSC_param); |
|
|
|
} |
|
|
|
|
|
|
|
QStringList arguments = params.split(" "); |
|
|
@ -557,10 +576,11 @@ void ConnectionLoader::refreshHushdState(Connection* connection, std::function<v |
|
|
|
QString explanation = QString() % |
|
|
|
QObject::tr("Authentication failed. The username / password you specified was " |
|
|
|
"not accepted by hushd. Try changing it in the Edit->Settings menu"); |
|
|
|
if(isdragonx) { |
|
|
|
explanation = QString() % |
|
|
|
QObject::tr("Authentication failed. The username / password you specified was " |
|
|
|
"not accepted by dragonxd. Try changing it in the Edit->Settings menu"); |
|
|
|
if (isHSC) { |
|
|
|
std::string auth_failed = "Authentication failed. The username / password you specified was not " |
|
|
|
"accepted by " + |
|
|
|
HSC_name + "d. Try changing it in the Edit->Settings menu"; |
|
|
|
explanation = QString() % QObject::tr(auth_failed.c_str()); |
|
|
|
} |
|
|
|
|
|
|
|
this->showError(explanation); |
|
|
@ -575,8 +595,9 @@ void ConnectionLoader::refreshHushdState(Connection* connection, std::function<v |
|
|
|
if (dots > 3) |
|
|
|
dots = 0; |
|
|
|
} |
|
|
|
if(isdragonx) { |
|
|
|
this->showInformation(QObject::tr("Your dragonxd is starting up. Please wait."), status); |
|
|
|
if (isHSC) { |
|
|
|
std::string please_wait = "Your " + HSC_name + "d is starting up. Please wait."; |
|
|
|
this->showInformation(QObject::tr(please_wait.c_str()), status); |
|
|
|
} else { |
|
|
|
this->showInformation(QObject::tr("Your hushd is starting up. Please wait."), status); |
|
|
|
} |
|
|
@ -621,8 +642,8 @@ void ConnectionLoader::showError(QString explanation) { |
|
|
|
QString ConnectionLoader::locateHushConfFile() { |
|
|
|
|
|
|
|
// HSC's have no legacy locations
|
|
|
|
if (isdragonx) { |
|
|
|
auto acname = "DRAGONX"; |
|
|
|
if (isHSC) { |
|
|
|
auto acname = QString::fromStdString(HSC_ac_name); |
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
auto confLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, QString(".hush/") + acname + "/" + acname + ".conf"); |
|
|
|
#elif defined(Q_OS_DARWIN) |
|
|
@ -662,18 +683,21 @@ QString ConnectionLoader::locateHushConfFile() { |
|
|
|
QString ConnectionLoader::hushConfWritableLocation() { |
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
auto confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".hush/HUSH3/HUSH3.conf"); |
|
|
|
if(isdragonx) { |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".hush/DRAGONX/DRAGONX.conf"); |
|
|
|
if (isHSC) { |
|
|
|
std::string conf_location = ".hush/" + HSC_ac_name + "/" + HSC_ac_name + ".conf"; |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(conf_location.c_str()); |
|
|
|
} |
|
|
|
#elif defined(Q_OS_DARWIN) |
|
|
|
auto confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath("Library/Application Support/Hush/HUSH3/HUSH3.conf"); |
|
|
|
if(isdragonx) { |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath("Library/Application Support/Hush/DRAGONX/DRAGONX.conf"); |
|
|
|
if (isHSC) { |
|
|
|
std::string conf_location = "Library/Application Support/Hush/" + HSC_ac_name + "/" + HSC_ac_name + ".conf"; |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(conf_location.c_str()); |
|
|
|
} |
|
|
|
#else |
|
|
|
auto confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("../../Hush/HUSH3/HUSH3.conf"); |
|
|
|
if(isdragonx) { |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("../../Hush/DRAGONX/DRAGONX.conf"); |
|
|
|
if (isHSC) { |
|
|
|
std::string conf_location = "../../Hush/" + HSC_ac_name + "/" + HSC_ac_name + ".conf"; |
|
|
|
confLocation = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath(conf_location.c_str()); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
@ -740,14 +764,15 @@ bool ConnectionLoader::verifyParams() { |
|
|
|
} |
|
|
|
|
|
|
|
// this is to support SDX on mac in /Applications
|
|
|
|
if( QFile( QDir("/Applications").filePath("silentdragonx.app/Contents/MacOS/sapling-output.params") ).exists() && QFile( QDir("/Applications").filePath("./silentdragonx.app/Contents/MacOS/sapling-spend.params") ).exists() ) { |
|
|
|
qDebug() << "Found params in /Applications/silentdragonx.app/Contents/MacOS"; |
|
|
|
QString app_name = QString::fromStdString(HSC_app_name); |
|
|
|
if (QFile(QDir("/Applications").filePath("" + app_name + ".app/Contents/MacOS/sapling-output.params")).exists() && QFile(QDir("/Applications").filePath("./" + app_name + ".app/Contents/MacOS/sapling-spend.params")).exists()) { |
|
|
|
qDebug() << "Found params in /Applications/" + app_name + ".app/Contents/MacOS"; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// this is to support SDX on mac inside a DMG
|
|
|
|
if( QFile( QDir("./").filePath("silentdragonx.app/Contents/MacOS/sapling-output.params") ).exists() && QFile( QDir("./").filePath("./silentdragonx.app/Contents/MacOS/sapling-spend.params") ).exists() ) { |
|
|
|
qDebug() << "Found params in ./silentdragonx.app/Contents/MacOS"; |
|
|
|
if (QFile(QDir("./").filePath("" + app_name + ".app/Contents/MacOS/sapling-output.params")).exists() && QFile(QDir("./").filePath("./" + app_name + ".app/Contents/MacOS/sapling-spend.params")).exists()) { |
|
|
|
qDebug() << "Found params in ./" + app_name + ".app/Contents/MacOS"; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -828,8 +853,8 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectHushConf() { |
|
|
|
|
|
|
|
// If rpcport is not in the file, and it was not set by the testnet=1 flag, then go to default
|
|
|
|
if (hushconf->port.isEmpty()) { |
|
|
|
if(isdragonx) { |
|
|
|
hushconf->port = "21769"; |
|
|
|
if (isHSC) { |
|
|
|
hushconf->port = QString::fromStdString(HSC_port); |
|
|
|
} else { |
|
|
|
hushconf->port = "18031"; |
|
|
|
} |
|
|
|