wallet: init, don't error out when loading legacy wallets

Instead of failing during initialization when encountering a legacy wallet, skip
loading the wallet and notify the user accordingly.

This allows users to access migration functionalities without needing to manually
remove the wallet from settings.json or resort to using the bitcoin-wallet utility.

This means that GUI users will be able to use the migration button, and bitcoin-cli
users will be able to call the migratewallet RPC directly after init.
This commit is contained in:
furszy
2025-05-08 11:54:47 -04:00
parent 66c968b4b4
commit 9f94de5bb5
5 changed files with 16 additions and 5 deletions

View File

@@ -1383,8 +1383,8 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
// BERKELEY_RO can only be opened if require_format was set, which only occurs in migration.
if (format && format == DatabaseFormat::BERKELEY_RO && (!options.require_format || options.require_format != DatabaseFormat::BERKELEY_RO)) {
error = Untranslated(strprintf("Failed to open database path '%s'. The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC).", fs::PathToString(path)));
status = DatabaseStatus::FAILED_BAD_FORMAT;
error = Untranslated(strprintf("Failed to open database path '%s'. The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC or the GUI option).", fs::PathToString(path)));
status = DatabaseStatus::FAILED_LEGACY_DISABLED;
return nullptr;
}