From 574b0ebf0c148b9b42eb965a0d5f259f88e37b6e Mon Sep 17 00:00:00 2001 From: tobtoht Date: Mon, 25 Jan 2021 17:38:04 +0100 Subject: [PATCH] Wallet cache debug dialog --- CMakeLists.txt | 2 +- monero | 2 +- src/dialog/WalletCacheDebugDialog.cpp | 94 ++++++++++++ src/dialog/WalletCacheDebugDialog.h | 30 ++++ src/dialog/WalletCacheDebugDialog.ui | 212 ++++++++++++++++++++++++++ src/libwalletqt/Wallet.cpp | 85 +++++++++++ src/libwalletqt/Wallet.h | 18 +++ src/mainwindow.cpp | 8 + src/mainwindow.h | 1 + src/mainwindow.ui | 6 + 10 files changed, 456 insertions(+), 2 deletions(-) create mode 100644 src/dialog/WalletCacheDebugDialog.cpp create mode 100644 src/dialog/WalletCacheDebugDialog.h create mode 100644 src/dialog/WalletCacheDebugDialog.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cb58b3..e8b509f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if(DEBUG) set(CMAKE_VERBOSE_MAKEFILE ON) endif() -set(MONERO_HEAD "36cd38434a5198059c5898ff3968e86fd95e897d") +set(MONERO_HEAD "0b16332df67928dcab50131d236a9a94e59686ad") set(BUILD_GUI_DEPS ON) set(ARCH "x86-64") set(BUILD_64 ON) diff --git a/monero b/monero index 36cd384..0b16332 160000 --- a/monero +++ b/monero @@ -1 +1 @@ -Subproject commit 36cd38434a5198059c5898ff3968e86fd95e897d +Subproject commit 0b16332df67928dcab50131d236a9a94e59686ad diff --git a/src/dialog/WalletCacheDebugDialog.cpp b/src/dialog/WalletCacheDebugDialog.cpp new file mode 100644 index 0000000..a1b11e8 --- /dev/null +++ b/src/dialog/WalletCacheDebugDialog.cpp @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2020-2021, The Monero Project. + +#include "WalletCacheDebugDialog.h" +#include "ui_WalletCacheDebugDialog.h" + +#include + +WalletCacheDebugDialog::WalletCacheDebugDialog(AppContext *ctx, QWidget *parent) + : QDialog(parent) + , m_ctx(ctx) + , ui(new Ui::WalletCacheDebugDialog) +{ + ui->setupUi(this); + + connect(ui->m_blockchain, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printBlockchain()); + }); + + connect(ui->m_transfers, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printTransfers()); + }); + + connect(ui->m_unconfirmed_payments, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printUnconfirmedPayments()); + }); + + connect(ui->m_confirmed_txs, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printConfirmedTransferDetails()); + }); + + connect(ui->m_unconfirmed_txs, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printUnconfirmedTransferDetails()); + }); + + connect(ui->m_payments, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printPayments()); + }); + + connect(ui->m_pub_keys, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printPubKeys()); + }); + + connect(ui->m_tx_notes, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printTxNotes()); + }); + + connect(ui->m_subaddresses, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printSubaddresses()); + }); + + connect(ui->m_subaddress_labels, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printSubaddressLabels()); + }); + + connect(ui->m_additional_tx_keys, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printAdditionalTxKeys()); + }); + + connect(ui->m_attributes, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printAttributes()); + }); + + connect(ui->m_key_images, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printKeyImages()); + }); + + connect(ui->m_account_tags, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printAccountTags()); + }); + + connect(ui->m_tx_keys, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printTxKeys()); + }); + + connect(ui->m_address_book, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printAddressBook()); + }); + + connect(ui->m_scanned_pool_txs, &QRadioButton::pressed, [this]{ + this->setOutput(m_ctx->currentWallet->printScannedPoolTxs()); + }); + + this->adjustSize(); +} + +void WalletCacheDebugDialog::setOutput(const QString &output) { + ui->output->setPlainText(output); +} + +WalletCacheDebugDialog::~WalletCacheDebugDialog() { + delete ui; +} + diff --git a/src/dialog/WalletCacheDebugDialog.h b/src/dialog/WalletCacheDebugDialog.h new file mode 100644 index 0000000..54a5f67 --- /dev/null +++ b/src/dialog/WalletCacheDebugDialog.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2020-2021, The Monero Project. + +#ifndef FEATHER_WALLETCACHEDEBUGDIALOG_H +#define FEATHER_WALLETCACHEDEBUGDIALOG_H + +#include +#include "appcontext.h" + +namespace Ui { + class WalletCacheDebugDialog; +} + +class WalletCacheDebugDialog : public QDialog +{ +Q_OBJECT + +public: + explicit WalletCacheDebugDialog(AppContext *ctx, QWidget *parent = nullptr); + ~WalletCacheDebugDialog() override; + +private: + void setOutput(const QString &output); + Ui::WalletCacheDebugDialog *ui; + AppContext *m_ctx; +}; + + + +#endif //FEATHER_WALLETCACHEDEBUGDIALOG_H diff --git a/src/dialog/WalletCacheDebugDialog.ui b/src/dialog/WalletCacheDebugDialog.ui new file mode 100644 index 0000000..1eb32cf --- /dev/null +++ b/src/dialog/WalletCacheDebugDialog.ui @@ -0,0 +1,212 @@ + + + WalletCacheDebugDialog + + + + 0 + 0 + 1423 + 814 + + + + Wallet Cache Debug + + + + + + + 500 + 0 + + + + true + + + + + + + + + + + m_blockchain + + + + + + + m_transfers + + + + + + + m_key_images + + + + + + + m_unconfirmed_txs + + + + + + + m_payments + + + + + + + m_tx_keys + + + + + + + + + + + m_confirmed_txs + + + + + + + m_tx_notes + + + + + + + m_unconfirmed_payments + + + + + + + m_pub_keys + + + + + + + m_address_book + + + + + + + m_scanned_pool_txs + + + + + + + + + + + m_subaddresses + + + + + + + m_subaddress_labels + + + + + + + m_additional_tx_keys + + + + + + + m_attributes + + + + + + + m_account_tags + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + WalletCacheDebugDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + WalletCacheDebugDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 0108017..ed32e66 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -468,6 +468,91 @@ bool Wallet::importTransaction(const QString& txid, const QVector& outp double_spend_seen); } +QString Wallet::printBlockchain() +{ + return QString::fromStdString(m_walletImpl->printBlockchain()); +} + +QString Wallet::printTransfers() +{ + return QString::fromStdString(m_walletImpl->printTransfers()); +} + +QString Wallet::printPayments() +{ + return QString::fromStdString(m_walletImpl->printPayments()); +} + +QString Wallet::printUnconfirmedPayments() +{ + return QString::fromStdString(m_walletImpl->printUnconfirmedPayments()); +} + +QString Wallet::printConfirmedTransferDetails() +{ + return QString::fromStdString(m_walletImpl->printConfirmedTransferDetails()); +} + +QString Wallet::printUnconfirmedTransferDetails() +{ + return QString::fromStdString(m_walletImpl->printUnconfirmedTransferDetails()); +} + +QString Wallet::printPubKeys() +{ + return QString::fromStdString(m_walletImpl->printPubKeys()); +} + +QString Wallet::printTxNotes() +{ + return QString::fromStdString(m_walletImpl->printTxNotes()); +} + +QString Wallet::printSubaddresses() +{ + return QString::fromStdString(m_walletImpl->printSubaddresses()); +} + +QString Wallet::printSubaddressLabels() +{ + return QString::fromStdString(m_walletImpl->printSubaddressLabels()); +} + +QString Wallet::printAdditionalTxKeys() +{ + return QString::fromStdString(m_walletImpl->printAdditionalTxKeys()); +} + +QString Wallet::printAttributes() +{ + return QString::fromStdString(m_walletImpl->printAttributes()); +} + +QString Wallet::printKeyImages() +{ + return QString::fromStdString(m_walletImpl->printKeyImages()); +} + +QString Wallet::printAccountTags() +{ + return QString::fromStdString(m_walletImpl->printAccountTags()); +} + +QString Wallet::printTxKeys() +{ + return QString::fromStdString(m_walletImpl->printTxKeys()); +} + +QString Wallet::printAddressBook() +{ + return QString::fromStdString(m_walletImpl->printAddressBook()); +} + +QString Wallet::printScannedPoolTxs() +{ + return QString::fromStdString(m_walletImpl->printScannedPoolTxs()); +} + void Wallet::startRefresh() { m_refreshEnabled = true; diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index d4fb002..c92e61b 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -217,6 +217,24 @@ public: //! import a transaction Q_INVOKABLE bool importTransaction(const QString& txid, const QVector& output_indeces, quint64 height, quint64 timestamp, bool miner_tx, bool pool, bool double_spend_seen); + Q_INVOKABLE QString printBlockchain(); + Q_INVOKABLE QString printTransfers(); + Q_INVOKABLE QString printPayments(); + Q_INVOKABLE QString printUnconfirmedPayments(); + Q_INVOKABLE QString printConfirmedTransferDetails(); + Q_INVOKABLE QString printUnconfirmedTransferDetails(); + Q_INVOKABLE QString printPubKeys(); + Q_INVOKABLE QString printTxNotes(); + Q_INVOKABLE QString printSubaddresses(); + Q_INVOKABLE QString printSubaddressLabels(); + Q_INVOKABLE QString printAdditionalTxKeys(); + Q_INVOKABLE QString printAttributes(); + Q_INVOKABLE QString printKeyImages(); + Q_INVOKABLE QString printAccountTags(); + Q_INVOKABLE QString printTxKeys(); + Q_INVOKABLE QString printAddressBook(); + Q_INVOKABLE QString printScannedPoolTxs(); + //! refreshes the wallet Q_INVOKABLE bool refresh(bool historyAndSubaddresses = false); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4b89dda..c0b3044 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,6 +19,7 @@ #include "dialog/tximportdialog.h" #include "dialog/passworddialog.h" #include "dialog/balancedialog.h" +#include "dialog/WalletCacheDebugDialog.h" #include "ui_mainwindow.h" #include "globals.h" @@ -73,6 +74,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : connect(ui->actionQuit, &QAction::triggered, this, &MainWindow::menuQuitClicked); connect(ui->actionSettings, &QAction::triggered, this, &MainWindow::menuSettingsClicked); connect(ui->actionCalculator, &QAction::triggered, this, &MainWindow::showCalcWindow); + connect(ui->actionWallet_cache_debug, &QAction::triggered, this, &MainWindow::showWalletCacheDebugDialog); #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) ui->actionCreateDesktopEntry->setDisabled(true); @@ -1157,6 +1159,12 @@ void MainWindow::showDebugInfo() { dialog->deleteLater(); } +void MainWindow::showWalletCacheDebugDialog() { + auto *dialog = new WalletCacheDebugDialog(m_ctx, this); + dialog->exec(); + dialog->deleteLater(); +} + void MainWindow::showNodeExhaustedMessage() { // Spawning dialogs inside a lambda can cause system freezes on linux so we have to do it this way ¯\_(ツ)_/¯ diff --git a/src/mainwindow.h b/src/mainwindow.h index 1cff433..4016f22 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -104,6 +104,7 @@ public slots: void showViewOnlyDialog(); void donateButtonClicked(); void showCalcWindow(); + void showWalletCacheDebugDialog(); void showSendTab(); void showHistoryTab(); void showSendScreen(const CCSEntry &entry); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 1b06402..a1e2b4f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -404,6 +404,7 @@ + @@ -720,6 +721,11 @@ Show Home + + + Wallet cache debug + +