Bitcoin Core 22.99.0
P2P Digital Currency
walletcontroller.h
Go to the documentation of this file.
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
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
25class ClientModel;
26class OptionsModel;
27class PlatformStyle;
28class WalletModel;
29
30namespace interfaces {
31class Handler;
32class Node;
33class Wallet;
34} // namespace interfaces
35
41
45class WalletController : public QObject
46{
47 Q_OBJECT
48
49 void removeAndDeleteWallet(WalletModel* wallet_model);
50
51public:
52 WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent);
54
55 WalletModel* getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet);
56
59 std::map<std::string, bool> listWalletDir() const;
60
61 void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);
62 void closeAllWallets(QWidget* parent = nullptr);
63
64Q_SIGNALS:
65 void walletAdded(WalletModel* wallet_model);
66 void walletRemoved(WalletModel* wallet_model);
67
68 void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction);
69
70private:
71 QThread* const m_activity_thread;
72 QObject* const m_activity_worker;
77 mutable QMutex m_mutex;
78 std::vector<WalletModel*> m_wallets;
79 std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
80
82};
83
84class WalletControllerActivity : public QObject
85{
86 Q_OBJECT
87
88public:
89 WalletControllerActivity(WalletController* wallet_controller, QWidget* parent_widget);
90 virtual ~WalletControllerActivity() = default;
91
92Q_SIGNALS:
93 void finished();
94
95protected:
97 QObject* worker() const { return m_wallet_controller->m_activity_worker; }
98
99 void showProgressDialog(const QString& title_text, const QString& label_text);
100
102 QWidget* const m_parent_widget;
105 std::vector<bilingual_str> m_warning_message;
106};
107
108
110{
111 Q_OBJECT
112
113public:
114 CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);
115 virtual ~CreateWalletActivity();
116
117 void create();
118
119Q_SIGNALS:
120 void created(WalletModel* wallet_model);
121
122private:
123 void askPassphrase();
124 void createWallet();
125 void finish();
126
130};
131
133{
134 Q_OBJECT
135
136public:
137 OpenWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);
138
139 void open(const std::string& path);
140
141Q_SIGNALS:
142 void opened(WalletModel* wallet_model);
143
144private:
145 void finish();
146};
147
149{
150 Q_OBJECT
151
152public:
153 LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget);
154
155 void load();
156};
157
158#endif // BITCOIN_QT_WALLETCONTROLLER_H
Multifunctional dialog to ask for passphrases.
Model for Bitcoin network client.
Definition: clientmodel.h:48
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.
LoadWalletsActivity(WalletController *wallet_controller, QWidget *parent_widget)
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:39
std::vector< bilingual_str > m_warning_message
WalletController *const m_wallet_controller
interfaces::Node & node() const
QObject * worker() const
void showProgressDialog(const QString &title_text, const QString &label_text)
virtual ~WalletControllerActivity()=default
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.
void coinsSent(WalletModel *wallet_model, SendCoinsRecipient recipient, QByteArray transaction)
QObject *const m_activity_worker
void walletRemoved(WalletModel *wallet_model)
const PlatformStyle *const m_platform_style
interfaces::Node & m_node
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
OptionsModel *const m_options_model
std::vector< WalletModel * > m_wallets
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:52
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:55
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:59
Bilingual messages:
Definition: translation.h:16