24 #include <QApplication> 25 #include <QMessageBox> 26 #include <QMutexLocker> 33 , m_activity_thread(new QThread(this))
34 , m_activity_worker(new QObject)
35 , m_client_model(client_model)
37 , m_platform_style(platform_style)
38 , m_options_model(client_model.getOptionsModel())
73 std::map<std::string, bool> wallets;
75 wallets[
name] =
false;
78 auto it = wallets.find(wallet_model->wallet().getWalletName());
79 if (it != wallets.end()) it->second =
true;
86 QMessageBox box(parent);
87 box.setWindowTitle(tr(
"Close wallet"));
89 box.setInformativeText(tr(
"Closing the wallet for too long can result in having to resync the entire chain if pruning is enabled."));
90 box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
91 box.setDefaultButton(QMessageBox::Yes);
92 if (box.exec() != QMessageBox::Yes)
return;
102 QMessageBox::StandardButton button = QMessageBox::question(parent, tr(
"Close all wallets"),
103 tr(
"Are you sure you wish to close all wallets?"),
104 QMessageBox::Yes|QMessageBox::Cancel,
106 if (button != QMessageBox::Yes)
return;
110 wallet_model->wallet().remove();
125 if (wallet_model->wallet().getWalletName() ==
name) {
140 wallet_model->moveToThread(thread());
143 wallet_model->setParent(
this);
151 const bool called = QMetaObject::invokeMethod(wallet_model,
"startPollBalance");
157 if (QApplication::activeModalWidget()) {
158 connect(qApp, &QApplication::focusWindowChanged, wallet_model, [
this, wallet_model]() {
159 if (!QApplication::activeModalWidget()) {
162 }, Qt::QueuedConnection);
166 }, Qt::QueuedConnection);
190 : QObject(wallet_controller)
191 , m_wallet_controller(wallet_controller)
192 , m_parent_widget(parent_widget)
299 std::vector<ExternalSigner> signers;
302 }
catch (
const std::runtime_error& e) {
303 QMessageBox::critical(
nullptr, tr(
"Can't list signers"), e.what());
347 QString
name = path.empty() ? QString(
"["+tr(
"default wallet")+
"]") : QString::fromStdString(path);
351 QTimer::singleShot(0,
worker(), [
this, path] {
bool isExternalSignerChecked() const
std::vector< WalletModel * > m_wallets
void destroyProgressDialog()
static const int MAX_PASSPHRASE_SIZE
interfaces::Wallet & wallet() const
bool isDescriptorWalletChecked() const
void coinsSent(WalletModel *wallet, SendCoinsRecipient recipient, QByteArray transaction)
virtual ~CreateWalletActivity()
bilingual_str m_error_message
virtual std::vector< std::string > listWalletDir()=0
Return available wallets in wallet directory.
interfaces::Node & node() const
bool isEncryptWalletChecked() const
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
CreateWalletDialog * m_create_wallet_dialog
void closeAllWallets(QWidget *parent=nullptr)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
void opened(WalletModel *wallet_model)
const PlatformStyle *const m_platform_style
CreateWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
void showProgressDialog(const QString &label_text)
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name...
Ask passphrase twice and encrypt.
QString walletName() const
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
OpenWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
Controller between interfaces::Node, WalletModel instances and the GUI.
QProgressDialog * m_progress_dialog
QString HtmlEscape(const QString &str, bool fMultiLine)
bool isDisablePrivateKeysChecked() const
Indicates that the wallet needs an external signer.
QObject *const m_activity_worker
void coinsSent(WalletModel *wallet_model, SendCoinsRecipient recipient, QByteArray transaction)
std::map< std::string, bool > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
SecureString m_passphrase
bool isMakeBlankWalletChecked() const
void created(WalletModel *wallet_model)
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
void ObjectInvoke(QObject *object, Fn &&function, Qt::ConnectionType connection=Qt::QueuedConnection)
Queue a function to run in an object's event loop.
QWidget *const m_parent_widget
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank.".
void open(const std::string &path)
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
std::vector< bilingual_str > m_warning_message
ClientModel & m_client_model
virtual ~WalletControllerActivity()
interfaces::Node & m_node
void walletAdded(WalletModel *wallet_model)
virtual std::vector< ExternalSigner > externalSigners()=0
List external signers.
void PolishProgressDialog(QProgressDialog *dialog)
Model for Bitcoin network client.
AskPassphraseDialog * m_passphrase_dialog
virtual std::unique_ptr< Wallet > loadWallet(const std::string &name, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
std::vector< WalletModel * > getOpenWallets() const
Returns wallet models currently open.
virtual WalletClient & walletClient()=0
Get wallet client.
Interface to Bitcoin wallet from Qt view code.
Multifunctional dialog to ask for passphrases.
Dialog for creating wallets.
WalletModel * getOrCreateWallet(std::unique_ptr< interfaces::Wallet > wallet)
void walletRemoved(WalletModel *wallet_model)
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.
WalletControllerActivity(WalletController *wallet_controller, QWidget *parent_widget)
QString getDisplayName() const
QThread *const m_activity_thread
WalletController(ClientModel &client_model, const PlatformStyle *platform_style, QObject *parent)
void setSigners(const std::vector< ExternalSigner > &signers)
std::unique_ptr< interfaces::Handler > m_handler_load_wallet
Indicate that this wallet supports DescriptorScriptPubKeyMan.
WalletModel * m_wallet_model
void removeAndDeleteWallet(WalletModel *wallet_model)
WalletController *const m_wallet_controller
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).