mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-17 07:11:29 +02:00
wowlet: solo-mining toggle — Wallet startMining/stopMining (RandomWOW via embedded node) + Wallet-menu action
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user