wallet: List sqlite wallets with empty string name

Although it is not explicitly possible to create a default wallet with
descriptors, it is possible to migrate a default wallet and have it end
up being a default wallet with descriptors. These wallets should be
listed by ListDatabases so that it appears in wallet directory listings
to avoid user confusion.
This commit is contained in:
Ava Chow 2024-06-10 17:23:55 -04:00
parent 3ddbdd1815
commit 6b2dcba076
2 changed files with 3 additions and 2 deletions

View file

@ -42,12 +42,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
(IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) { (IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) {
// Found a directory which contains wallet.dat btree file, add it as a wallet. // Found a directory which contains wallet.dat btree file, add it as a wallet.
paths.emplace_back(path); paths.emplace_back(path);
} else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path()) && it->path().extension() != ".bak") { } else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && it->path().extension() != ".bak") {
if (it->path().filename() == "wallet.dat") { if (it->path().filename() == "wallet.dat") {
// Found top-level wallet.dat btree file, add top level directory "" // Found top-level wallet.dat btree file, add top level directory ""
// as a wallet. // as a wallet.
paths.emplace_back(); paths.emplace_back();
} else { } else if (IsBDBFile(it->path())) {
// Found top-level btree file not called wallet.dat. Current bitcoin // Found top-level btree file not called wallet.dat. Current bitcoin
// software will never create these files but will allow them to be // software will never create these files but will allow them to be
// opened in a shared database environment for backwards compatibility. // opened in a shared database environment for backwards compatibility.

View file

@ -539,6 +539,7 @@ class WalletMigrationTest(BitcoinTestFramework):
assert_equal(info["format"], "sqlite") assert_equal(info["format"], "sqlite")
walletdir_list = wallet.listwalletdir() walletdir_list = wallet.listwalletdir()
assert {"name": info["walletname"]} in walletdir_list["wallets"]
# Check backup existence and its non-empty wallet filename # Check backup existence and its non-empty wallet filename
backup_filename = f"default_wallet_{curr_time}.legacy.bak" backup_filename = f"default_wallet_{curr_time}.legacy.bak"