From 1e6f821a2fd81741e57c9c27644fbf4aa9ec00f4 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 11 Mar 2022 13:41:40 +0100 Subject: [PATCH] libwalletqt: more WalletManager cleanup --- src/libwalletqt/WalletManager.cpp | 2 +- src/libwalletqt/WalletManager.h | 84 +++++++++++++------------------ 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 8141c737..109f8c96 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -6,7 +6,7 @@ #include "utils/ScopeGuard.h" -class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver +class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver { public: explicit WalletPassphraseListenerImpl(WalletManager * mgr): m_mgr(mgr), m_phelper(mgr) {} diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index a9848bfa..626ccfce 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -4,13 +4,12 @@ #ifndef WALLETMANAGER_H #define WALLETMANAGER_H -#include -#include -#include #include + +#include #include #include -#include + #include "utils/scheduler.h" #include "utils/networktype.h" #include "PassphraseHelper.h" @@ -25,21 +24,9 @@ class WalletManager : public QObject, public PassprasePrompter Q_OBJECT public: - enum LogLevel { - LogLevel_Silent = Monero::WalletManagerFactory::LogLevel_Silent, - LogLevel_0 = Monero::WalletManagerFactory::LogLevel_0, - LogLevel_1 = Monero::WalletManagerFactory::LogLevel_1, - LogLevel_2 = Monero::WalletManagerFactory::LogLevel_2, - LogLevel_3 = Monero::WalletManagerFactory::LogLevel_3, - LogLevel_4 = Monero::WalletManagerFactory::LogLevel_4, - LogLevel_Min = Monero::WalletManagerFactory::LogLevel_Min, - LogLevel_Max = Monero::WalletManagerFactory::LogLevel_Max, - }; - - static WalletManager * instance(); - // wizard: createWallet path; - Wallet * createWallet(const QString &path, const QString &password, - const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1); + static WalletManager *instance(); + + Wallet * createWallet(const QString &path, const QString &password, const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1); /*! * \brief openWallet - opens wallet by given path @@ -56,43 +43,41 @@ public: */ void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1); - // wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = "" Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset, - NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1); + NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1); Wallet * createWalletFromKeys(const QString &path, - const QString &password, - const QString &language, - NetworkType::Type nettype, - const QString &address, - const QString &viewkey, - const QString &spendkey = "", - quint64 restoreHeight = 0, - quint64 kdfRounds = 1); + const QString &password, + const QString &language, + NetworkType::Type nettype, + const QString &address, + const QString &viewkey, + const QString &spendkey = "", + quint64 restoreHeight = 0, + quint64 kdfRounds = 1); Wallet * createDeterministicWalletFromSpendKey(const QString &path, - const QString &password, - const QString &language, - NetworkType::Type nettype, - const QString &spendkey, - quint64 restoreHeight, - quint64 kdfRounds, - const QString &offset_passphrase = ""); + const QString &password, + const QString &language, + NetworkType::Type nettype, + const QString &spendkey, + quint64 restoreHeight, + quint64 kdfRounds, + const QString &offset_passphrase = ""); Wallet * createWalletFromDevice(const QString &path, - const QString &password, - NetworkType::Type nettype, - const QString &deviceName, - quint64 restoreHeight = 0, - const QString &subaddressLookahead = ""); + const QString &password, + NetworkType::Type nettype, + const QString &deviceName, + quint64 restoreHeight = 0, + const QString &subaddressLookahead = ""); void createWalletFromDeviceAsync(const QString &path, - const QString &password, - NetworkType::Type nettype, - const QString &deviceName, - quint64 restoreHeight = 0, - const QString &subaddressLookahead = ""); - + const QString &password, + NetworkType::Type nettype, + const QString &deviceName, + quint64 restoreHeight = 0, + const QString &subaddressLookahead = ""); //! checks is given filename is a wallet; bool walletExists(const QString &path) const; @@ -103,7 +88,6 @@ public: //! returns list with wallet's filenames, if found by given path QStringList findWallets(const QString &path); - //! since we can't call static method from QML, move it to this class static QString displayAmount(quint64 amount, bool trailing_zeroes = true, int decimals = 12); static quint64 amountFromString(const QString &amount); static quint64 amountFromDouble(double amount); @@ -130,8 +114,8 @@ public: virtual void onWalletPassphraseNeeded(bool on_device) override; signals: - void walletOpened(Wallet * wallet); - void walletCreated(Wallet * wallet); + void walletOpened(Wallet *wallet); + void walletCreated(Wallet *wallet); void walletPassphraseNeeded(bool onDevice); void deviceButtonRequest(quint64 buttonCode); void deviceButtonPressed(); -- 2.52.0