Compare commits

...

1 Commits

  1. 7
      src/addressbook.cpp
  2. 121
      src/connection.cpp
  3. 30
      src/main.cpp
  4. 65
      src/mainwindow.cpp
  5. 16
      src/requestdialog.cpp
  6. 26
      src/rpc.cpp
  7. 8
      src/senttxstore.cpp
  8. 24
      src/settings.cpp
  9. 11
      src/txtablemodel.cpp

7
src/addressbook.cpp

@ -7,7 +7,8 @@
#include "mainwindow.h"
#include "rpc.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_name;
AddressBookModel::AddressBookModel(QTableView *parent)
: QAbstractTableModel(parent) {
@ -294,8 +295,8 @@ void AddressBook::writeToStorage() {
QString AddressBook::writeableFile() {
auto filename = QStringLiteral("addresslabels.dat");
if (isdragonx) {
filename = QStringLiteral("addresslabels-drgx.dat");
if (isHSC) {
filename = QString::fromStdString("addresslabels-" + HSC_name + ".dat");
}
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));

121
src/connection.cpp

@ -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";
}

30
src/main.cpp

@ -8,7 +8,20 @@
#include "version.h"
#include <QCommandLineParser>
bool isdragonx = 0;
bool isHSC = 1;
std::string HSC_name = "dragonx";
std::string HSC_app_name = "silentdragonx";
std::string App_title = "SilentDragonX";
std::string HSC_ticker = "drgx";
std::string HSC_default_theme = "dragonx";
std::string HSC_TG_link = "dragonx.is/tg";
std::string HSC_website = "dragonx.is";
std::string HSC_explorer = "explorer.dragonx.is";
std::string HSC_ac_name = "DRAGONX";
std::string HSC_port = "21769";
std::string HSC_seednode = "-addnode=176.126.87.241";
std::string HSC_param = " -ac_name=" + HSC_ac_name + " -ac_algo=randomx -ac_halving=3500000 -ac_reward=300000000 -ac_blocktime=36 -ac_private=1 " + HSC_seednode;
class SignalHandler
{
@ -150,8 +163,11 @@ public:
QStringList pathParts = binaryName.split(QLatin1Char('/'));
qDebug() << pathParts;
isdragonx = binaryName.endsWith("dragonx") || binaryName.endsWith("dragonx.exe") || binaryName.endsWith("dragonx.app");
qDebug() << "isdragonx=" << isdragonx;
std::string appname_exe = HSC_app_name + ".exe";
std::string appname_app = HSC_app_name + ".app";
isHSC = binaryName.endsWith(HSC_app_name.c_str()) || binaryName.endsWith((appname_exe.c_str())) || binaryName.endsWith((appname_app.c_str()));
qDebug() << "isHSC=" << isHSC;
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@ -186,14 +202,14 @@ public:
}
QCoreApplication::setOrganizationName("Hush");
QCoreApplication::setApplicationName(isdragonx ? "SilentDragonX" : "SilentDragon");
QCoreApplication::setApplicationName(isHSC ? App_title.c_str() : "SilentDragon");
QString locale = QLocale::system().name();
locale.truncate(locale.lastIndexOf('_')); // Get the language code
qDebug() << "Loading locale " << locale;
QTranslator translator;
if(isdragonx) {
if (isHSC) {
translator.load(QString(":/translations/silentdragon_") + locale);
} else {
translator.load(QString(":/translations/silentdragon_") + locale);
@ -235,8 +251,8 @@ public:
}
w = new MainWindow();
if(isdragonx) {
w->setWindowTitle("SilentDragonX v" + QString(APP_VERSION));
if (isHSC) {
w->setWindowTitle((QString::fromStdString(App_title) + " v" + QString(APP_VERSION)));
} else {
w->setWindowTitle("SilentDragon v" + QString(APP_VERSION));
}

65
src/mainwindow.cpp

@ -25,7 +25,14 @@
#include <QThread>
#include "sd.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_default_theme;
extern std::string HSC_ticker;
extern std::string App_title;
extern std::string HSC_app_name;
extern std::string HSC_website;
extern std::string HSC_ac_name;
extern std::string HSC_name;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@ -40,8 +47,8 @@ MainWindow::MainWindow(QWidget *parent) :
{
qDebug() << __func__ << ": exception!";
if(isdragonx){
theme_name = "dragonx";
if (isHSC){
theme_name = QString::fromStdString(HSC_default_theme);
}else{
theme_name = "dark";
}
@ -50,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) :
this->slot_change_theme(theme_name);
ui->setupUi(this);
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath(isdragonx ? "SilentDragonX.log" : "SilentDragon.log"));
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath(isHSC ? (QString::fromStdString(HSC_app_name) + ".log") : "SilentDragon.log"));
// Status Bar
setupStatusBar();
@ -236,8 +243,8 @@ void switchTranslator(QTranslator& translator, const QString& filename) {
// load the new translator
QString path = QApplication::applicationDirPath();
if (isdragonx) {
path.append("/res-drgx/");
if (isHSC) {
path.append(("/res-" + QString::fromStdString(HSC_ticker) + "/"));
}
else{
path.append("/res/");
@ -830,8 +837,8 @@ void MainWindow::addressBook() {
void MainWindow::telegram() {
QString url = "https://hush.is/tg";
if (isdragonx) {
url = "https://dragonx.is/tg";
if (isHSC) {
url = QString::fromStdString(HSC_website);
}
QDesktopServices::openUrl(QUrl(url));
}
@ -844,8 +851,8 @@ void MainWindow::reportbug() {
void MainWindow::website() {
QString url = "https://hush.is";
if (isdragonx) {
url = "https://dragonx.is";
if (isHSC) {
url = QString::fromStdString(HSC_website);
}
QDesktopServices::openUrl(QUrl(url));
}
@ -974,9 +981,10 @@ void MainWindow::payHushURI(QString uri, QString myAddr) {
if (uri.isEmpty()) {
uri = QInputDialog::getText(this, tr("Paste HUSH URI"),
"HUSH URI" + QString(" ").repeated(180));
if(isdragonx) {
uri = QInputDialog::getText(this, tr("Paste DRGX URI"),
"DRGX URI" + QString(" ").repeated(180));
if (isHSC) {
std::string str1 = "Paste " + HSC_ac_name + " URI";
std::string str2 = HSC_ticker + " URI";
uri = QInputDialog::getText(this, tr((str1.c_str())), (str2.c_str() + QString(" ").repeated(180)));
}
}
@ -988,9 +996,11 @@ void MainWindow::payHushURI(QString uri, QString myAddr) {
qDebug() << "Received URI " << uri;
PaymentURI paymentInfo = Settings::parseURI(uri);
if (!paymentInfo.error.isEmpty()) {
if(isdragonx) {
QMessageBox::critical(this, tr("Error paying DragonX URI"),
tr("URI should be of the form 'drgx:<addr>?amt=x&memo=y") + "\n" + paymentInfo.error);
if (isHSC) {
std::string payment_info_error = paymentInfo.error.toStdString();
std::string payment_error = "Error paying " + HSC_name + " URI";
std::string uri_error = "URI should be of the form '" + HSC_ticker + ":<addr>?amt=x&memo=y" + "\n" + payment_info_error;
QMessageBox::critical(this, tr(payment_error.c_str()), tr(uri_error.c_str()));
} else {
QMessageBox::critical(this, tr("Error paying Hush URI"),
tr("URI should be of the form 'hush:<addr>?amt=x&memo=y") + "\n" + paymentInfo.error);
@ -1072,8 +1082,10 @@ void MainWindow::importPrivKey() {
void MainWindow::exportTransactions() {
// First, get the export file name
QString exportName;
if(isdragonx){
exportName = "drgx-transactions-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".csv";
if(isHSC){
std::string str = QDateTime::currentDateTime().toString("yyyyMMdd").toStdString();
std::string str2 = HSC_ticker + "-transactions-" + str + ".csv";
exportName = str2.c_str();
}else{
exportName = "hush-transactions-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".csv";
}
@ -1101,8 +1113,10 @@ void MainWindow::backupWalletDat() {
QDir hushdir(rpc->getConnection()->config->hushDir);
QString backupDefaultName;
if(isdragonx){
backupDefaultName = "drgx-wallet-backup-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".dat";
if(isHSC){
std::string str = QDateTime::currentDateTime().toString("yyyyMMdd").toStdString();
std::string str2 = HSC_ticker + "-wallet-backup-" + str + ".dat";
backupDefaultName = str2.c_str();
}else{
backupDefaultName = "hush-wallet-backup-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".dat";
}
@ -1549,7 +1563,7 @@ QString peer2ip(QString peer) {
void MainWindow::setupMiningTab() {
DEBUG("setting up mining tab");
//TODO: for other HSC's, look at getinfo.ac_algo == randomx
if(isdragonx) {
if (isHSC) {
int hwc = std::thread::hardware_concurrency();
DEBUG("hardware concurrency = " << hwc);
auto tab = new QWidget();
@ -2064,7 +2078,8 @@ void MainWindow::setupTransactionsTab() {
*/
// Payment Request
if (!memo.isEmpty() && memo.startsWith(isdragonx ? "drgx:" : "hush:")) {
std::string ticker = HSC_ticker + ":";
if (!memo.isEmpty() && memo.startsWith(isHSC ? (ticker.c_str()) : "hush:")) {
menu.addAction(tr("View Payment Request"), [=] () {
RequestDialog::showPaymentConfirmation(this, memo);
});
@ -2438,7 +2453,7 @@ void MainWindow::slot_change_theme(QString& theme_name)
qDebug() << __func__ << ": theme_name=" << theme_name;
if (theme_name == "dark" || theme_name == "default" || theme_name == "light" ||
theme_name == "midnight" || theme_name == "blue" || theme_name == "dragonx") {
theme_name == "midnight" || theme_name == "blue" || theme_name == (QString::fromStdString(HSC_default_theme))) {
Settings::getInstance()->set_theme_name(theme_name);
} else {
qDebug() << __func__ << ": ignoring invalid theme_name=" << theme_name;
@ -2452,8 +2467,8 @@ void MainWindow::slot_change_theme(QString& theme_name)
} catch (const std::exception& e) {
qDebug() << QString("Ignoring theme change Exception! : ");
if(isdragonx){
saved_theme_name = "dragonx";
if (isHSC){
saved_theme_name = QString::fromStdString(HSC_default_theme);
}else{
saved_theme_name = "dark";
}

16
src/requestdialog.cpp

@ -8,7 +8,10 @@
#include "rpc.h"
#include "settings.h"
#include "precompiled.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_ac_name;
extern std::string HSC_ticker;
RequestDialog::RequestDialog(QWidget *parent) :
QDialog(parent),
@ -49,9 +52,10 @@ void RequestDialog::setupDialog(MainWindow* main, QDialog* d, Ui_RequestDialog*
void RequestDialog::showPaymentConfirmation(MainWindow* main, QString paymentURI) {
PaymentURI payInfo = Settings::parseURI(paymentURI);
if (!payInfo.error.isEmpty()) {
if(isdragonx) {
QMessageBox::critical(main, tr("Error paying DRAGONX URI"),
tr("URI should be of the form 'drgx:<addr>?amt=x&memo=y") + "\n" + payInfo.error);
if (isHSC) {
std::string error = "Error paying " + HSC_ac_name + " URI";
std::string error2 = "URI should be of the form '" + HSC_ticker + ":<addr>?amt=x&memo=y";
QMessageBox::critical(main, tr(error.c_str()), tr(error2.c_str()) + "\n" + payInfo.error);
} else {
QMessageBox::critical(main, tr("Error paying HUSH URI"),
tr("URI should be of the form 'hush:<addr>?amt=x&memo=y") + "\n" + payInfo.error);
@ -131,11 +135,11 @@ void RequestDialog::showRequestZcash(MainWindow* main) {
if (d.exec() == QDialog::Accepted) {
// Construct a Hush Payment URI with the data and pay it immediately.
QString memoURI = (isdragonx ? "drgx:" : "hush:" ) + req.cmbMyAddress->currentText()
QString memoURI = (isHSC ? (QString::fromStdString(HSC_ticker) + ":") : "hush:" ) + req.cmbMyAddress->currentText()
+ "?amt=" + Settings::getDecimalString(req.txtAmount->text().toDouble())
+ "&memo=" + QUrl::toPercentEncoding(req.txtMemo->toPlainText());
QString sendURI = (isdragonx ? "drgx:" : "hush:" ) + AddressBook::addressFromAddressLabel(req.txtFrom->text())
QString sendURI = (isHSC ? (QString::fromStdString(HSC_ticker) + ":") : "hush:" ) + AddressBook::addressFromAddressLabel(req.txtFrom->text())
+ "?amt=0.0001"
+ "&memo=" + QUrl::toPercentEncoding(memoURI);

26
src/rpc.cpp

@ -9,7 +9,9 @@
#include <QThread>
#include "sd.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string App_title;
extern std::string HSC_name;
RPC::RPC(MainWindow* main) {
auto cl = new ConnectionLoader(main, this);
@ -775,7 +777,7 @@ void RPC::getInfoThenRefresh(bool force) {
int blocks_until_halving= 2020000 - curBlock;
char halving_days[8];
int blocktime = 75; // seconds
if(isdragonx) {
if (isHSC) {
blocks_until_halving= 3500000 - curBlock;
blocktime = 60;
}
@ -874,7 +876,7 @@ void RPC::getInfoThenRefresh(bool force) {
QString genproclimit = QString::number( reply["genproclimit"].toInt() );
// Update network hashrate in "Node Info" tab
if(isdragonx) {
if (isHSC) {
ui->solrate->setText(QString::number(networkhashps.toDouble()) % " Hash/s");
} else {
ui->solrate->setText(QString::number(networkhashps.toDouble() / 1000000) % " MegaSol/s");
@ -1024,7 +1026,7 @@ void RPC::getInfoThenRefresh(bool force) {
QString price = "";
// No price data for dragonx for now
if (!isdragonx) {
if (!isHSC) {
auto ticker_price = s->get_price(ticker);
if(ticker_price > 0 && ticker != "BTC") {
extra = QString::number( s->getBTCPrice() ) % "sat";
@ -1054,7 +1056,7 @@ void RPC::getInfoThenRefresh(bool force) {
}
tooltip = tooltip % "(v" % QString::number(Settings::getInstance()->getHushdVersion()) % ")";
if (!isdragonx && !hushPrice.isEmpty()) {
if (!isHSC && !hushPrice.isEmpty()) {
tooltip = "1 HUSH = " % hushPrice % "\n" % tooltip;
}
main->statusLabel->setToolTip(tooltip);
@ -1551,7 +1553,7 @@ void RPC::refreshPrice() {
if (conn == nullptr)
return noConnection();
if (isdragonx) {
if (isHSC) {
return;
}
@ -1689,8 +1691,8 @@ void RPC::shutdownHushd() {
Ui_ConnectionDialog connD;
connD.setupUi(&d);
//connD.topIcon->setBasePixmap(QIcon(":/icons/icon.ico").pixmap(256, 256));
if(isdragonx) {
d.setWindowTitle("SilentDragonX");
if(isHSC) {
d.setWindowTitle(QString::fromStdString(App_title));
}
QMovie *movie1 = new QMovie(":/img/silentdragon-animated-dark.gif");;
@ -1699,9 +1701,11 @@ void RPC::shutdownHushd() {
connD.topIcon->setMovie(movie1);
movie1->start();
if(isdragonx) {
connD.status->setText(QObject::tr("Please enhance your calm and wait for SilentDragonX to exit"));
connD.statusDetail->setText(QObject::tr("Waiting for dragonxd to exit, y'all"));
if (isHSC) {
std::string exit_message = "Please enhance your calm and wait for " + App_title + " to exit";
std::string exit_detail = "Waiting for " + HSC_name + "d to exit, y'all";
connD.status->setText((QObject::tr(exit_message.c_str())));
connD.statusDetail->setText((QObject::tr(exit_detail.c_str())));
} else {
connD.status->setText(QObject::tr("Please enhance your calm and wait for SilentDragon to exit"));
connD.statusDetail->setText(QObject::tr("Waiting for hushd to exit, y'all"));

8
src/senttxstore.cpp

@ -3,13 +3,15 @@
#include "senttxstore.h"
#include "settings.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_ticker;
/// Get the location of the app data file to be written.
QString SentTxStore::writeableFile() {
auto filename = QStringLiteral("senttxstore.dat");
if (isdragonx) {
filename = QStringLiteral("senttxstore-drgx.dat");
if (isHSC) {
std::string ticker = ("senttxstore-" + HSC_ticker + ".dat");
filename = QString::fromStdString(ticker);
}
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));

24
src/settings.cpp

@ -5,7 +5,9 @@
#include "sd.h"
#include <QUrlQuery>
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_explorer;
extern std::string HSC_ticker;
Settings* Settings::instance = nullptr;
@ -43,8 +45,8 @@ Explorer Settings::getExplorer() {
//TODO: make it easy for people to use other explorers
QString explorer = "https://explorer.hush.is";
if(isdragonx) {
explorer = "https://explorer.dragonx.is";
if (isHSC) {
explorer = QString::fromStdString(HSC_explorer);
}
QString onionExplorer = "http://jlqhwhak65kokg3pdjp3ufy6almf5spnhsfnugtjsc4z7wtapgozxyad.onion";
@ -340,8 +342,8 @@ QString Settings::getHUSHUSDDisplayFormat(double bal) {
const QString Settings::txidStatusMessage = QString(QObject::tr("Transaction submitted (right click to copy) txid:"));
QString Settings::getTokenName() {
if (isdragonx) {
return "DRGX";
if (isHSC) {
return QString::fromStdString(HSC_ticker);
}
if (Settings::getInstance()->isTestnet()) {
return "TUSH";
@ -465,10 +467,12 @@ PaymentURI Settings::parseURI(QString uri) {
PaymentURI ans;
auto proto="";
if (isdragonx) {
proto ="drgx:";
if (isHSC) {
std::string ticker = HSC_ticker + ":";
proto = ((ticker.c_str()));
if (!uri.startsWith(proto % QString(":"))) {
ans.error = "Not a DRGX payment URI";
std::string not_a_uri = "Not a " + HSC_ticker + " payment URI";
ans.error = (not_a_uri.c_str());
return ans;
}
} else {
@ -481,8 +485,8 @@ PaymentURI Settings::parseURI(QString uri) {
uri = uri.right(uri.length() - QString("hush:").length());
if(isdragonx) {
uri = uri.right(uri.length() - QString("drgx:").length());
if (isHSC) {
uri = uri.right((uri.length() - QString(QString::fromStdString(HSC_ticker) % ":").length()));
}
QRegExp re("([a-zA-Z0-9]+)");

11
src/txtablemodel.cpp

@ -5,7 +5,9 @@
#include "rpc.h"
#include "guiconstants.h"
extern bool isdragonx;
extern bool isHSC;
extern std::string HSC_ticker;
extern std::string HSC_default_theme;
TxTableModel::TxTableModel(QObject *parent)
: QAbstractTableModel(parent) {
@ -131,7 +133,7 @@ int TxTableModel::columnCount(const QModelIndex&) const
QColor color;
if (theme_name == "dark" || theme_name == "midnight") {
color = COLOR_WHITE;
}else if(theme_name == "dragonx"){
}else if (theme_name == (QString::fromStdString(HSC_default_theme))){
color = COLOR_DRAGONX_TEXT;
}else{
color = COLOR_BLACK;
@ -199,8 +201,9 @@ int TxTableModel::columnCount(const QModelIndex&) const
if (!dat.memo.isEmpty()) {
// If the memo is a Payment URI, then show a payment request icon
if(isdragonx) {
if (dat.memo.startsWith("drgx:")) {
if (isHSC) {
std::string ticker = "" + HSC_ticker + ":";
if (dat.memo.startsWith(ticker.c_str())) {
QIcon icon(":/icons/paymentreq.gif");
return QVariant(icon.pixmap(16, 16));
}

Loading…
Cancel
Save