gui: Disallow loading legacy wallets

Instead of allowing users to load a legacy wallet from the "Open Wallet"
menu, show the legacy wallet greyed out with a message that the wallet
needs to be migrated.
This commit is contained in:
Ava Chow
2025-05-26 13:23:04 -07:00
parent 09955172f3
commit f3a444c45f

View File

@@ -398,15 +398,19 @@ void BitcoinGUI::createActions()
connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] { connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
m_open_wallet_menu->clear(); m_open_wallet_menu->clear();
for (const auto& [path, info] : m_wallet_controller->listWalletDir()) { for (const auto& [path, info] : m_wallet_controller->listWalletDir()) {
const auto& [loaded, _] = info; const auto& [loaded, format] = info;
QString name = GUIUtil::WalletDisplayName(path); QString name = GUIUtil::WalletDisplayName(path);
// An single ampersand in the menu item's text sets a shortcut for this item. // An single ampersand in the menu item's text sets a shortcut for this item.
// Single & are shown when && is in the string. So replace & with &&. // Single & are shown when && is in the string. So replace & with &&.
name.replace(QChar('&'), QString("&&")); name.replace(QChar('&'), QString("&&"));
bool is_legacy = format == "bdb";
if (is_legacy) {
name += " (needs migration)";
}
QAction* action = m_open_wallet_menu->addAction(name); QAction* action = m_open_wallet_menu->addAction(name);
if (loaded) { if (loaded || is_legacy) {
// This wallet is already loaded // This wallet is already loaded or it is a legacy wallet
action->setEnabled(false); action->setEnabled(false);
continue; continue;
} }