From 6821fadc3d2d4e3b2289d6cda3047cf66a85d433 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 2 May 2026 14:35:54 +0000 Subject: [PATCH] Add Qt mining controls and update Agrarian copyrights --- Makefile.am | 2 +- autogen.sh | 2 +- configure.ac | 4 +-- depends/hosts/i686-w64-mingw32.mk | 2 +- depends/hosts/x86_64-w64-mingw32.mk | 2 +- doc/build-ubuntu-24.md | 2 +- doc/build-unix.md | 2 +- doc/build-wallets.md | 2 +- doc/build-windows.md | 2 +- src/agrarian-cli-res.rc | 2 +- src/agrarian-cli.cpp | 2 +- src/agrarian-tx-res.rc | 2 +- src/agrarian-tx.cpp | 2 +- src/agrariand-res.rc | 2 +- src/agrariand.cpp | 2 +- src/chainparams.cpp | 2 +- src/chainparams.h | 2 +- src/clientversion.h | 2 +- src/init.cpp | 2 +- src/kernel.cpp | 2 +- src/kernel.h | 2 +- src/main.cpp | 2 +- src/main.h | 2 +- src/masternode-budget.cpp | 2 +- src/masternode-budget.h | 2 +- src/masternode-payments.cpp | 2 +- src/masternode-payments.h | 2 +- src/miner.cpp | 2 +- src/miner.h | 2 +- src/pow.cpp | 2 +- src/pow.h | 2 +- src/qt/bitcoingui.cpp | 52 +++++++++++++++++++++++++++++ src/qt/bitcoingui.h | 5 +++ src/qt/forms/optionsdialog.ui | 45 ++++++++++++++++++++++--- src/qt/locale/agrarian_hr_HR.ts | 4 +-- src/qt/optionsdialog.cpp | 6 ++++ src/qt/optionsmodel.cpp | 21 ++++++++++++ src/qt/optionsmodel.h | 2 ++ src/qt/splashscreen.cpp | 2 +- src/rpc/mining.cpp | 2 +- src/txdb.cpp | 2 +- 41 files changed, 164 insertions(+), 41 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3bc7ba62..ab36ee7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # Copyright (c) 2013-2016 The Bitcoin Core developers -# Copyright (c) 2026 Agrarian Developers +# Copyright (c) 2022-2036 Agrarian Developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/autogen.sh b/autogen.sh index 5707fa19..37ab5719 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2013-2016 The Bitcoin Core developers -# Copyright (c) 2026 Agrarian Developers +# Copyright (c) 2022-2036 Agrarian Developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/configure.ac b/configure.ac index de2a973b..631706cd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -dnl Copyright (c) 2026 Agrarian Developers +dnl Copyright (c) 2022-2036 Agrarian Developers dnl Distributed under the MIT/X11 software license, see the accompanying dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -9,7 +9,7 @@ define(_CLIENT_VERSION_MINOR, 0) define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2026) +define(_COPYRIGHT_YEAR, 2036) AC_INIT([Agrarian Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.agrarian.org],[agrarian]) AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADERS([src/config/agrarian-config.h]) diff --git a/depends/hosts/i686-w64-mingw32.mk b/depends/hosts/i686-w64-mingw32.mk index 43bd5acd..be0b5163 100644 --- a/depends/hosts/i686-w64-mingw32.mk +++ b/depends/hosts/i686-w64-mingw32.mk @@ -1,4 +1,4 @@ -# Copyright (c) 2026 Agrarian Developers +# Copyright (c) 2022-2036 Agrarian Developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php. diff --git a/depends/hosts/x86_64-w64-mingw32.mk b/depends/hosts/x86_64-w64-mingw32.mk index d4c1c3c7..9194bbb5 100644 --- a/depends/hosts/x86_64-w64-mingw32.mk +++ b/depends/hosts/x86_64-w64-mingw32.mk @@ -1,4 +1,4 @@ -# Copyright (c) 2026 Agrarian Developers +# Copyright (c) 2022-2036 Agrarian Developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php. diff --git a/doc/build-ubuntu-24.md b/doc/build-ubuntu-24.md index 1eb3aa0f..58fe8364 100644 --- a/doc/build-ubuntu-24.md +++ b/doc/build-ubuntu-24.md @@ -1,4 +1,4 @@ -Copyright (c) 2026 Agrarian Developers +Copyright (c) 2022-2036 Agrarian Developers Ubuntu 24.04 Build Notes ======================== diff --git a/doc/build-unix.md b/doc/build-unix.md index 0782823b..f820336b 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -1,4 +1,4 @@ -Copyright (c) 2026 Agrarian Developers +Copyright (c) 2022-2036 Agrarian Developers UNIX Build Notes diff --git a/doc/build-wallets.md b/doc/build-wallets.md index 7770d6c2..aa8289da 100644 --- a/doc/build-wallets.md +++ b/doc/build-wallets.md @@ -1,4 +1,4 @@ -Copyright (c) 2026 Agrarian Developers +Copyright (c) 2022-2036 Agrarian Developers Desktop Wallet Build Quick Start ================================ diff --git a/doc/build-windows.md b/doc/build-windows.md index ef3c84dc..3108d524 100644 --- a/doc/build-windows.md +++ b/doc/build-windows.md @@ -1,4 +1,4 @@ -Copyright (c) 2026 Agrarian Developers +Copyright (c) 2022-2036 Agrarian Developers ============================================================ Agrarian Core – Windows Build Notes diff --git a/src/agrarian-cli-res.rc b/src/agrarian-cli-res.rc index d92e4d1d..a00e1142 100644 --- a/src/agrarian-cli-res.rc +++ b/src/agrarian-cli-res.rc @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers #include // needed for VERSIONINFO #include "clientversion.h" // holds the needed client version information diff --git a/src/agrarian-cli.cpp b/src/agrarian-cli.cpp index 7626b356..e9c3dd30 100644 --- a/src/agrarian-cli.cpp +++ b/src/agrarian-cli.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2015 The Bitcoin developers // Copyright (c) 2009-2015 The Dash developers // Copyright (c) 2015-2018 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/agrarian-tx-res.rc b/src/agrarian-tx-res.rc index 7d255126..88d43c65 100644 --- a/src/agrarian-tx-res.rc +++ b/src/agrarian-tx-res.rc @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers #include // needed for VERSIONINFO #include "clientversion.h" // holds the needed client version information diff --git a/src/agrarian-tx.cpp b/src/agrarian-tx.cpp index befddfaf..b01f2673 100644 --- a/src/agrarian-tx.cpp +++ b/src/agrarian-tx.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/agrariand-res.rc b/src/agrariand-res.rc index 49e2f463..f85de862 100644 --- a/src/agrariand-res.rc +++ b/src/agrariand-res.rc @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers #include // needed for VERSIONINFO #include "clientversion.h" // holds the needed client version information diff --git a/src/agrariand.cpp b/src/agrariand.cpp index 9e4a8437..2ba34c12 100644 --- a/src/agrariand.cpp +++ b/src/agrariand.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 3975be16..5721e6ec 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/chainparams.h b/src/chainparams.h index e9faa989..23d5724b 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/clientversion.h b/src/clientversion.h index e81321ac..ef4b5b31 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -23,7 +23,7 @@ #define DO_STRINGIZE(X) #X //! Copyright string used in Windows .rc files -#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, 2014-" STRINGIZE(COPYRIGHT_YEAR) " The Dash Core Developers, 2015-" STRINGIZE(COPYRIGHT_YEAR) " The Agrarian Core Developers" +#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, 2014-" STRINGIZE(COPYRIGHT_YEAR) " The Dash Core Developers, 2015-" STRINGIZE(COPYRIGHT_YEAR) " The PIVX Core Developers, 2022-" STRINGIZE(COPYRIGHT_YEAR) " The Agrarian Core Developers" /** * agrariand-res.rc includes this file, but it cannot cope with real c++ code. diff --git a/src/init.cpp b/src/init.cpp index 8fe35199..3d7d5149 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -616,7 +616,7 @@ std::string LicenseInfo() "\n" + FormatParagraph(strprintf(_("Copyright (C) 2015-%i The PIVX Core Developers"), COPYRIGHT_YEAR)) + "\n" + "\n" + - FormatParagraph(strprintf(_("Copyright (C) %i The Agrarian Core Developers"), COPYRIGHT_YEAR)) + "\n" + + FormatParagraph(strprintf(_("Copyright (C) 2022-%i The Agrarian Core Developers"), COPYRIGHT_YEAR)) + "\n" + "\n" + FormatParagraph(_("This is experimental software.")) + "\n" + "\n" + diff --git a/src/kernel.cpp b/src/kernel.cpp index 6d0cf27a..a4f0539e 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The PPCoin developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/kernel.h b/src/kernel.h index 0fb6767d..8f255427 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The PPCoin developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef AGRARIAN_BITCOIN_KERNEL_H diff --git a/src/main.cpp b/src/main.cpp index 7fbf7b63..e9bf6bc1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 The Agrarian developers +// Copyright (c) 2022-2036 The Agrarian developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/main.h b/src/main.h index faa717f6..79f9ccbd 100644 --- a/src/main.h +++ b/src/main.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index d854e732..8f0be982 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/masternode-budget.h b/src/masternode-budget.h index 05aa7638..94e3ef6c 100644 --- a/src/masternode-budget.h +++ b/src/masternode-budget.h @@ -1,6 +1,6 @@ // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index a8b6533f..7b86433f 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/masternode-payments.h b/src/masternode-payments.h index ec9d7479..eb90c52e 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -1,6 +1,6 @@ // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/miner.cpp b/src/miner.cpp index e67a68a1..4ca576ef 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/miner.h b/src/miner.h index 66ff2a15..a23279cc 100644 --- a/src/miner.h +++ b/src/miner.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2016-2018 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef AGRARIAN_BITCOIN_MINER_H diff --git a/src/pow.cpp b/src/pow.cpp index c36129b9..ff149e73 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2018 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/pow.h b/src/pow.h index a1677e28..935534e4 100644 --- a/src/pow.h +++ b/src/pow.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2017-2018 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef AGRARIAN_BITCOIN_POW_H diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fd1f043b..bd600144 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -23,6 +23,7 @@ #include "blockexplorer.h" #include "walletframe.h" #include "walletmodel.h" +#include "wallet/wallet.h" #endif // ENABLE_WALLET #ifdef Q_OS_MAC @@ -106,6 +107,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai openAction(0), showHelpMessageAction(0), multiSendAction(0), + toggleMiningAction(0), trayIcon(0), trayIconMenu(0), notificator(0), @@ -437,6 +439,10 @@ void BitcoinGUI::createActions(const NetworkStyle* networkStyle) multiSendAction = new QAction(QIcon(":/icons/edit"), tr("&MultiSend"), this); multiSendAction->setToolTip(tr("MultiSend Settings")); multiSendAction->setCheckable(true); + toggleMiningAction = new QAction(tr("&Start CPU Mining"), this); + toggleMiningAction->setStatusTip(tr("Start or stop CPU mining using the configured mining processor threads")); + toggleMiningAction->setToolTip(toggleMiningAction->statusTip()); + toggleMiningAction->setCheckable(true); openInfoAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&Information"), this); openInfoAction->setStatusTip(tr("Show diagnostic information")); @@ -496,6 +502,7 @@ void BitcoinGUI::createActions(const NetworkStyle* networkStyle) connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses())); connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked())); connect(multiSendAction, SIGNAL(triggered()), this, SLOT(gotoMultiSendDialog())); + connect(toggleMiningAction, SIGNAL(triggered()), this, SLOT(toggleMining())); connect(multisigCreateAction, SIGNAL(triggered()), this, SLOT(gotoMultisigCreate())); connect(multisigSpendAction, SIGNAL(triggered()), this, SLOT(gotoMultisigSpend())); connect(multisigSignAction, SIGNAL(triggered()), this, SLOT(gotoMultisigSign())); @@ -544,6 +551,11 @@ void BitcoinGUI::createMenuBar() settings->addAction(optionsAction); if (walletFrame) { + QMenu* mining = appMenuBar->addMenu(tr("&Mining")); + mining->addAction(toggleMiningAction); + mining->addSeparator(); + mining->addAction(optionsAction); + QMenu* tools = appMenuBar->addMenu(tr("&Tools")); tools->addAction(openInfoAction); tools->addAction(openRPCConsoleAction); @@ -638,6 +650,7 @@ void BitcoinGUI::setClientModel(ClientModel* clientModel) #endif // ENABLE_WALLET unitDisplayControl->setOptionsModel(clientModel->getOptionsModel()); connect(clientModel->getOptionsModel(), SIGNAL(zeromintEnableChanged(bool)), this, SLOT(setAutoMintStatus())); + updateMiningAction(); //Show trayIcon if (trayIcon) @@ -702,6 +715,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) usedSendingAddressesAction->setEnabled(enabled); usedReceivingAddressesAction->setEnabled(enabled); openAction->setEnabled(enabled); + toggleMiningAction->setEnabled(enabled); } void BitcoinGUI::createTrayIcon(const NetworkStyle* networkStyle) @@ -811,6 +825,44 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::toggleMining() +{ + const bool currentlyMining = GetBoolArg("-gen", false); + const bool startMining = !currentlyMining; + + if (!pwalletMain) { + QMessageBox::warning(this, tr("Mining unavailable"), tr("CPU mining requires an active wallet.")); + updateMiningAction(); + return; + } + + int miningThreads = 1; + if (clientModel && clientModel->getOptionsModel()) + miningThreads = clientModel->getOptionsModel()->getMiningThreads(); + + mapArgs["-gen"] = (startMining ? "1" : "0"); + mapArgs["-genproclimit"] = itostr(startMining ? miningThreads : 0); + GenerateBitcoins(startMining, pwalletMain, startMining ? miningThreads : 0); + updateMiningAction(); + + const QString message = startMining + ? tr("CPU mining started with %1 processor thread(s).").arg(miningThreads) + : tr("CPU mining stopped."); + statusBar()->showMessage(message, 5000); +} + +void BitcoinGUI::updateMiningAction() +{ + if (!toggleMiningAction) + return; + + const bool mining = GetBoolArg("-gen", false); + toggleMiningAction->blockSignals(true); + toggleMiningAction->setChecked(mining); + toggleMiningAction->setText(mining ? tr("&Stop CPU Mining") : tr("&Start CPU Mining")); + toggleMiningAction->blockSignals(false); +} + void BitcoinGUI::gotoOverviewPage() { overviewAction->setChecked(true); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a79f42ed..e68660ab 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -131,6 +131,7 @@ private: QAction* openBlockExplorerAction; QAction* showHelpMessageAction; QAction* multiSendAction; + QAction* toggleMiningAction; QSystemTrayIcon* trayIcon; QMenu* trayIconMenu; @@ -238,6 +239,10 @@ private slots: /** Show open dialog */ void openClicked(); + /** Toggle CPU mining using the configured mining thread count. */ + void toggleMining(); + /** Refresh CPU mining action text/check state. */ + void updateMiningAction(); #endif // ENABLE_WALLET /** Show configuration dialog */ diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index cb21ac9a..9a9c5668 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -115,10 +115,47 @@ - - - - + + + + + + + + Number of mining processor threads + + + Qt::PlainText + + + miningThreads + + + + + + + Processor threads used when CPU mining is started from the Mining menu. + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical diff --git a/src/qt/locale/agrarian_hr_HR.ts b/src/qt/locale/agrarian_hr_HR.ts index a2d17323..0e156a55 100644 --- a/src/qt/locale/agrarian_hr_HR.ts +++ b/src/qt/locale/agrarian_hr_HR.ts @@ -4997,7 +4997,7 @@ Please be patient... Copyright (C) 2015-%i The PIVX Core Developers - Autorska prava (C) 2015-%i The Agrarian Core Developers + Autorska prava (C) 2015-%i The PIVX Core Developers Corrupted block database detected @@ -5900,4 +5900,4 @@ Please be patient... wallet.dat korumpiran, spašavanje nije uspjelo - \ No newline at end of file + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 524fb565..1e9e39ab 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -31,6 +31,9 @@ #include #include #include +#include + +#include OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), ui(new Ui::OptionsDialog), @@ -46,6 +49,8 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(paren ui->databaseCache->setMaximum(nMaxDbCache); ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency()); ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS); + ui->miningThreads->setMinimum(1); + ui->miningThreads->setMaximum(std::max(1, QThread::idealThreadCount())); /* Network elements init */ #ifndef USE_UPNP @@ -192,6 +197,7 @@ void OptionsDialog::setMapper() /* Main */ mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif); + mapper->addMapping(ui->miningThreads, OptionsModel::MiningThreads); mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache); // Zeromint Enabled mapper->addMapping(ui->checkBoxZeromintEnable, OptionsModel::ZeromintEnable); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 46cb7e22..9b396aba 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -29,6 +29,9 @@ #include #include #include +#include + +#include OptionsModel::OptionsModel(QObject* parent) : QAbstractListModel(parent) { @@ -119,6 +122,9 @@ void OptionsModel::Init() if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) addOverriddenOption("-par"); + if (!settings.contains("nMiningThreads")) + settings.setValue("nMiningThreads", 1); + // Wallet #ifdef ENABLE_WALLET if (!settings.contains("bSpendZeroConfChange")) @@ -255,6 +261,8 @@ QVariant OptionsModel::data(const QModelIndex& index, int role) const return settings.value("nDatabaseCache"); case ThreadsScriptVerif: return settings.value("nThreadsScriptVerif"); + case MiningThreads: + return settings.value("nMiningThreads", 1); case HideZeroBalances: return settings.value("fHideZeroBalances"); case HideOrphans: @@ -420,6 +428,12 @@ bool OptionsModel::setData(const QModelIndex& index, const QVariant& value, int setRestartRequired(true); } break; + case MiningThreads: { + const int maxThreads = std::max(1, QThread::idealThreadCount()); + const int threads = std::max(1, std::min(value.toInt(), maxThreads)); + settings.setValue("nMiningThreads", threads); + break; + } case Listen: if (settings.value("fListen") != value) { settings.setValue("fListen", value); @@ -436,6 +450,13 @@ bool OptionsModel::setData(const QModelIndex& index, const QVariant& value, int return successful; } +int OptionsModel::getMiningThreads() +{ + QSettings settings; + const int maxThreads = std::max(1, QThread::idealThreadCount()); + return std::max(1, std::min(settings.value("nMiningThreads", 1).toInt(), maxThreads)); +} + /** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */ void OptionsModel::setDisplayUnit(const QVariant& value) { diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 54f60165..bd5195d0 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -54,6 +54,7 @@ public: ShowMasternodesTab, // bool Listen, // bool StakeSplitThreshold, // int + MiningThreads, // int OptionIDRowCount, }; @@ -75,6 +76,7 @@ public: QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } bool getProxySettings(QNetworkProxy& proxy) const; bool getCoinControlFeatures() { return fCoinControlFeatures; } + int getMiningThreads(); const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } /* Restart flag helper */ diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index e8ad190d..bd51aed9 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -45,7 +45,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle* networkStyle) QString copyrightTextBtc = QChar(0xA9) + QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers")); QString copyrightTextDash = QChar(0xA9) + QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core developers")); QString copyrightTextPIVX = QChar(0xA9) + QString(" 2015-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The PIVX Core developers")); - QString copyrightTextAgrarian = QChar(0xA9) + QString(" %1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Agrarian Core developers")); + QString copyrightTextAgrarian = QChar(0xA9) + QString(" 2022-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Agrarian Core developers")); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 17d54445..69c3b90e 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/txdb.cpp b/src/txdb.cpp index 4c17c55e..3d67c392 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2016-2019 The PIVX developers -// Copyright (c) 2026 Agrarian Developers +// Copyright (c) 2022-2036 Agrarian Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php.