Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2019-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_QT_WALLETCONTROLLER_H6#define BITCOIN_QT_WALLETCONTROLLER_H8#include <qt/sendcoinsrecipient.h>9#include <support/allocators/secure.h>10#include <sync.h>11#include <util/translation.h>13#include <map>14#include <memory>15#include <string>16#include <vector>18#include <QMessageBox>19#include <QMutex>20#include <QProgressDialog>21#include <QThread>22#include <QTimer>23#include <QString>25class ClientModel;26class OptionsModel;27class PlatformStyle;28class WalletModel;30namespace interfaces {31class Handler;32class Node;33class Wallet;34} // namespace interfaces36namespace fs {37class path;38}40class AskPassphraseDialog;41class CreateWalletActivity;42class CreateWalletDialog;43class MigrateWalletActivity;44class OpenWalletActivity;45class WalletControllerActivity;47/**48* Controller between interfaces::Node, WalletModel instances and the GUI.49*/50class WalletController : public QObject51{52Q_OBJECT54void removeAndDeleteWallet(WalletModel* wallet_model);56public:57WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent);58~WalletController();60WalletModel* getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet);62//! Returns all wallet names in the wallet dir mapped to whether the wallet63//! is loaded.64std::map<std::string, std::pair<bool, std::string>> listWalletDir() const;66void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);67void closeAllWallets(QWidget* parent = nullptr);69Q_SIGNALS:70void walletAdded(WalletModel* wallet_model);71void walletRemoved(WalletModel* wallet_model);73void coinsSent(WalletModel* wallet_model, SendCoinsRecipient recipient, QByteArray transaction);75private:76QThread* const m_activity_thread;77QObject* const m_activity_worker;78ClientModel& m_client_model;79interfaces::Node& m_node;80const PlatformStyle* const m_platform_style;81OptionsModel* const m_options_model;82mutable QMutex m_mutex;83std::vector<WalletModel*> m_wallets;84std::unique_ptr<interfaces::Handler> m_handler_load_wallet;86friend class WalletControllerActivity;87friend class MigrateWalletActivity;89//! Starts the wallet closure procedure90void removeWallet(WalletModel* wallet_model);91};93class WalletControllerActivity : public QObject94{95Q_OBJECT97public:98WalletControllerActivity(WalletController* wallet_controller, QWidget* parent_widget);99virtual ~WalletControllerActivity() = default;101Q_SIGNALS:102void finished();104protected:105interfaces::Node& node() const { return m_wallet_controller->m_node; }106QObject* worker() const { return m_wallet_controller->m_activity_worker; }108void showProgressDialog(const QString& title_text, const QString& label_text, bool show_minimized=false);110WalletController* const m_wallet_controller;111QWidget* const m_parent_widget;112WalletModel* m_wallet_model{nullptr};113bilingual_str m_error_message;114std::vector<bilingual_str> m_warning_message;115};118class CreateWalletActivity : public WalletControllerActivity119{120Q_OBJECT122public:123CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);124virtual ~CreateWalletActivity();126void create();128Q_SIGNALS:129void created(WalletModel* wallet_model);131private:132void askPassphrase();133void createWallet();134void finish();136SecureString m_passphrase;137CreateWalletDialog* m_create_wallet_dialog{nullptr};138AskPassphraseDialog* m_passphrase_dialog{nullptr};139};141class OpenWalletActivity : public WalletControllerActivity142{143Q_OBJECT145public:146OpenWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);148void open(const std::string& path);150Q_SIGNALS:151void opened(WalletModel* wallet_model);153private:154void finish();155};157class LoadWalletsActivity : public WalletControllerActivity158{159Q_OBJECT161public:162LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget);164void load(bool show_loading_minimized);165};167class RestoreWalletActivity : public WalletControllerActivity168{169Q_OBJECT171public:172RestoreWalletActivity(WalletController* wallet_controller, QWidget* parent_widget);174void restore(const fs::path& backup_file, const std::string& wallet_name);176Q_SIGNALS:177void restored(WalletModel* wallet_model);179private:180void finish();181};183class MigrateWalletActivity : public WalletControllerActivity184{185Q_OBJECT187public:188MigrateWalletActivity(WalletController* wallet_controller, QWidget* parent) : WalletControllerActivity(wallet_controller, parent) {}190void restore_and_migrate(const fs::path& path, const std::string& wallet_name);191void migrate(const std::string& path);193Q_SIGNALS:194void migrated(WalletModel* wallet_model);196private:197QString m_success_message;199void do_migrate(const std::string& name, bool load_wallet);200void finish();201};203#endif // BITCOIN_QT_WALLETCONTROLLER_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.