Skip to content

Commit f77ba34

Browse files
committed
gui: Add closeWallet to WalletController
1 parent f6122ab commit f77ba34

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/qt/walletcontroller.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ OpenWalletActivity* WalletController::openWallet(const std::string& name, QWidge
6363
return activity;
6464
}
6565

66+
void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
67+
{
68+
QMessageBox box(parent);
69+
box.setWindowTitle(tr("Close wallet"));
70+
box.setText(tr("Are you sure you wish to close wallet <i>%1</i>?").arg(wallet_model->getDisplayName()));
71+
box.setInformativeText(tr("Closing the wallet for too long can result in having to resync the entire chain if pruning is enabled."));
72+
box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
73+
box.setDefaultButton(QMessageBox::Yes);
74+
if (box.exec() != QMessageBox::Yes) return;
75+
76+
// First remove wallet from node.
77+
wallet_model->wallet().remove();
78+
// Now release the model.
79+
removeAndDeleteWallet(wallet_model);
80+
}
81+
6682
WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet)
6783
{
6884
QMutexLocker locker(&m_mutex);

src/qt/walletcontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class WalletController : public QObject
4444
std::vector<std::string> getWalletsAvailableToOpen() const;
4545

4646
OpenWalletActivity* openWallet(const std::string& name, QWidget* parent = nullptr);
47+
void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);
4748

4849
private Q_SLOTS:
4950
void addWallet(WalletModel* wallet_model);

0 commit comments

Comments
 (0)