 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
23 #include <QApplication>
24 #include <QMessageBox>
25 #include <QMutexLocker>
32 , m_activity_thread(new QThread(this))
33 , m_activity_worker(new QObject)
34 , m_client_model(client_model)
36 , m_platform_style(platform_style)
37 , m_options_model(client_model.getOptionsModel())
72 std::map<std::string, bool> wallets;
74 wallets[
name] =
false;
77 auto it = wallets.find(wallet_model->wallet().getWalletName());
78 if (
it != wallets.end())
it->second =
true;
85 QMessageBox box(parent);
86 box.setWindowTitle(tr(
"Close wallet"));
88 box.setInformativeText(tr(
"Closing the wallet for too long can result in having to resync the entire chain if pruning is enabled."));
89 box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
90 box.setDefaultButton(QMessageBox::Yes);
91 if (box.exec() != QMessageBox::Yes)
return;
101 QMessageBox::StandardButton button = QMessageBox::question(parent, tr(
"Close all wallets"),
102 tr(
"Are you sure you wish to close all wallets?"),
103 QMessageBox::Yes|QMessageBox::Cancel,
105 if (button != QMessageBox::Yes)
return;
109 wallet_model->wallet().remove();
124 if (wallet_model->wallet().getWalletName() ==
name) {
139 wallet_model->moveToThread(thread());
142 wallet_model->setParent(
this);
150 const bool called = QMetaObject::invokeMethod(wallet_model,
"startPollBalance");
156 if (QApplication::activeModalWidget()) {
157 connect(qApp, &QApplication::focusWindowChanged, wallet_model, [
this, wallet_model]() {
158 if (!QApplication::activeModalWidget()) {
161 }, Qt::QueuedConnection);
165 }, Qt::QueuedConnection);
189 : QObject(wallet_controller)
190 , m_wallet_controller(wallet_controller)
191 , m_parent_widget(parent_widget)
331 QString
name = path.empty() ? QString(
"["+tr(
"default wallet")+
"]") : QString::fromStdString(path);
335 QTimer::singleShot(0,
worker(), [
this, path] {
void walletRemoved(WalletModel *wallet_model)
virtual ~CreateWalletActivity()
std::unique_ptr< interfaces::Handler > m_handler_load_wallet
std::vector< bilingual_str > m_warning_message
Interface to Bitcoin wallet from Qt view code.
void removeAndDeleteWallet(WalletModel *wallet_model)
bool isMakeBlankWalletChecked() const
CreateWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
bool isDisablePrivateKeysChecked() const
virtual std::unique_ptr< Wallet > createWallet(const std::string &name, const SecureString &passphrase, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Create new wallet.
bilingual_str m_error_message
CreateWalletDialog * m_create_wallet_dialog
Multifunctional dialog to ask for passphrases.
std::map< std::string, bool > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
void walletAdded(WalletModel *wallet_model)
std::vector< WalletModel * > m_wallets
ClientModel & m_client_model
OpenWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
static const int MAX_PASSPHRASE_SIZE
void destroyProgressDialog()
void ObjectInvoke(QObject *object, Fn &&function, Qt::ConnectionType connection=Qt::QueuedConnection)
Queue a function to run in an object's event loop.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
interfaces::Wallet & wallet() const
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
virtual std::unique_ptr< Wallet > loadWallet(const std::string &name, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
bool isEncryptWalletChecked() const
std::vector< WalletModel * > getOpenWallets() const
Returns wallet models currently open.
void opened(WalletModel *wallet_model)
virtual std::vector< std::string > listWalletDir()=0
Return available wallets in wallet directory.
QWidget *const m_parent_widget
SecureString m_passphrase
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
WalletModel * m_wallet_model
const PlatformStyle *const m_platform_style
Controller between interfaces::Node, WalletModel instances and the GUI.
virtual WalletClient & walletClient()=0
Get wallet client.
void created(WalletModel *wallet_model)
void PolishProgressDialog(QProgressDialog *dialog)
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
void coinsSent(WalletModel *wallet_model, SendCoinsRecipient recipient, QByteArray transaction)
interfaces::Node & node() const
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
WalletModel * getOrCreateWallet(std::unique_ptr< interfaces::Wallet > wallet)
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
WalletController *const m_wallet_controller
Model for Bitcoin network client.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
QString HtmlEscape(const QString &str, bool fMultiLine)
virtual ~WalletControllerActivity()
AskPassphraseDialog * m_passphrase_dialog
Dialog for creating wallets.
QObject *const m_activity_worker
WalletController(ClientModel &client_model, const PlatformStyle *platform_style, QObject *parent)
bool isDescriptorWalletChecked() const
interfaces::Node & m_node
WalletControllerActivity(WalletController *wallet_controller, QWidget *parent_widget)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
QProgressDialog * m_progress_dialog
QThread *const m_activity_thread
void open(const std::string &path)
QString getDisplayName() const
QString walletName() const
@ Encrypt
Ask passphrase twice and encrypt.
assert(std::addressof(::ChainstateActive().CoinsTip())==std::addressof(coins_cache))
void closeAllWallets(QWidget *parent=nullptr)
void showProgressDialog(const QString &label_text)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.