wowlet: solo-mining toggle — Wallet startMining/stopMining (RandomWOW via embedded node) + Wallet-menu action

This commit is contained in:
jwinterm
2026-06-18 17:06:06 -04:00
parent 5206dbdf8a
commit 640a478b1b
3 changed files with 35 additions and 0 deletions
+17
View File
@@ -7,6 +7,7 @@
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QThread>
#include <QCheckBox>
#include "constants.h"
@@ -253,6 +254,22 @@ void MainWindow::initWidgets() {
m_wallet->setCacheAttribute("wallet.notes", ui->notes->toPlainText());
});
// [Mining] — wowlet: solo-mine to this wallet via the embedded local node (RandomWOW in wownerod)
auto *mineAction = new QAction("Mine to this wallet", this);
mineAction->setCheckable(true);
ui->menuWallet->addAction(mineAction);
connect(mineAction, &QAction::toggled, this, [this, mineAction](bool on) {
if (on) {
int threads = std::max(1, QThread::idealThreadCount() / 2);
if (!m_wallet->startMining(threads)) {
mineAction->setChecked(false);
QMessageBox::warning(this, "Mining", "Could not start mining — make sure the node is connected and synced.");
}
} else {
m_wallet->stopMining();
}
});
// [Plugins..]
for (auto* plugin : m_plugins) {
if (!plugin->hasParent()) {
+12
View File
@@ -113,6 +113,18 @@ bool Wallet::isConnected() const {
return status == ConnectionStatus_Synchronizing || status == ConnectionStatus_Synchronized;
}
bool Wallet::startMining(quint32 threads) {
return m_walletImpl->startMining(m_walletImpl->address(0, 0), threads);
}
bool Wallet::stopMining() {
return m_walletImpl->stopMining();
}
bool Wallet::isMining() {
return m_walletImpl->isMining();
}
QString Wallet::errorString() const {
return QString::fromStdString(m_walletImpl->errorString());
}
+6
View File
@@ -126,6 +126,12 @@ public:
//! returns true if wallet is currently synchronized
bool isSynchronized() const;
// wowlet: solo-mine to this wallet's primary address via the connected daemon (the embedded
// local node). Mining runs inside wownerod (RandomWOW); these just toggle it over RPC.
bool startMining(quint32 threads = 1);
bool stopMining();
bool isMining();
//! return true if wallet is connected to a node
bool isConnected() const;