From 18fe61117b4bd3b951f3f898f5dfd7b3d721de32 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Tue, 13 Jun 2023 19:17:11 +0200 Subject: [PATCH] xmrig: allow adding additional command line options --- src/plugins/xmrig/XMRigWidget.cpp | 16 +++++++++------- src/plugins/xmrig/XMRigWidget.ui | 10 ++++++++++ src/plugins/xmrig/xmrig.cpp | 8 ++++++-- src/plugins/xmrig/xmrig.h | 2 +- src/utils/config.cpp | 1 + src/utils/config.h | 1 + 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/plugins/xmrig/XMRigWidget.cpp b/src/plugins/xmrig/XMRigWidget.cpp index f3c676f..33928e3 100644 --- a/src/plugins/xmrig/XMRigWidget.cpp +++ b/src/plugins/xmrig/XMRigWidget.cpp @@ -90,6 +90,11 @@ XMRigWidget::XMRigWidget(Wallet *wallet, QWidget *parent) this->updatePools(); }); + ui->lineEdit_solo->setText(config()->get(Config::xmrigDaemon).toString()); + connect(ui->lineEdit_solo, &QLineEdit::textChanged, [this](){ + config()->set(Config::xmrigDaemon, ui->lineEdit_solo->text()); + }); + // Network settings connect(ui->check_tls, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTLSToggled); connect(ui->relayTor, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTorToggled); @@ -108,12 +113,7 @@ XMRigWidget::XMRigWidget(Wallet *wallet, QWidget *parent) // Password auto password = m_wallet->getCacheAttribute("feather.xmrig_password"); - if (!password.isEmpty()) { - ui->lineEdit_password->setText(password); - } else { - ui->lineEdit_password->setText("featherwallet"); - m_wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text()); - } + ui->lineEdit_password->setText(password); connect(ui->lineEdit_password, &QLineEdit::textChanged, [=]() { m_wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text()); }); @@ -208,9 +208,11 @@ void XMRigWidget::onStartClicked() { } int threads = ui->threadSlider->value(); + bool solo = (ui->combo_miningMode->currentIndex() == Config::MiningMode::Solo); + QStringList extraOptions = ui->lineEdit_extraOptions->text().split(" "); m_XMRig->start(xmrigPath, threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked(), - ui->radio_elevateYes->isChecked()); + ui->radio_elevateYes->isChecked(), solo, extraOptions); } void XMRigWidget::onStopClicked() { diff --git a/src/plugins/xmrig/XMRigWidget.ui b/src/plugins/xmrig/XMRigWidget.ui index 512a0ca..b3642a9 100644 --- a/src/plugins/xmrig/XMRigWidget.ui +++ b/src/plugins/xmrig/XMRigWidget.ui @@ -419,6 +419,16 @@ + + + + Extra command-line options: + + + + + + diff --git a/src/plugins/xmrig/xmrig.cpp b/src/plugins/xmrig/xmrig.cpp index aa19945..d4e5118 100644 --- a/src/plugins/xmrig/xmrig.cpp +++ b/src/plugins/xmrig/xmrig.cpp @@ -35,7 +35,7 @@ void XmRig::stop() { } void XmRig::start(const QString &path, int threads, const QString &address, const QString &username, - const QString &password, bool tor, bool tls, bool elevated) + const QString &password, bool tor, bool tls, bool elevated, bool solo, const QStringList &extraOptions) { m_elevated = elevated; @@ -60,7 +60,6 @@ void XmRig::start(const QString &path, int threads, const QString &address, cons arguments << path; } arguments << "-o" << address; - arguments << "-a" << "rx/0"; arguments << "-u" << username; if (!password.isEmpty()) { arguments << "-p" << password; @@ -79,6 +78,11 @@ void XmRig::start(const QString &path, int threads, const QString &address, cons if (tls) { arguments << "--tls"; } + if (solo) { + arguments << "--daemon"; + } + arguments += extraOptions; + QString cmd = QString("%1 %2").arg(path, arguments.join(" ")); emit output(cmd.toUtf8()); diff --git a/src/plugins/xmrig/xmrig.h b/src/plugins/xmrig/xmrig.h index 03f182e..3687214 100644 --- a/src/plugins/xmrig/xmrig.h +++ b/src/plugins/xmrig/xmrig.h @@ -13,7 +13,7 @@ Q_OBJECT public: explicit XmRig(const QString &configDir, QObject *parent = nullptr); - void start(const QString &path, int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true, bool elevated = false); + void start(const QString &path, int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true, bool elevated = false, bool solo = false, const QStringList &extraOptions = {}); void stop(); signals: diff --git a/src/utils/config.cpp b/src/utils/config.cpp index 47c5a1c..a89ec68 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -54,6 +54,7 @@ static const QHash configStrings = { {Config::xmrigElevated,{QS("xmrigElevated"), false}}, {Config::xmrigThreads,{QS("xmrigThreads"), 1}}, {Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:9000"}}, + {Config::xmrigDaemon,{QS("xmrigDaemon"), "127.0.0.1:18081"}}, {Config::xmrigNetworkTLS,{QS("xmrigNetworkTLS"), true}}, {Config::xmrigNetworkTor,{QS("xmrigNetworkTor"), false}}, {Config::pools,{QS("pools"), {}}}, diff --git a/src/utils/config.h b/src/utils/config.h index ff7d208..d97a678 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -57,6 +57,7 @@ public: xmrigElevated, xmrigThreads, xmrigPool, + xmrigDaemon, xmrigNetworkTLS, xmrigNetworkTor, pools,