Skip to content

Commit 6b2dcba

Browse files
committed
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.
1 parent 3ddbdd1 commit 6b2dcba

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/wallet/db.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
4242
(IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) {
4343
// Found a directory which contains wallet.dat btree file, add it as a wallet.
4444
paths.emplace_back(path);
45-
} else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path()) && it->path().extension() != ".bak") {
45+
} else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && it->path().extension() != ".bak") {
4646
if (it->path().filename() == "wallet.dat") {
4747
// Found top-level wallet.dat btree file, add top level directory ""
4848
// as a wallet.
4949
paths.emplace_back();
50-
} else {
50+
} else if (IsBDBFile(it->path())) {
5151
// Found top-level btree file not called wallet.dat. Current bitcoin
5252
// software will never create these files but will allow them to be
5353
// opened in a shared database environment for backwards compatibility.

test/functional/wallet_migration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ def test_default_wallet(self):
539539
assert_equal(info["format"], "sqlite")
540540

541541
walletdir_list = wallet.listwalletdir()
542+
assert {"name": info["walletname"]} in walletdir_list["wallets"]
542543

543544
# Check backup existence and its non-empty wallet filename
544545
backup_filename = f"default_wallet_{curr_time}.legacy.bak"

0 commit comments

Comments
 (0)