mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-19 16:18:39 +02:00
- Embed XMRig executable (baked into buildbot image)
- Refactored CMake related to Tor/XMRig - Move executables to `src/assets/exec` - Embedding executables require passing definition to CMake, e.g: - `-DTOR=/path/to/tor` - `-DXMRIG=/path/to/xmrig` - Allow solo mining for XMRig - Redesign XMRig settings screen
This commit is contained in:
+18
-15
@@ -42,14 +42,16 @@ file(GLOB SOURCE_FILES
|
||||
"dialog/*.cpp"
|
||||
)
|
||||
|
||||
if((APPLE AND BUILD_TOR) OR (APPLE AND "$ENV{DRONE}" STREQUAL "true"))
|
||||
set(ASSETS_OS "assets_macos_tor.qrc")
|
||||
elseif(UNIX AND NOT APPLE AND BUILD_TOR)
|
||||
set(ASSETS_OS "assets_linux_tor.qrc")
|
||||
elseif(MINGW AND BUILD_TOR)
|
||||
set(ASSETS_OS "assets_windows_tor.qrc")
|
||||
else()
|
||||
message(STATUS "Building without embedded Tor")
|
||||
if(TOR)
|
||||
if(APPLE)
|
||||
set(ASSETS_TOR "assets_tor_macos.qrc")
|
||||
else()
|
||||
set(ASSETS_TOR "assets_tor.qrc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(XMRIG)
|
||||
set(ASSETS_XMRIG "assets_mining.qrc")
|
||||
endif()
|
||||
|
||||
set(EXECUTABLE_FLAG)
|
||||
@@ -74,7 +76,8 @@ endif()
|
||||
add_executable(feather ${EXECUTABLE_FLAG} main.cpp
|
||||
${SOURCE_FILES}
|
||||
${RESOURCES}
|
||||
${ASSETS_OS}
|
||||
${ASSETS_TOR}
|
||||
${ASSETS_XMRIG}
|
||||
)
|
||||
|
||||
# mac os bundle
|
||||
@@ -122,16 +125,16 @@ if(DONATE_BEG)
|
||||
target_compile_definitions(feather PRIVATE DONATE_BEG=1)
|
||||
endif()
|
||||
|
||||
if(BUILD_TOR)
|
||||
target_compile_definitions(feather PRIVATE BUILD_TOR=1)
|
||||
endif()
|
||||
|
||||
if(XMRTO)
|
||||
target_compile_definitions(feather PRIVATE XMRTO=1)
|
||||
endif()
|
||||
|
||||
if(XMRig)
|
||||
target_compile_definitions(feather PRIVATE MINING=1)
|
||||
if(TOR)
|
||||
target_compile_definitions(feather PRIVATE HAS_TOR=1)
|
||||
endif()
|
||||
|
||||
if(XMRIG)
|
||||
target_compile_definitions(feather PRIVATE HAS_XMRIG=1)
|
||||
endif()
|
||||
|
||||
if(HAVE_SYS_PRCTL_H)
|
||||
|
||||
+17
-24
@@ -147,10 +147,17 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
|
||||
AppContext::prices = new Prices();
|
||||
|
||||
// xmr.to
|
||||
#if defined(XMRTO)
|
||||
#ifdef XMRTO
|
||||
this->XMRTo = new XmrTo(this);
|
||||
#endif
|
||||
|
||||
// XMRig
|
||||
#ifdef HAS_XMRIG
|
||||
this->XMRig = new XmRig(this->configDirectory, this);
|
||||
if(!this->isTails)
|
||||
this->XMRig->prepare();
|
||||
#endif
|
||||
|
||||
this->walletManager = WalletManager::instance();
|
||||
QString logPath = QString("%1/daemon.log").arg(configDirectory);
|
||||
Monero::Utils::onStartup();
|
||||
@@ -393,7 +400,7 @@ void AppContext::onWSMessage(const QJsonObject &msg) {
|
||||
else if(cmd == "nodes") {
|
||||
this->onWSNodes(msg.value("data").toArray());
|
||||
}
|
||||
#if defined(MINING)
|
||||
#if defined(HAS_XMRIG)
|
||||
else if(cmd == "xmrig") {
|
||||
this->XMRigDownloads(msg.value("data").toObject());
|
||||
}
|
||||
@@ -511,31 +518,17 @@ void AppContext::onWSCCS(const QJsonArray &ccs_data) {
|
||||
}
|
||||
|
||||
void AppContext::createConfigDirectory(const QString &dir) {
|
||||
if(!Utils::dirExists(dir)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(dir);
|
||||
if(!QDir().mkpath(dir))
|
||||
throw std::runtime_error("Could not create directory " + dir.toStdString());
|
||||
}
|
||||
|
||||
QString config_dir_tor = QString("%1%2").arg(dir).arg("tor");
|
||||
if(!Utils::dirExists(config_dir_tor)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(config_dir_tor);
|
||||
if (!QDir().mkpath(config_dir_tor))
|
||||
throw std::runtime_error("Could not create directory " + config_dir_tor.toStdString());
|
||||
}
|
||||
|
||||
QString config_dir_tordata = QString("%1%2").arg(dir).arg("tor/data");
|
||||
if(!Utils::dirExists(config_dir_tordata)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(config_dir_tordata);
|
||||
if (!QDir().mkpath(config_dir_tordata))
|
||||
throw std::runtime_error("Could not create directory " + config_dir_tordata.toStdString());
|
||||
}
|
||||
QString config_dir_xmrig = QString("%1%2").arg(dir).arg("xmrig");
|
||||
|
||||
QString config_dir_torsocks = QString("%1%2").arg(dir).arg("torsocks");
|
||||
if(!Utils::dirExists(config_dir_torsocks)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(config_dir_torsocks);
|
||||
if (!QDir().mkpath(config_dir_torsocks))
|
||||
throw std::runtime_error("Could not create directory " + config_dir_torsocks.toStdString());
|
||||
QStringList createDirs({dir, config_dir_tor, config_dir_tordata, config_dir_xmrig});
|
||||
for(const auto &d: createDirs) {
|
||||
if(!Utils::dirExists(d)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(d);
|
||||
if (!QDir().mkpath(d))
|
||||
throw std::runtime_error("Could not create directory " + d.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "utils/networking.h"
|
||||
#include "utils/tor.h"
|
||||
#include "utils/xmrto.h"
|
||||
#include "utils/xmrig.h"
|
||||
#include "utils/wsclient.h"
|
||||
#include "utils/txfiathistory.h"
|
||||
#include "widgets/RedditPost.h"
|
||||
@@ -78,6 +79,7 @@ public:
|
||||
Tor *tor;
|
||||
WSClient *ws;
|
||||
XmrTo *XMRTo;
|
||||
XmRig *XMRig;
|
||||
Nodes *nodes;
|
||||
static Prices *prices;
|
||||
static WalletKeysFilesModel *wallets;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>tor/tor</file>
|
||||
<file>tor/libevent-2.1.7.dylib</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>tor/tor.exe</file>
|
||||
<file>assets/exec/xmrig</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>tor/tor</file>
|
||||
<file>assets/exec/tor</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>assets/exec/tor</file>
|
||||
<file>assets/exec/libevent-2.1.7.dylib</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
+8
-6
@@ -22,12 +22,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(assets);
|
||||
|
||||
#if defined(Q_OS_MAC) && defined(BUILD_TOR)
|
||||
Q_INIT_RESOURCE(assets_macos_tor);
|
||||
#elif defined(Q_OS_LINUX) && defined(BUILD_TOR)
|
||||
Q_INIT_RESOURCE(assets_linux_tor);
|
||||
#elif defined(Q_OS_WIN) && defined(BUILD_TOR)
|
||||
Q_INIT_RESOURCE(assets_windows_tor);
|
||||
#if defined(Q_OS_MAC) && defined(HAS_TOR)
|
||||
Q_INIT_RESOURCE(assets_tor_macos);
|
||||
#elif defined(HAS_TOR)
|
||||
Q_INIT_RESOURCE(assets_tor);
|
||||
#endif
|
||||
|
||||
#if defined(HAS_XMRIG)
|
||||
Q_INIT_RESOURCE(assets_mining);
|
||||
#endif
|
||||
|
||||
QStringList argv_;
|
||||
|
||||
+9
-2
@@ -167,13 +167,20 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
|
||||
connect(m_ctx->nodes, &Nodes::WSNodeExhausted, this, &MainWindow::showWSNodeExhaustedMessage);
|
||||
|
||||
// XMRig
|
||||
#ifdef HAS_XMRIG
|
||||
m_xmrig = new XMRigWidget(m_ctx, this);
|
||||
ui->xmrRigLayout->addWidget(m_xmrig);
|
||||
connect(m_ctx->XMRig, &XmRig::output, m_xmrig, &XMRigWidget::onProcessOutput);
|
||||
connect(m_ctx->XMRig, &XmRig::error, m_xmrig, &XMRigWidget::onProcessError);
|
||||
connect(m_ctx->XMRig, &XmRig::hashrate, m_xmrig, &XMRigWidget::onHashrate);
|
||||
|
||||
connect(m_ctx, &AppContext::walletClosed, m_xmrig, &XMRigWidget::onWalletClosed);
|
||||
connect(m_ctx, &AppContext::walletOpened, m_xmrig, &XMRigWidget::onWalletOpened);
|
||||
connect(m_ctx, &AppContext::XMRigDownloads, m_xmrig, &XMRigWidget::onDownloads);
|
||||
connect(m_ctx, &AppContext::walletClosed, m_xmrig, &XMRigWidget::onWalletClosed);
|
||||
|
||||
connect(m_xmrig, &XMRigWidget::miningStarted, [=]{ m_ctx->setWindowTitle(true); });
|
||||
connect(m_xmrig, &XMRigWidget::miningEnded, [=]{ m_ctx->setWindowTitle(false); });
|
||||
#endif
|
||||
|
||||
// CCS/Reddit widget
|
||||
m_ccsWidget = new CCSWidget(this);
|
||||
@@ -388,7 +395,7 @@ void MainWindow::initMenu() {
|
||||
ui->actionShow_xmr_to->setVisible(false);
|
||||
#endif
|
||||
|
||||
#if defined(MINING)
|
||||
#if defined(HAS_XMRIG)
|
||||
connect(ui->actionShow_XMRig, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map));
|
||||
m_tabShowHideMapper["XMRig"] = new ToggleTab(ui->tabXmrRig, "XMRig", "XMRig", ui->actionShow_XMRig, Config::showTabXMRig);
|
||||
m_tabShowHideSignalMapper->setMapping(ui->actionShow_XMRig, "XMRig");
|
||||
|
||||
+14
-14
@@ -43,9 +43,15 @@ Tor::Tor(AppContext *ctx, QObject *parent)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef HAS_TOR
|
||||
qCritical() << "Feather built without embedded Tor. Assuming --use-local-tor";
|
||||
this->localTor = true;
|
||||
return;
|
||||
#endif
|
||||
|
||||
bool unpacked = this->unpackBins();
|
||||
if (!unpacked) {
|
||||
qCritical() << "Feather built without embedded Tor. Assuming --use-local-tor";
|
||||
qCritical() << "Error unpacking embedded Tor. Assuming --use-local-tor";
|
||||
this->localTor = true;
|
||||
return;
|
||||
}
|
||||
@@ -175,11 +181,9 @@ void Tor::handleProcessError(QProcess::ProcessError error) {
|
||||
bool Tor::unpackBins() {
|
||||
QString torFile;
|
||||
|
||||
// @TODO: refactor for Mac OS - should compile Tor statically.
|
||||
#if defined(Q_OS_MAC) && defined(DRONE)
|
||||
// Tor on Mac requires libevent.dylib, borrowed the executable from
|
||||
// the official Tor Browser release for now.
|
||||
QString libEvent = ":/tor/libevent-2.1.7.dylib";
|
||||
// On MacOS write libevent to disk
|
||||
#if defined(Q_OS_MAC)
|
||||
QString libEvent = ":/assets/exec/libevent-2.1.7.dylib";
|
||||
if (Utils::fileExists(libEvent)) {
|
||||
QFile e(libEvent);
|
||||
QFileInfo eventInfo(e);
|
||||
@@ -190,18 +194,15 @@ bool Tor::unpackBins() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
|
||||
torFile = ":/tor/tor";
|
||||
#elif defined(Q_OS_WIN)
|
||||
torFile = ":/tor/tor.exe";
|
||||
#endif
|
||||
|
||||
torFile = ":/assets/exec/tor";
|
||||
if (!Utils::fileExists(torFile))
|
||||
return false;
|
||||
|
||||
// write to disk
|
||||
QFile f(torFile);
|
||||
QFileInfo fileInfo(f);
|
||||
this->torPath = QDir(this->torDir).filePath(fileInfo.fileName());
|
||||
qDebug() << this->torPath;
|
||||
qDebug() << "Writing Tor executable to " << this->torPath;
|
||||
f.copy(torPath);
|
||||
f.close();
|
||||
|
||||
@@ -209,7 +210,6 @@ bool Tor::unpackBins() {
|
||||
QFile torBin(this->torPath);
|
||||
torBin.setPermissions(QFile::ExeGroup | QFile::ExeOther | QFile::ExeOther | QFile::ExeUser);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+50
-20
@@ -13,28 +13,37 @@
|
||||
#include "appcontext.h"
|
||||
|
||||
|
||||
XMRig::XMRig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
qDebug() << "Using embedded tor instance";
|
||||
m_process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(&m_process, &QProcess::readyReadStandardOutput, this, &XMRig::handleProcessOutput);
|
||||
connect(&m_process, &QProcess::errorOccurred, this, &XMRig::handleProcessError);
|
||||
connect(&m_process, &QProcess::stateChanged, this, &XMRig::stateChanged);
|
||||
XmRig::XmRig(const QString &configDir, QObject *parent) : QObject(parent) {
|
||||
this->rigDir = QDir(configDir).filePath("xmrig");
|
||||
}
|
||||
|
||||
void XMRig::stop() {
|
||||
void XmRig::prepare() {
|
||||
// unpack and set process signals
|
||||
|
||||
if(!this->unpackBins()) {
|
||||
qCritical() << "failed to write XMRig to config directory";
|
||||
return;
|
||||
}
|
||||
|
||||
m_process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
connect(&m_process, &QProcess::readyReadStandardOutput, this, &XmRig::handleProcessOutput);
|
||||
connect(&m_process, &QProcess::errorOccurred, this, &XmRig::handleProcessError);
|
||||
connect(&m_process, &QProcess::stateChanged, this, &XmRig::stateChanged);
|
||||
}
|
||||
|
||||
void XmRig::stop() {
|
||||
if(m_process.state() == QProcess::Running)
|
||||
m_process.kill();
|
||||
}
|
||||
|
||||
void XMRig::terminate() {
|
||||
void XmRig::terminate() {
|
||||
if(m_process.state() == QProcess::Running)
|
||||
m_process.terminate();
|
||||
}
|
||||
|
||||
void XMRig::start(unsigned int threads,
|
||||
const QString &pool_name,
|
||||
void XmRig::start(const QString &path,
|
||||
unsigned int threads,
|
||||
const QString &address,
|
||||
const QString &username,
|
||||
const QString &password,
|
||||
bool tor, bool tls) {
|
||||
@@ -44,22 +53,22 @@ void XMRig::start(unsigned int threads,
|
||||
return;
|
||||
}
|
||||
|
||||
auto path = config()->get(Config::xmrigPath).toString();
|
||||
if(path.isEmpty()) {
|
||||
emit error("Please set path to XMRig binary before starting.");
|
||||
emit error("XmRig->Start path parameter missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Utils::fileExists(path)) {
|
||||
emit error("Path to XMRig binary invalid; file does not exist.");
|
||||
emit error(QString("Path to XMRig binary invalid; file does not exist: %1").arg(path));
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList arguments;
|
||||
arguments << "-o" << pool_name;
|
||||
arguments << "-o" << address;
|
||||
arguments << "-a" << "rx/0";
|
||||
arguments << "-u" << username;
|
||||
arguments << "-p" << password;
|
||||
if(!password.isEmpty())
|
||||
arguments << "-p" << password;
|
||||
arguments << "--no-color";
|
||||
arguments << "-t" << QString::number(threads);
|
||||
if(tor)
|
||||
@@ -72,14 +81,14 @@ void XMRig::start(unsigned int threads,
|
||||
m_process.start(path, arguments);
|
||||
}
|
||||
|
||||
void XMRig::stateChanged(QProcess::ProcessState state) {
|
||||
void XmRig::stateChanged(QProcess::ProcessState state) {
|
||||
if(state == QProcess::ProcessState::Running)
|
||||
emit output("XMRig started");
|
||||
else if (state == QProcess::ProcessState::NotRunning)
|
||||
emit output("XMRig stopped");
|
||||
}
|
||||
|
||||
void XMRig::handleProcessOutput() {
|
||||
void XmRig::handleProcessOutput() {
|
||||
QByteArray _output = m_process.readAllStandardOutput();
|
||||
if(_output.contains("miner") && _output.contains("speed")) {
|
||||
// detect hashrate
|
||||
@@ -93,7 +102,7 @@ void XMRig::handleProcessOutput() {
|
||||
emit output(_output);
|
||||
}
|
||||
|
||||
void XMRig::handleProcessError(QProcess::ProcessError err) {
|
||||
void XmRig::handleProcessError(QProcess::ProcessError err) {
|
||||
if (err == QProcess::ProcessError::Crashed)
|
||||
emit error("XMRig crashed or killed");
|
||||
else if (err == QProcess::ProcessError::FailedToStart) {
|
||||
@@ -102,3 +111,24 @@ void XMRig::handleProcessError(QProcess::ProcessError err) {
|
||||
}
|
||||
}
|
||||
|
||||
bool XmRig::unpackBins() {
|
||||
QString rigFile;
|
||||
|
||||
rigFile = ":/assets/exec/xmrig";
|
||||
if (!Utils::fileExists(rigFile))
|
||||
return false;
|
||||
|
||||
// write to disk
|
||||
QFile f(rigFile);
|
||||
QFileInfo fileInfo(f);
|
||||
this->rigPath = QDir(this->rigDir).filePath(fileInfo.fileName());
|
||||
qDebug() << "Writing XMRig executable to " << this->rigPath;
|
||||
f.copy(rigPath);
|
||||
f.close();
|
||||
|
||||
#if defined(Q_OS_UNIX)
|
||||
QFile torBin(this->rigPath);
|
||||
torBin.setPermissions(QFile::ExeGroup | QFile::ExeOther | QFile::ExeOther | QFile::ExeUser);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
+8
-3
@@ -15,16 +15,21 @@
|
||||
|
||||
#include "utils/childproc.h"
|
||||
|
||||
class XMRig : public QObject
|
||||
class XmRig : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XMRig(QObject *parent = nullptr);
|
||||
explicit XmRig(const QString &configDir, QObject *parent = nullptr);
|
||||
void prepare();
|
||||
|
||||
void start(unsigned int threads, const QString &pool_name, const QString &username, const QString &password, bool tor = false, bool tls = true);
|
||||
void start(const QString &path, unsigned int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true);
|
||||
void stop();
|
||||
void terminate();
|
||||
bool unpackBins();
|
||||
|
||||
QString rigDir;
|
||||
QString rigPath;
|
||||
|
||||
signals:
|
||||
void error(const QString &msg);
|
||||
|
||||
+65
-21
@@ -33,12 +33,6 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) :
|
||||
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &XMRigWidget::showContextMenu);
|
||||
connect(ui->tableView, &QTableView::doubleClicked, this, &XMRigWidget::linkClicked);
|
||||
|
||||
// XMRig core
|
||||
m_rig = new XMRig(this);
|
||||
connect(m_rig, &XMRig::output, this, &XMRigWidget::onProcessOutput);
|
||||
connect(m_rig, &XMRig::error, this, &XMRigWidget::onProcessError);
|
||||
connect(m_rig, &XMRig::hashrate, this, &XMRigWidget::onHashrate);
|
||||
|
||||
// threads
|
||||
ui->threadSlider->setMinimum(1);
|
||||
int threads = QThread::idealThreadCount();
|
||||
@@ -60,19 +54,29 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) :
|
||||
ui->relayTor->setChecked(false);
|
||||
ui->check_tls->setChecked(true);
|
||||
ui->label_status->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
ui->label_status->hide();
|
||||
ui->pathFrame->hide();
|
||||
ui->soloFrame->hide();
|
||||
ui->poolFrame->hide();
|
||||
|
||||
// XMRig binary
|
||||
auto path = config()->get(Config::xmrigPath).toString();
|
||||
ui->lineEdit_path->setText(path);
|
||||
ui->label_status->hide();
|
||||
if(path.isEmpty())
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
if(!path.isEmpty()) {
|
||||
ui->pathFrame->show();
|
||||
ui->check_custompath->setChecked(true);
|
||||
ui->lineEdit_path->setText(path);
|
||||
}
|
||||
|
||||
// pools
|
||||
ui->poolFrame->show();
|
||||
ui->combo_pools->insertItems(0, m_pools);
|
||||
auto preferredPool = config()->get(Config::xmrigPool).toString();
|
||||
if (m_pools.contains(preferredPool))
|
||||
ui->combo_pools->setCurrentIndex(m_pools.indexOf(preferredPool));
|
||||
else {
|
||||
preferredPool = m_pools.at(0);
|
||||
config()->set(Config::xmrigPool, preferredPool);
|
||||
}
|
||||
connect(ui->combo_pools, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &XMRigWidget::onPoolChanged);
|
||||
|
||||
// info
|
||||
@@ -81,18 +85,26 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) :
|
||||
ui->console->appendPlainText("Invalid path to XMRig binary detected. Please reconfigure on the Settings tab.");
|
||||
else
|
||||
ui->console->appendPlainText(QString("XMRig path set to %1").arg(path));
|
||||
ui->console->appendPlainText("Ready to mine.");
|
||||
if(m_ctx->isTails) {
|
||||
ui->console->appendPlainText("Mining not available on Tails.");
|
||||
ui->btn_start->setEnabled(false);
|
||||
}
|
||||
else
|
||||
ui->console->appendPlainText("Ready to mine.");
|
||||
|
||||
// username/password
|
||||
connect(ui->lineEdit_password, &QLineEdit::editingFinished, [=]() {
|
||||
m_ctx->currentWallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
|
||||
m_ctx->currentWallet->store();
|
||||
});
|
||||
|
||||
connect(ui->lineEdit_address, &QLineEdit::editingFinished, [=]() {
|
||||
m_ctx->currentWallet->setCacheAttribute("feather.xmrig_username", ui->lineEdit_address->text());
|
||||
m_ctx->currentWallet->store();
|
||||
});
|
||||
|
||||
// checkbox connects
|
||||
connect(ui->check_custompath, &QCheckBox::stateChanged, this, &XMRigWidget::onCustomPathChecked);
|
||||
connect(ui->check_solo, &QCheckBox::stateChanged, this, &XMRigWidget::onSoloChecked);
|
||||
}
|
||||
|
||||
void XMRigWidget::onWalletClosed() {
|
||||
@@ -140,30 +152,40 @@ void XMRigWidget::onClearClicked() {
|
||||
}
|
||||
|
||||
void XMRigWidget::onStartClicked() {
|
||||
auto pool_name = config()->get(Config::xmrigPool).toString();
|
||||
QString xmrigPath;
|
||||
bool solo = ui->check_solo->isChecked();
|
||||
bool customBinary = ui->check_custompath->isChecked();
|
||||
|
||||
// fix error in config
|
||||
if(!m_pools.contains(pool_name)) {
|
||||
pool_name = m_pools.at(0);
|
||||
config()->set(Config::xmrigPool, pool_name);
|
||||
}
|
||||
if(customBinary)
|
||||
xmrigPath = config()->get(Config::xmrigPath).toString();
|
||||
else
|
||||
xmrigPath = m_ctx->XMRig->rigPath;
|
||||
|
||||
// username is receiving address usually
|
||||
auto username = m_ctx->currentWallet->getCacheAttribute("feather.xmrig_username");
|
||||
auto password = m_ctx->currentWallet->getCacheAttribute("feather.xmrig_password");
|
||||
|
||||
if(username.isEmpty()) {
|
||||
Utils::showMessageBox("Error", "Please specify a receiving address on the Settings screen", true);
|
||||
QString err = "Please specify a receiving address on the Settings screen";
|
||||
ui->console->appendPlainText(err);
|
||||
Utils::showMessageBox("Error", err, true);
|
||||
return;
|
||||
}
|
||||
|
||||
m_rig->start(m_threads, pool_name, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked());
|
||||
QString address;
|
||||
if(solo)
|
||||
address = ui->lineEdit_solo->text().trimmed();
|
||||
else
|
||||
address = config()->get(Config::xmrigPool).toString();
|
||||
|
||||
m_ctx->XMRig->start(xmrigPath, m_threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked());
|
||||
ui->btn_start->setEnabled(false);
|
||||
ui->btn_stop->setEnabled(true);
|
||||
emit miningStarted();
|
||||
}
|
||||
|
||||
void XMRigWidget::onStopClicked() {
|
||||
m_rig->terminate();
|
||||
m_ctx->XMRig->terminate();
|
||||
ui->btn_start->setEnabled(true);
|
||||
ui->btn_stop->setEnabled(false);
|
||||
ui->label_status->hide();
|
||||
@@ -257,6 +279,28 @@ void XMRigWidget::showContextMenu(const QPoint &pos) {
|
||||
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void XMRigWidget::onCustomPathChecked(int state) {
|
||||
if(state == 2) {
|
||||
ui->pathFrame->show();
|
||||
} else {
|
||||
ui->lineEdit_path->setText("");
|
||||
config()->set(Config::xmrigPath, "");
|
||||
ui->pathFrame->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void XMRigWidget::onSoloChecked(int state) {
|
||||
if(state == 2) {
|
||||
ui->poolFrame->hide();
|
||||
ui->soloFrame->show();
|
||||
ui->check_tls->setChecked(false);
|
||||
}
|
||||
else {
|
||||
ui->poolFrame->show();
|
||||
ui->soloFrame->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void XMRigWidget::linkClicked() {
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
auto download_link = m_urls.at(index.row());
|
||||
|
||||
@@ -33,14 +33,16 @@ public slots:
|
||||
void onClearClicked();
|
||||
void onDownloads(const QJsonObject &data);
|
||||
void linkClicked();
|
||||
void onProcessError(const QString &msg);
|
||||
void onProcessOutput(const QByteArray &msg);
|
||||
void onHashrate(const QString &hashrate);
|
||||
void onCustomPathChecked(int state);
|
||||
void onSoloChecked(int state);
|
||||
|
||||
private slots:
|
||||
void onBrowseClicked();
|
||||
void onProcessError(const QString &msg);
|
||||
void onProcessOutput(const QByteArray &msg);
|
||||
void onThreadsValueChanged(int date);
|
||||
void onPoolChanged(int pos);
|
||||
void onHashrate(const QString &hashrate);
|
||||
|
||||
signals:
|
||||
void miningStarted();
|
||||
@@ -56,7 +58,6 @@ private:
|
||||
unsigned int m_threads;
|
||||
QStringList m_urls;
|
||||
QStringList m_pools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999"};
|
||||
XMRig *m_rig;
|
||||
};
|
||||
|
||||
#endif // REDDITWIDGET_H
|
||||
|
||||
+267
-91
@@ -29,7 +29,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@@ -125,86 +125,13 @@
|
||||
<attribute name="title">
|
||||
<string>Settings</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Path to XMRig executable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_path"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_browse">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Pool</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QComboBox" name="combo_pools">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_tls">
|
||||
<property name="text">
|
||||
<string>TLS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="relayTor">
|
||||
<property name="text">
|
||||
<string>Tor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@@ -227,22 +154,8 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Pool worker name (optional)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -256,6 +169,204 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_solo">
|
||||
<property name="text">
|
||||
<string>Solo mine</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_custompath">
|
||||
<property name="text">
|
||||
<string>Custom XMRig executable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="pathFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_path">
|
||||
<property name="placeholderText">
|
||||
<string>/path/to/xmrig</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_browse">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="QFrame" name="poolFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Pool</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QComboBox" name="combo_pools">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="soloFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Node address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_solo">
|
||||
<property name="text">
|
||||
<string>127.0.0.1:18081</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@@ -266,6 +377,71 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_address"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Password (optional)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_tls">
|
||||
<property name="text">
|
||||
<string>TLS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="relayTor">
|
||||
<property name="text">
|
||||
<string>Tor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user