Bitcoin ABC 0.30.5
P2P Digital Currency
walletcontroller.h
Go to the documentation of this file.
1// Copyright (c) 2019 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 <interfaces/wallet.h>
10#include <qt/walletmodel.h>
12#include <sync.h>
13#include <util/translation.h>
14
15#include <QMutex>
16
17#include <map>
18#include <memory>
19#include <string>
20#include <vector>
21
22#include <QMessageBox>
23#include <QProgressDialog>
24#include <QString>
25#include <QThread>
26#include <QTimer>
27
28class ClientModel;
29class OptionsModel;
30class PlatformStyle;
31class WalletModel;
32
33namespace interfaces {
34class Handler;
35class Node;
36class Wallet;
37} // namespace interfaces
38
44
48class WalletController : public QObject {
49 Q_OBJECT
50
51 void removeAndDeleteWallet(WalletModel *wallet_model);
52
53public:
54 WalletController(ClientModel &client_model,
55 const PlatformStyle *platform_style, QObject *parent);
57
59 std::vector<WalletModel *> getOpenWallets() const;
60
61 WalletModel *getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet);
62
65 std::map<std::string, bool> listWalletDir() const;
66
67 void closeWallet(WalletModel *wallet_model, QWidget *parent = nullptr);
68 void closeAllWallets(QWidget *parent = nullptr);
69
70Q_SIGNALS:
71 void walletAdded(WalletModel *wallet_model);
72 void walletRemoved(WalletModel *wallet_model);
73
75 QByteArray transaction);
76
77private:
78 QThread *const m_activity_thread;
79 QObject *const m_activity_worker;
84 mutable QMutex m_mutex;
85 std::vector<WalletModel *> m_wallets;
86 std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
87
89};
90
91class WalletControllerActivity : public QObject {
92 Q_OBJECT
93
94public:
96 QWidget *parent_widget);
98
99Q_SIGNALS:
100 void finished();
101
102protected:
104 QObject *worker() const { return m_wallet_controller->m_activity_worker; }
105
106 void showProgressDialog(const QString &label_text);
108
110 QWidget *const m_parent_widget;
111 QProgressDialog *m_progress_dialog{nullptr};
114 std::vector<bilingual_str> m_warning_message;
115};
116
118 Q_OBJECT
119
120public:
121 CreateWalletActivity(WalletController *wallet_controller,
122 QWidget *parent_widget);
123 virtual ~CreateWalletActivity();
124
125 void create();
126
127Q_SIGNALS:
128 void created(WalletModel *wallet_model);
129
130private:
131 void askPassphrase();
132 void createWallet();
133 void finish();
134
138};
139
141 Q_OBJECT
142
143public:
144 OpenWalletActivity(WalletController *wallet_controller,
145 QWidget *parent_widget);
146
147 void open(const std::string &path);
148
149Q_SIGNALS:
150 void opened(WalletModel *wallet_model);
151
152private:
153 void finish();
154};
155
156#endif // BITCOIN_QT_WALLETCONTROLLER_H
Multifunctional dialog to ask for passphrases.
Model for Bitcoin network client.
Definition: clientmodel.h:43
AskPassphraseDialog * m_passphrase_dialog
CreateWalletDialog * m_create_wallet_dialog
CreateWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
void created(WalletModel *wallet_model)
Dialog for creating wallets.
void opened(WalletModel *wallet_model)
OpenWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
void open(const std::string &path)
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:48
std::vector< bilingual_str > m_warning_message
WalletController *const m_wallet_controller
QProgressDialog * m_progress_dialog
interfaces::Node & node() const
QObject * worker() const
void showProgressDialog(const QString &label_text)
WalletControllerActivity(WalletController *wallet_controller, QWidget *parent_widget)
QWidget *const m_parent_widget
Controller between interfaces::Node, WalletModel instances and the GUI.
WalletController(ClientModel &client_model, const PlatformStyle *platform_style, QObject *parent)
WalletModel * getOrCreateWallet(std::unique_ptr< interfaces::Wallet > wallet)
ClientModel & m_client_model
void removeAndDeleteWallet(WalletModel *wallet_model)
void walletAdded(WalletModel *wallet_model)
void closeAllWallets(QWidget *parent=nullptr)
std::unique_ptr< interfaces::Handler > m_handler_load_wallet
QThread *const m_activity_thread
std::map< std::string, bool > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
std::vector< WalletModel * > getOpenWallets() const
Returns wallet models currently open.
QObject *const m_activity_worker
void walletRemoved(WalletModel *wallet_model)
const PlatformStyle *const m_platform_style
void coinsSent(interfaces::Wallet &wallet, SendCoinsRecipient recipient, QByteArray transaction)
interfaces::Node & m_node
std::vector< WalletModel * > m_wallets
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
OptionsModel *const m_options_model
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:59
Interface for accessing a wallet.
Definition: wallet.h:59
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:55
Bilingual messages:
Definition: translation.h:17