diff --git a/.drone.yml b/.drone.yml index 60ce72d..50e5a30 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ steps: - git config --global url."http://gitea:3000/".insteadOf https://git.wownero.com/ - git submodule update --init monero - git submodule update --init --recursive monero - - TOR="/usr/local/tor/bin/tor" XMRIG="/xmrig/xmrig" make -j8 release-static + - TOR_BIN="/usr/local/tor/bin/tor" make -j8 release-static environment: OPENSSL_ROOT_DIR: /usr/local/openssl/ CMAKEFLAGS_EXTRA: -DFETCH_DEPS=Off @@ -98,7 +98,7 @@ steps: - git config --global url."http://gitea:3000/".insteadOf https://git.wownero.com/ - git submodule update --init monero - git submodule update --init --recursive monero - - PATH="/mxe/usr/bin/:$PATH" TOR="/mxe/usr/x86_64-w64-mingw32.static/bin/tor.exe" XMRIG="/xmrig/xmrig.exe" make -j8 windows-mxe-release + - PATH="/mxe/usr/bin/:$PATH" TOR_BIN="/mxe/usr/x86_64-w64-mingw32.static/bin/tor.exe" make -j8 windows-mxe-release environment: CMAKEFLAGS_EXTRA: -DFETCH_DEPS=Off - name: deploy diff --git a/BUILDING.md b/BUILDING.md index 4229d3b..6b4fb74 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -35,7 +35,7 @@ Building the base image takes a while. You only need to build the base image onc #### 3. Build ```bash -docker run --rm -it -v $PWD:/feather --env OPENSSL_ROOT_DIR=/usr/local/openssl/ -w /feather feather:linux sh -c 'TOR="/usr/local/tor/bin/tor" XMRIG="/xmrig/xmrig" make release-static -j4' +docker run --rm -it -v $PWD:/feather --env OPENSSL_ROOT_DIR=/usr/local/openssl/ -w /feather feather:linux sh -c 'TOR_BIN="/usr/local/tor/bin/tor" make release-static -j4' ``` If you're re-running a build make sure to `rm -rf build/` first. @@ -73,7 +73,7 @@ Note: You only need to build the base image once. #### 3. Build ```bash -docker run --rm -it -v /tmp/ccache:/root/.ccache -v /root/feather:/feather -w /feather feather:win /bin/bash -c 'PATH="/mxe/usr/bin/:$PATH" TOR="/mxe/usr/x86_64-w64-mingw32.static/bin/tor.exe" XMRIG="/xmrig/xmrig.exe" make windows-mxe-release -j8' +docker run --rm -it -v /tmp/ccache:/root/.ccache -v PATH_TO_FEATHER:/feather -w /feather feather:win /bin/bash -c 'PATH="/mxe/usr/bin/:$PATH" TOR_BIN="/mxe/usr/x86_64-w64-mingw32.static/bin/tor.exe" make windows-mxe-release -j8' ``` Replace `PATH_TO_FEATHER` with the absolute path to Feather locally. @@ -103,4 +103,4 @@ Build Feather. CMAKE_PREFIX_PATH=~/Qt5.15.1/5.15.1/clang_64 make mac-release ``` -The resulting Mac OS application can be found `build/bin/feather.app` and will **not** have Tor embedded. \ No newline at end of file +The resulting Mac OS application can be found `build/bin/feather.app` and will **not** have Tor embedded. diff --git a/CMakeLists.txt b/CMakeLists.txt index 24fbfc3..c61a6b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,9 @@ set(VERSION "beta-1") option(FETCH_DEPS "Download dependencies if they are not found" ON) option(XMRTO "Include Xmr.To module" ON) option(MORPHTOKEN "Include MorphToken module" ON) -option(XMRIG "Path to XMRig binary to embed inside Feather" OFF) -option(TOR "Path to Tor binary to embed inside Feather" OFF) -option(TOR_VERSION "Optional git hash or tag of embedded Tor version" "tor-0.4.3.5") +option(XMRIG "Include XMRig module" ON) +option(TOR_BIN "Path to Tor binary to embed inside Feather" OFF) + option(STATIC "Link libraries statically, requires static Qt") option(USE_DEVICE_TREZOR "Trezor support compilation" OFF) option(DONATE_BEG "Prompt donation window every once in a while" ON) @@ -181,8 +181,8 @@ if("$ENV{DRONE}" STREQUAL "true") message(STATUS "We are inside a static compile with Drone CI") endif() -# To build Feather with embedded (and static) Tor, pass CMake -DTOR=/path/to/tor -if(TOR) +# To build Feather with embedded (and static) Tor, pass CMake -DTOR_BIN=/path/to/tor +if(TOR_BIN) if(APPLE) execute_process(COMMAND bash -c "touch ${CMAKE_CURRENT_SOURCE_DIR}/src/tor/libevent-2.1.7.dylib") endif() @@ -191,34 +191,16 @@ if(TOR) # - linux: See `Dockerfile` # - windows: https://github.com/mxe/mxe/blob/1024dc7d2db5eb7d5d3c64a2c12b5f592572f1ce/plugins/apps/tor.mk # - macos: taken from Tor Browser official release - set(TOR_COPY_CMD "cp ${TOR} ${CMAKE_CURRENT_SOURCE_DIR}/src/assets/exec/tor") + set(TOR_COPY_CMD "cp ${TOR_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/src/assets/exec/tor") message(STATUS "${TOR_COPY_CMD}") execute_process(COMMAND bash -c "${TOR_COPY_CMD}" RESULT_VARIABLE ret) if(ret EQUAL "1") message(FATAL_ERROR "Tor copy failure: ${TOR_COPY_CMD}") endif() - message(STATUS "Embedding Tor binary at ${TOR}") + message(STATUS "Embedding Tor binary at ${TOR_BIN}") else() - message(STATUS "Skipping Tor inclusion because -DTOR=Off") -endif() - -# To build Feather with embedded (and static) XMRig, pass CMake -DXMRIG=/path/to/xmrig -if(XMRIG) - # on the buildbot XMRig is baked into the image - # - linux: See `Dockerfile` - # - windows: See `Dockerfile_windows` - # - macos: manually downloaded an official release - set(XMRIG_COPY_CMD "cp ${XMRIG} ${CMAKE_CURRENT_SOURCE_DIR}/src/assets/exec/xmrig") - message(STATUS "${XMRIG_COPY_CMD}") - execute_process(COMMAND bash -c "${XMRIG_COPY_CMD}" RESULT_VARIABLE ret) - if(ret EQUAL "1") - message(FATAL_ERROR "XMRig copy failure: ${XMRIG_COPY_CMD}") - endif() - - message(STATUS "Embedding XMRig binary at ${XMRIG}") -else() - message(STATUS "Skipping XMRig inclusion because -DXMRIG=Off") + message(STATUS "Skipping Tor inclusion because -DTOR_BIN=Off") endif() if(MINGW) diff --git a/Dockerfile b/Dockerfile index fb95e3e..7bfdacf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -346,8 +346,3 @@ RUN git clone https://git.wownero.com/feather/monero-seed.git && \ make -Cbuild -j$THREADS && \ make -Cbuild install && \ rm -rf $(pwd) - -RUN apt install -y curl && \ - curl -LO "https://github.com/xmrig/xmrig/releases/download/v6.3.5/xmrig-6.3.5-linux-static-x64.tar.gz" && \ - echo "24d4f07cf5850f00ab513b228f95769a5a5ed68d35808d98f9959b58d97985a0 xmrig-6.3.5-linux-static-x64.tar.gz" | sha256sum -c && \ - tar xvf xmrig-6.3.5-linux-static-x64.tar.gz --one-top-level=/xmrig --strip 1 diff --git a/Dockerfile_windows b/Dockerfile_windows index 06c64fb..e81fa5e 100644 --- a/Dockerfile_windows +++ b/Dockerfile_windows @@ -72,10 +72,3 @@ RUN git clone https://git.wownero.com/feather/monero-seed.git && \ cmake -DCMAKE_BUILD_TYPE=Release -Bbuild && \ make -Cbuild -j$THREADS && \ make -Cbuild install - -RUN apt install -y curl && \ - curl -LO "https://github.com/xmrig/xmrig/releases/download/v6.3.5/xmrig-6.3.5-gcc-win64.zip" && \ - echo "e45915ada7e6e30f6ab40abf33831056449d5914307d7706bb0ad439b6d64c12 xmrig-6.3.5-gcc-win64.zip" > hashsum.txt && \ - sha256sum -c hashsum.txt && \ - unzip -q xmrig-6.3.5-gcc-win64.zip -d /xmrig && \ - mv /xmrig/xmrig-6.3.5/* /xmrig/ diff --git a/HACKING.md b/HACKING.md index e7112bf..6679d4d 100644 --- a/HACKING.md +++ b/HACKING.md @@ -42,9 +42,9 @@ via the `CMAKE_PREFIX_PATH` definition. For me this is: There are some Monero/Feather related options/definitions that you may pass: - `-DXMRTO=OFF` - disable Xmr.To feature -- `-DMORPHTOKEN=OFF` - diable MorphToken feature -- `-DTOR=/path/to/tor` - Embed a Tor executable inside Feather -- `-DXMRIG=/path/to/xmrig` - Embed a XMRig executable inside Feather +- `-DMORPHTOKEN=OFF` - disable MorphToken feature +- `-DXMRIG=OFF` - disable XMRig feature +- `-DTOR_BIN=/path/to/tor` - Embed a Tor executable inside Feather - `-DDONATE_BEG=OFF` - disable the dreaded donate requests And: diff --git a/Makefile b/Makefile index 046705f..837a0fc 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,10 @@ CMAKEFLAGS = \ -DARCH=x86_64 \ -DBUILD_64=On \ -DBUILD_TESTS=Off \ - -DXMRTO=ON \ - -DMORPHTOKEN=ON \ - -DXMRIG=Off \ - -DTOR=Off \ + -DXMRTO=On \ + -DMORPHTOKEN=On \ + -DXMRIG=On \ + -DTOR_BIN=Off \ -DCMAKE_CXX_STANDARD=11 \ -DCMAKE_VERBOSE_MAKEFILE=On \ -DINSTALL_VENDORED_LIBUNBOUND=Off \ @@ -43,32 +43,28 @@ CMAKEFLAGS = \ $(CMAKEFLAGS_EXTRA) release-static: CMAKEFLAGS += -DBUILD_TAG="linux-x64" -release-static: CMAKEFLAGS += -DTOR=$(or ${TOR},OFF) -release-static: CMAKEFLAGS += -DXMRIG=$(or ${XMRIG},OFF) +release-static: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF) release-static: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Release release-static: cmake -Bbuild $(CMAKEFLAGS) $(MAKE) -Cbuild windows-mxe-release: CMAKEFLAGS += -DBUILD_TAG="win-x64" -windows-mxe-release: CMAKEFLAGS += -DTOR=$(or ${TOR},OFF) -windows-mxe-release: CMAKEFLAGS += -DXMRIG=$(or ${XMRIG},OFF) +windows-mxe-release: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF) windows-mxe-release: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Release windows-mxe-release: cmake -Bbuild $(CMAKEFLAGS) $(MAKE) -Cbuild windows-mxe-debug: CMAKEFLAGS += -DBUILD_TAG="win-x64" -windows-mxe-debug: CMAKEFLAGS += -DTOR=$(or ${TOR},OFF) -windows-mxe-debug: CMAKEFLAGS += -DXMRIG=$(or ${XMRIG},OFF) +windows-mxe-debug: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF) windows-mxe-debug: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Debug windows-mxe-debug: cmake -Bbuild $(CMAKEFLAGS) $(MAKE) -Cbuild mac-release: CMAKEFLAGS += -DSTATIC=Off -mac-release: CMAKEFLAGS += -DTOR=$(or ${TOR},OFF) -mac-release: CMAKEFLAGS += -DXMRIG=$(or ${XMRIG},OFF) +mac-release: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF) mac-release: CMAKEFLAGS += -DBUILD_TAG="mac-x64" mac-release: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Release mac-release: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 321a4c2..1e3ef97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,7 @@ file(GLOB SOURCE_FILES "dialog/*.cpp" ) -if(TOR) +if(TOR_BIN) if(APPLE) set(ASSETS_TOR "assets_tor_macos.qrc") else() @@ -50,10 +50,6 @@ if(TOR) endif() endif() -if(XMRIG) - set(ASSETS_XMRIG "assets_mining.qrc") -endif() - set(EXECUTABLE_FLAG) if(MINGW) set(EXECUTABLE_FLAG WIN32) @@ -77,8 +73,7 @@ add_executable(feather ${EXECUTABLE_FLAG} main.cpp ${SOURCE_FILES} ${RESOURCES} ${ASSETS_TOR} - ${ASSETS_XMRIG} - ) +) # mac os bundle set_target_properties(feather PROPERTIES @@ -133,8 +128,8 @@ if(MORPHTOKEN) target_compile_definitions(feather PRIVATE HAS_MORPHTOKEN=1) endif() -if(TOR) - target_compile_definitions(feather PRIVATE HAS_TOR=1) +if(TOR_BIN) + target_compile_definitions(feather PRIVATE HAS_TOR_BIN=1) endif() if(XMRIG) diff --git a/src/appcontext.cpp b/src/appcontext.cpp index 37e9a9a..590c946 100644 --- a/src/appcontext.cpp +++ b/src/appcontext.cpp @@ -526,9 +526,8 @@ void AppContext::onWSCCS(const QJsonArray &ccs_data) { void AppContext::createConfigDirectory(const QString &dir) { QString config_dir_tor = QString("%1%2").arg(dir).arg("tor"); QString config_dir_tordata = QString("%1%2").arg(dir).arg("tor/data"); - QString config_dir_xmrig = QString("%1%2").arg(dir).arg("xmrig"); - QStringList createDirs({dir, config_dir_tor, config_dir_tordata, config_dir_xmrig}); + QStringList createDirs({dir, config_dir_tor, config_dir_tordata}); for(const auto &d: createDirs) { if(!Utils::dirExists(d)) { qDebug() << QString("Creating directory: %1").arg(d); diff --git a/src/assets_mining.qrc b/src/assets_mining.qrc deleted file mode 100644 index bbe426e..0000000 --- a/src/assets_mining.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - assets/exec/xmrig - - diff --git a/src/main.cpp b/src/main.cpp index a42749e..660b0cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,16 +26,12 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(assets); -#if defined(Q_OS_MAC) && defined(HAS_TOR) +#if defined(Q_OS_MAC) && defined(HAS_TOR_BIN) Q_INIT_RESOURCE(assets_tor_macos); -#elif defined(HAS_TOR) +#elif defined(HAS_TOR_BIN) Q_INIT_RESOURCE(assets_tor); #endif -#if defined(HAS_XMRIG) - Q_INIT_RESOURCE(assets_mining); -#endif - #ifdef _WIN32 if (AttachConsole(ATTACH_PARENT_PROCESS)) { freopen("CONOUT$", "w", stdout); diff --git a/src/utils/tor.cpp b/src/utils/tor.cpp index fcfff44..8430be9 100644 --- a/src/utils/tor.cpp +++ b/src/utils/tor.cpp @@ -43,7 +43,7 @@ Tor::Tor(AppContext *ctx, QObject *parent) return; } -#ifndef HAS_TOR +#ifndef HAS_TOR_BIN qCritical() << "Feather built without embedded Tor. Assuming --use-local-tor"; this->localTor = true; return; diff --git a/src/utils/xmrig.cpp b/src/utils/xmrig.cpp index 994d60e..702f868 100644 --- a/src/utils/xmrig.cpp +++ b/src/utils/xmrig.cpp @@ -9,22 +9,13 @@ #include "utils/utils.h" #include "utils/xmrig.h" - #include "appcontext.h" - XmRig::XmRig(const QString &configDir, QObject *parent) : QObject(parent) { this->rigDir = QDir(configDir).filePath("xmrig"); } 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); @@ -110,29 +101,3 @@ void XmRig::handleProcessError(QProcess::ProcessError err) { emit error(QString("XMRig binary failed to start: %1").arg(path)); } } - -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()); -#if defined(Q_OS_WIN) - if(!this->rigPath.endsWith(".exe")) - this->rigPath += ".exe"; -#endif - qDebug() << "Writing XMRig executable to " << this->rigPath; - f.copy(rigPath); - f.close(); - -#if defined(Q_OS_UNIX) - QFile rigBin(this->rigPath); - rigBin.setPermissions(QFile::ExeGroup | QFile::ExeOther | QFile::ExeOther | QFile::ExeUser); -#endif - return true; -} diff --git a/src/widgets/xmrigwidget.cpp b/src/widgets/xmrigwidget.cpp index 0795440..8f0dac4 100644 --- a/src/widgets/xmrigwidget.cpp +++ b/src/widgets/xmrigwidget.cpp @@ -36,7 +36,7 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) : // threads ui->threadSlider->setMinimum(1); int threads = QThread::idealThreadCount(); - m_threads = (unsigned int) threads / 2; + m_threads = threads / 2; ui->threadSlider->setMaximum(threads); ui->threadSlider->setValue(m_threads); ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads)); @@ -55,15 +55,12 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) : 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(); if(!path.isEmpty()) { - ui->pathFrame->show(); - ui->check_custompath->setChecked(true); ui->lineEdit_path->setText(path); } @@ -99,7 +96,6 @@ XMRigWidget::XMRigWidget(AppContext *ctx, QWidget *parent) : }); // checkbox connects - connect(ui->check_custompath, &QCheckBox::stateChanged, this, &XMRigWidget::onCustomPathChecked); connect(ui->check_solo, &QCheckBox::stateChanged, this, &XMRigWidget::onSoloChecked); } @@ -127,7 +123,7 @@ void XMRigWidget::onWalletOpened(){ } void XMRigWidget::onThreadsValueChanged(int threads) { - m_threads = (unsigned int) threads; + m_threads = threads; ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads)); } @@ -150,12 +146,7 @@ void XMRigWidget::onClearClicked() { void XMRigWidget::onStartClicked() { QString xmrigPath; bool solo = ui->check_solo->isChecked(); - bool customBinary = ui->check_custompath->isChecked(); - - if(customBinary) - xmrigPath = config()->get(Config::xmrigPath).toString(); - else - xmrigPath = m_ctx->XMRig->rigPath; + xmrigPath = config()->get(Config::xmrigPath).toString(); // username is receiving address usually auto username = m_ctx->currentWallet->getCacheAttribute("feather.xmrig_username"); @@ -245,7 +236,7 @@ void XMRigWidget::onDownloads(const QJsonObject &data) { os_assets = const_cast(&_linux); } - unsigned int i = 0; + int i = 0; for(const auto &entry: *os_assets) { auto _obj = entry.toObject(); auto _name = _obj.value("name").toString(); @@ -280,16 +271,6 @@ 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(); diff --git a/src/widgets/xmrigwidget.h b/src/widgets/xmrigwidget.h index 231223f..daf87eb 100644 --- a/src/widgets/xmrigwidget.h +++ b/src/widgets/xmrigwidget.h @@ -22,7 +22,7 @@ class XMRigWidget : public QWidget public: explicit XMRigWidget(AppContext *ctx, QWidget *parent = nullptr); - ~XMRigWidget(); + ~XMRigWidget() override; QStandardItemModel *model(); public slots: @@ -36,7 +36,6 @@ public slots: 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: @@ -55,7 +54,7 @@ private: Ui::XMRigWidget *ui; QStandardItemModel *m_model; QMenu *m_contextMenu; - unsigned int m_threads; + 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", "cryptonote.social:5555", "cryptonote.social:5556"}; }; diff --git a/src/widgets/xmrigwidget.ui b/src/widgets/xmrigwidget.ui index 6151a4c..85f02d6 100644 --- a/src/widgets/xmrigwidget.ui +++ b/src/widgets/xmrigwidget.ui @@ -178,13 +178,6 @@ - - - - Custom XMRig executable - - - @@ -552,36 +545,6 @@ - - - - - - false - - - Powered by Github API v3 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - diff --git a/utils/build_macos.sh b/utils/build_macos.sh index f96db3e..bf58960 100644 --- a/utils/build_macos.sh +++ b/utils/build_macos.sh @@ -14,7 +14,7 @@ git submodule update --init --depth 120 monero git submodule update --init --depth 120 --recursive monero cp "/Users/administrator/tor/libevent-2.1.7.dylib" "/Users/administrator/feather/src/assets/exec/libevent-2.1.7.dylib" -CMAKE_PREFIX_PATH="~/Qt/5.15.1/clang_64" TOR="/Users/administrator/tor/tor" XMRIG="/Users/administrator/xmrig/xmrig" make -j3 mac-release +CMAKE_PREFIX_PATH="~/Qt/5.15.1/clang_64" TOR_BIN="/Users/administrator/tor/tor" make -j3 mac-release if [[ $? -eq 0 ]]; then echo "[+] Feather built OK"