xmrig: allow adding additional command line options

This commit is contained in:
tobtoht 2023-06-13 19:17:11 +02:00
parent f8a3df1489
commit 18fe61117b
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
6 changed files with 28 additions and 10 deletions

View file

@ -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() {

View file

@ -419,6 +419,16 @@
<item row="7" column="1">
<widget class="QLineEdit" name="lineEdit_password"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Extra command-line options:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_extraOptions"/>
</item>
</layout>
</item>
</layout>

View file

@ -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());

View file

@ -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:

View file

@ -54,6 +54,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> 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"), {}}},

View file

@ -57,6 +57,7 @@ public:
xmrigElevated,
xmrigThreads,
xmrigPool,
xmrigDaemon,
xmrigNetworkTLS,
xmrigNetworkTor,
pools,