diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index a5a5f8ec6f22b..1523b7d6133de 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -42,12 +42,12 @@ std::vector ListDatabases(const fs::path& wallet_dir) (IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) { // Found a directory which contains wallet.dat btree file, add it as a wallet. paths.emplace_back(path); - } else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path())) { + } else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && it->path().extension() != ".bak") { if (it->path().filename() == "wallet.dat") { // Found top-level wallet.dat btree file, add top level directory "" // as a wallet. paths.emplace_back(); - } else { + } else if (IsBDBFile(it->path())) { // Found top-level btree file not called wallet.dat. Current bitcoin // software will never create these files but will allow them to be // opened in a shared database environment for backwards compatibility. diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index b4dc163e341f6..48ad8e4f2a1f8 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -548,10 +548,15 @@ def test_default_wallet(self): assert_equal(info["descriptors"], True) assert_equal(info["format"], "sqlite") + walletdir_list = wallet.listwalletdir() + assert {"name": info["walletname"]} in walletdir_list["wallets"] + # Check backup existence and its non-empty wallet filename - backup_path = self.nodes[0].wallets_path / f'default_wallet_{curr_time}.legacy.bak' + backup_filename = f"default_wallet_{curr_time}.legacy.bak" + backup_path = self.nodes[0].wallets_path / backup_filename assert backup_path.exists() assert_equal(str(backup_path), res['backup_path']) + assert {"name": backup_filename} not in walletdir_list["wallets"] def test_direct_file(self): self.log.info("Test migration of a wallet that is not in a wallet directory")