From: gg Date: Sun, 18 Jan 2026 20:54:47 +0000 (-0500) Subject: add history widget and mempool scanning config X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=3ff15fbeae7d29d3e12c40c0734e125e6a3ed155;p=gamesguru%2Ffeather.git add history widget and mempool scanning config --- diff --git a/src/HistoryWidget.cpp b/src/HistoryWidget.cpp index 6f2433b7..09aa843b 100644 --- a/src/HistoryWidget.cpp +++ b/src/HistoryWidget.cpp @@ -15,6 +15,11 @@ #include "utils/Icons.h" #include "WebsocketNotifier.h" +#include +#include +#include +#include + HistoryWidget::HistoryWidget(Wallet *wallet, QWidget *parent) : QWidget(parent) , ui(new Ui::HistoryWidget) @@ -33,6 +38,7 @@ HistoryWidget::HistoryWidget(Wallet *wallet, QWidget *parent) m_copyMenu->addAction("Date", this, [this]{copy(copyField::Date);}); m_copyMenu->addAction("Description", this, [this]{copy(copyField::Description);}); m_copyMenu->addAction("Amount", this, [this]{copy(copyField::Amount);}); + m_copyMenu->addAction("Row as JSON", this, [this]{copy(copyField::JSON);}); ui->history->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->history, &QTreeView::customContextMenuRequested, this, &HistoryWidget::showContextMenu); @@ -204,6 +210,30 @@ void HistoryWidget::copy(copyField field) { conf()->get(Config::timeFormat).toString())); case copyField::Amount: return WalletManager::displayAmount(abs(tx.balanceDelta)); + case copyField::JSON: { + QJsonObject obj; + obj.insert("txid", tx.hash); + obj.insert("amount", static_cast(tx.amount)); + obj.insert("fee", static_cast(tx.fee)); + obj.insert("height", static_cast(tx.blockHeight)); + obj.insert("timestamp", tx.timestamp.toSecsSinceEpoch()); + obj.insert("direction", tx.direction == TransactionRow::Direction_In ? "in" : "out"); + obj.insert("payment_id", tx.paymentId); + obj.insert("description", tx.description); + obj.insert("confirmations", static_cast(tx.confirmations)); + obj.insert("failed", tx.failed); + obj.insert("pending", tx.pending); + obj.insert("coinbase", tx.coinbase); + obj.insert("label", tx.label); + + QJsonArray subaddrIndices; + for (const auto &idx : tx.subaddrIndex) subaddrIndices.append(static_cast(idx)); + obj.insert("subaddr_index", subaddrIndices); + obj.insert("subaddr_account", static_cast(tx.subaddrAccount)); + + QJsonDocument doc(obj); + return QString::fromUtf8(doc.toJson(QJsonDocument::Indented)); + } default: return QString(""); } diff --git a/src/HistoryWidget.h b/src/HistoryWidget.h index d9d98263..f619a126 100644 --- a/src/HistoryWidget.h +++ b/src/HistoryWidget.h @@ -48,7 +48,8 @@ private: TxID = 0, Description, Date, - Amount + Amount, + JSON }; void copy(copyField field); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5f0dc0a7..f0f0258b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -235,6 +235,15 @@ void MainWindow::initStatusBar() { m_actionPauseSync->setChecked(conf()->get(Config::syncPaused).toBool()); m_statusLabelStatus->addAction(m_actionPauseSync); + m_actionScanMempoolWhenPaused = new QAction(tr("Scan mempool when paused"), this); + m_actionScanMempoolWhenPaused->setCheckable(true); + m_actionScanMempoolWhenPaused->setChecked(conf()->get(Config::scanMempoolWhenPaused).toBool()); + m_statusLabelStatus->addAction(m_actionScanMempoolWhenPaused); + + connect(m_actionScanMempoolWhenPaused, &QAction::toggled, this, [](bool checked) { + conf()->set(Config::scanMempoolWhenPaused, checked); + }); + m_actionEnableWebsocket = new QAction(tr("Enable Websocket"), this); m_actionEnableWebsocket->setCheckable(true); m_actionEnableWebsocket->setChecked(!conf()->get(Config::disableWebsocket).toBool()); diff --git a/src/MainWindow.h b/src/MainWindow.h index 5164c147..51d44c9c 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -240,6 +240,7 @@ private: QPointer m_updateNetworkInfoAction; QPointer m_actionEnableWebsocket; QPointer m_actionPauseSync; + QPointer m_actionScanMempoolWhenPaused; QDateTime m_lastSyncStatusUpdate; QDateTime m_lastNetInfoUpdate; diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 5f9e2eb1..a6fef448 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "AddressBook.h" #include "Coins.h" @@ -561,9 +562,6 @@ void Wallet::startRefreshThread() // Don't call refresh function if we don't have the daemon and target height // We do this to prevent to UI from getting confused about the amount of blocks that are still remaining if (haveHeights) { - // Prevent background network usage when sync is paused - if (m_syncPaused) - continue; QMutexLocker locker(&m_asyncMutex); @@ -576,6 +574,19 @@ void Wallet::startRefreshThread() quint64 walletHeight = m_walletImpl->blockChainHeight(); m_walletImpl->refresh(); } + + // Scan mempool if paused + // Low-bandwidth query if user has enabled it + if (m_syncPaused) { + if (m_refreshNow || conf()->get(Config::scanMempoolWhenPaused).toBool()) { + scanMempool(); + m_refreshNow = false; + } else { + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + } + last = std::chrono::steady_clock::now(); + continue; + } } } @@ -1688,6 +1699,19 @@ void Wallet::getTxPoolStatsAsync() { }); } +void Wallet::scanMempool() { + QMutexLocker locker(&m_asyncMutex); + try { + std::vector> process_txs; + m_wallet2->update_pool_state(process_txs, false, false); + if (!process_txs.empty()) { + m_wallet2->process_pool_state(process_txs); + } + } catch (const std::exception &e) { + qWarning() << "Failed to scan mempool:" << e.what(); + } +} + Wallet::~Wallet() { qDebug() << "~Wallet: Closing wallet" << QThread::currentThreadId(); diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 366dd885..69096654 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -494,6 +494,7 @@ private: void onTransactionCreated(Monero::PendingTransaction *mtx, const QVector &address); private: + void scanMempool(); friend class WalletManager; friend class WalletListenerImpl; diff --git a/src/utils/config.cpp b/src/utils/config.cpp index ae6cade9..c6720fa4 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -132,6 +132,7 @@ static const QHash configStrings = { {Config::torManagedPort, {QS("torManagedPort"), "19450"}}, {Config::useLocalTor, {QS("useLocalTor"), false}}, {Config::initSyncThreshold, {QS("initSyncThreshold"), 360}}, + {Config::scanMempoolWhenPaused, {QS("scanMempoolWhenPaused"), false}}, {Config::enabledPlugins, {QS("enabledPlugins"), QStringList{"tickers", "crowdfunding", "revuo", "calc"}}}, {Config::restartRequired, {QS("restartRequired"), false}}, diff --git a/src/utils/config.h b/src/utils/config.h index b739359b..d43935b0 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -150,6 +150,7 @@ public: lastNetInfoUpdate, lastSyncTimestamp, lastPriceUpdateTimestamp, + scanMempoolWhenPaused, }; enum PrivacyLevel {