20#include <QApplication>
21#include <QMutexLocker>
35 [
this](std::unique_ptr<interfaces::Wallet>
wallet) {
39 for (std::unique_ptr<interfaces::Wallet> &
wallet :
65 std::map<std::string, bool>
wallets;
79 QMessageBox
box(parent);
80 box.setWindowTitle(
tr(
"Close wallet"));
81 box.setText(
tr(
"Are you sure you wish to close the wallet <i>%1</i>?")
83 box.setInformativeText(
84 tr(
"Closing the wallet for too long can result in having to resync the "
85 "entire chain if pruning is enabled."));
86 box.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
87 box.setDefaultButton(QMessageBox::Yes);
88 if (
box.exec() != QMessageBox::Yes) {
99 QMessageBox::StandardButton
button = QMessageBox::question(
100 parent,
tr(
"Close all wallets"),
101 tr(
"Are you sure you wish to close all wallets?"),
102 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
103 if (
button != QMessageBox::Yes) {
117 std::unique_ptr<interfaces::Wallet>
wallet) {
143 QMetaObject::invokeMethod(
wallet_model,
"startPollBalance");
151 if (QApplication::activeModalWidget()) {
155 if (!QApplication::activeModalWidget()) {
159 Qt::QueuedConnection);
164 Qt::QueuedConnection);
242 tr(
"Creating Wallet <b>%1</b>...")
258 std::unique_ptr<interfaces::Wallet>
wallet =
275 QMessageBox::critical(
279 QMessageBox::warning(
281 QString::fromStdString(
318 QMessageBox::critical(
322 QMessageBox::warning(
324 QString::fromStdString(
337 : QString::fromStdString(path);
340 tr(
"Opening Wallet <b>%1</b>...").
arg(
name.toHtmlEscaped()));
342 QTimer::singleShot(0,
worker(), [
this, path] {
343 std::unique_ptr<interfaces::Wallet>
wallet =
Multifunctional dialog to ask for passphrases.
@ Encrypt
Ask passphrase twice and encrypt.
Model for Bitcoin network client.
virtual ~CreateWalletActivity()
AskPassphraseDialog * m_passphrase_dialog
CreateWalletDialog * m_create_wallet_dialog
SecureString m_passphrase
CreateWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
void created(WalletModel *wallet_model)
Dialog for creating wallets.
bool isMakeBlankWalletChecked() const
QString walletName() const
bool isDisablePrivateKeysChecked() const
bool isEncryptWalletChecked() const
bool isDescriptorWalletChecked() const
void opened(WalletModel *wallet_model)
OpenWalletActivity(WalletController *wallet_controller, QWidget *parent_widget)
void open(const std::string &path)
WalletModel * m_wallet_model
virtual ~WalletControllerActivity()
std::vector< bilingual_str > m_warning_message
WalletController *const m_wallet_controller
QProgressDialog * m_progress_dialog
interfaces::Node & node() const
void destroyProgressDialog()
void showProgressDialog(const QString &label_text)
bilingual_str m_error_message
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.
std::vector< WalletModel * > getOpenWallets() const
Returns wallet models currently open.
QObject *const m_activity_worker
void walletRemoved(WalletModel *wallet_model)
const PlatformStyle *const m_platform_style
void coinsSent(interfaces::Wallet &wallet, SendCoinsRecipient recipient, QByteArray transaction)
interfaces::Node & m_node
std::vector< WalletModel * > m_wallets
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
Interface to Bitcoin wallet from Qt view code.
void coinsSent(interfaces::Wallet &wallet, SendCoinsRecipient recipient, QByteArray transaction)
virtual WalletClient & walletClient()=0
Get wallet client.
virtual std::vector< std::string > listWalletDir()=0
Return available wallets in wallet directory.
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.
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
virtual std::unique_ptr< Wallet > loadWallet(const std::string &name, bilingual_str &error, std::vector< bilingual_str > &warnings)=0
Load existing wallet.
static const int MAX_PASSPHRASE_SIZE
QString HtmlEscape(const QString &str, bool fMultiLine)
void PolishProgressDialog(QProgressDialog *dialog)
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...