LCOV - code coverage report
Current view: top level - src/qt - walletcontroller.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 6 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 8 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2019-2020 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_QT_WALLETCONTROLLER_H
       6             : #define BITCOIN_QT_WALLETCONTROLLER_H
       7             : 
       8             : #include <qt/sendcoinsrecipient.h>
       9             : #include <support/allocators/secure.h>
      10             : #include <sync.h>
      11             : #include <util/translation.h>
      12             : 
      13             : #include <map>
      14             : #include <memory>
      15             : #include <string>
      16             : #include <vector>
      17             : 
      18             : #include <QMessageBox>
      19             : #include <QMutex>
      20             : #include <QProgressDialog>
      21             : #include <QThread>
      22             : #include <QTimer>
      23             : #include <QString>
      24             : 
      25             : class ClientModel;
      26             : class OptionsModel;
      27             : class PlatformStyle;
      28             : class WalletModel;
      29             : 
      30             : namespace interfaces {
      31             : class Handler;
      32             : class Node;
      33             : class Wallet;
      34             : } // namespace interfaces
      35             : 
      36             : class AskPassphraseDialog;
      37             : class CreateWalletActivity;
      38             : class CreateWalletDialog;
      39             : class OpenWalletActivity;
      40             : class WalletControllerActivity;
      41             : 
      42             : /**
      43             :  * Controller between interfaces::Node, WalletModel instances and the GUI.
      44             :  */
      45             : class WalletController : public QObject
      46             : {
      47           0 :     Q_OBJECT
      48             : 
      49             :     void removeAndDeleteWallet(WalletModel* wallet_model);
      50             : 
      51             : public:
      52             :     WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent);
      53             :     ~WalletController();
      54             : 
      55             :     //! Returns wallet models currently open.
      56             :     std::vector<WalletModel*> getOpenWallets() const;
      57             : 
      58             :     WalletModel* getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet);
      59             : 
      60             :     //! Returns all wallet names in the wallet dir mapped to whether the wallet
      61             :     //! is loaded.
      62             :     std::map<std::string, bool> listWalletDir() const;
      63             : 
      64             :     void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);
      65             :     void closeAllWallets(QWidget* parent = nullptr);
      66             : 
      67             : Q_SIGNALS:
      68             :     void walletAdded(WalletModel* wallet_model);
      69             :     void walletRemoved(WalletModel* wallet_model);
      70             : 
      71             :     void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction);
      72             : 
      73             : private:
      74             :     QThread* const m_activity_thread;
      75             :     QObject* const m_activity_worker;
      76             :     ClientModel& m_client_model;
      77             :     interfaces::Node& m_node;
      78             :     const PlatformStyle* const m_platform_style;
      79             :     OptionsModel* const m_options_model;
      80             :     mutable QMutex m_mutex;
      81             :     std::vector<WalletModel*> m_wallets;
      82             :     std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
      83             : 
      84             :     friend class WalletControllerActivity;
      85             : };
      86             : 
      87             : class WalletControllerActivity : public QObject
      88             : {
      89             :     Q_OBJECT
      90             : 
      91             : public:
      92             :     WalletControllerActivity(WalletController* wallet_controller, QWidget* parent_widget);
      93             :     virtual ~WalletControllerActivity();
      94             : 
      95             : Q_SIGNALS:
      96             :     void finished();
      97             : 
      98             : protected:
      99           0 :     interfaces::Node& node() const { return m_wallet_controller->m_node; }
     100           0 :     QObject* worker() const { return m_wallet_controller->m_activity_worker; }
     101             : 
     102             :     void showProgressDialog(const QString& label_text);
     103             :     void destroyProgressDialog();
     104             : 
     105             :     WalletController* const m_wallet_controller;
     106             :     QWidget* const m_parent_widget;
     107             :     QProgressDialog* m_progress_dialog{nullptr};
     108             :     WalletModel* m_wallet_model{nullptr};
     109             :     bilingual_str m_error_message;
     110             :     std::vector<bilingual_str> m_warning_message;
     111             : };
     112             : 
     113             : 
     114             : class CreateWalletActivity : public WalletControllerActivity
     115             : {
     116           0 :     Q_OBJECT
     117             : 
     118             : public:
     119             :     CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);
     120             :     virtual ~CreateWalletActivity();
     121             : 
     122             :     void create();
     123             : 
     124             : Q_SIGNALS:
     125             :     void created(WalletModel* wallet_model);
     126             : 
     127             : private:
     128             :     void askPassphrase();
     129             :     void createWallet();
     130             :     void finish();
     131             : 
     132             :     SecureString m_passphrase;
     133             :     CreateWalletDialog* m_create_wallet_dialog{nullptr};
     134             :     AskPassphraseDialog* m_passphrase_dialog{nullptr};
     135             : };
     136             : 
     137           0 : class OpenWalletActivity : public WalletControllerActivity
     138             : {
     139           0 :     Q_OBJECT
     140             : 
     141             : public:
     142             :     OpenWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);
     143             : 
     144             :     void open(const std::string& path);
     145             : 
     146             : Q_SIGNALS:
     147             :     void opened(WalletModel* wallet_model);
     148             : 
     149             : private:
     150             :     void finish();
     151             : };
     152             : 
     153             : #endif // BITCOIN_QT_WALLETCONTROLLER_H

Generated by: LCOV version 1.15