@@ -370,9 +370,18 @@ void BitcoinGUI::createActions()
370
370
connect (openAction, &QAction::triggered, this , &BitcoinGUI::openClicked);
371
371
connect (m_open_wallet_action->menu (), &QMenu::aboutToShow, [this ] {
372
372
m_open_wallet_action->menu ()->clear ();
373
- for (std::string path : m_wallet_controller->getWalletsAvailableToOpen ()) {
373
+ std::vector<std::string> available_wallets = m_wallet_controller->getWalletsAvailableToOpen ();
374
+ std::vector<std::string> wallets = m_node.listWalletDir ();
375
+ for (const auto & path : wallets) {
374
376
QString name = path.empty () ? QString (" [" +tr (" default wallet" )+" ]" ) : QString::fromStdString (path);
375
377
QAction* action = m_open_wallet_action->menu ()->addAction (name);
378
+
379
+ if (std::find (available_wallets.begin (), available_wallets.end (), path) == available_wallets.end ()) {
380
+ // This wallet is already loaded
381
+ action->setEnabled (false );
382
+ continue ;
383
+ }
384
+
376
385
connect (action, &QAction::triggered, [this , name, path] {
377
386
OpenWalletActivity* activity = m_wallet_controller->openWallet (path);
378
387
@@ -400,6 +409,10 @@ void BitcoinGUI::createActions()
400
409
assert (invoked);
401
410
});
402
411
}
412
+ if (wallets.empty ()) {
413
+ QAction* action = m_open_wallet_action->menu ()->addAction (tr (" No wallets available" ));
414
+ action->setEnabled (false );
415
+ }
403
416
});
404
417
connect (m_close_wallet_action, &QAction::triggered, [this ] {
405
418
m_wallet_controller->closeWallet (walletFrame->currentWalletModel (), this );
0 commit comments