Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
walletcontroller.h
Go to the documentation of this file.
1// Copyright (c) 2019-present 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 PlatformStyle;
27class WalletModel;
28
29namespace interfaces {
30class Handler;
31class Node;
32class Wallet;
33} // namespace interfaces
34
35namespace fs {
36class path;
37}
38
45
49class WalletController : public QObject
50{
52
54
55public:
58
59 WalletModel* getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet);
60
63 std::map<std::string, std::pair<bool, std::string>> listWalletDir() const;
64
65 void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);
66 void closeAllWallets(QWidget* parent = nullptr);
67
71
73
74private:
76 QObject* const m_activity_worker;
80 mutable QMutex m_mutex;
81 std::vector<WalletModel*> m_wallets;
82 std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
83
86
89};
90
91class WalletControllerActivity : public QObject
92{
94
95public:
97 virtual ~WalletControllerActivity() = default;
98
100 void finished();
101
102protected:
104 QObject* worker() const { return m_wallet_controller->m_activity_worker; }
105
106 void showProgressDialog(const QString& title_text, const QString& label_text, bool show_minimized=false);
107
109 QWidget* const m_parent_widget;
112 std::vector<bilingual_str> m_warning_message;
113};
114
115
138
140{
142
143public:
145
146 void open(const std::string& path);
147
150
151private:
152 void finish();
153};
154
164
166{
168
169public:
171
172 void restore(const fs::path& backup_file, const std::string& wallet_name);
173
176
177private:
178 void finish();
179};
180
182{
184
185public:
187
188 void restore_and_migrate(const fs::path& path, const std::string& wallet_name);
189 void migrate(const std::string& path);
190
193
194private:
196
197 void do_migrate(const std::string& name, bool load_wallet);
198 void finish();
199};
200
201#endif // BITCOIN_QT_WALLETCONTROLLER_H
Multifunctional dialog to ask for passphrases.
Model for Bitcoin network client.
Definition clientmodel.h:57
AskPassphraseDialog * m_passphrase_dialog
CreateWalletDialog * m_create_wallet_dialog
void created(WalletModel *wallet_model)
Dialog for creating wallets.
void load(bool show_loading_minimized)
void do_migrate(const std::string &name, bool load_wallet)
MigrateWalletActivity(WalletController *wallet_controller, QWidget *parent)
void restore_and_migrate(const fs::path &path, const std::string &wallet_name)
void migrated(WalletModel *wallet_model)
void migrate(const std::string &path)
void opened(WalletModel *wallet_model)
void open(const std::string &path)
void restore(const fs::path &backup_file, const std::string &wallet_name)
void restored(WalletModel *wallet_model)
std::vector< bilingual_str > m_warning_message
WalletController *const m_wallet_controller
interfaces::Node & node() const
void showProgressDialog(const QString &title_text, const QString &label_text, bool show_minimized=false)
virtual ~WalletControllerActivity()=default
Controller between interfaces::Node, WalletModel instances and the GUI.
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
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)
std::map< std::string, std::pair< bool, std::string > > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
void removeWallet(WalletModel *wallet_model)
Starts the wallet closure procedure.
std::vector< WalletModel * > m_wallets
Interface to Bitcoin wallet from Qt view code.
Definition walletmodel.h:49
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition fs.h:33
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:66
const char * name
Definition rest.cpp:71
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition secure.h:53
Bilingual messages:
Definition translation.h:24
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82