Skip to content

Commit 69f59af

Browse files
committed
Bugfix: Wallet: Soft-fail exceptions within ListWalletDir file checks
1 parent f5cdc29 commit 69f59af

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/wallet/walletutil.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,31 @@ std::vector<fs::path> ListWalletDir()
4949
continue;
5050
}
5151

52-
// Get wallet path relative to walletdir by removing walletdir from the wallet path.
53-
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
54-
const fs::path path = it->path().string().substr(offset);
52+
try {
53+
// Get wallet path relative to walletdir by removing walletdir from the wallet path.
54+
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
55+
const fs::path path = it->path().string().substr(offset);
5556

56-
if (it->status().type() == fs::directory_file &&
57-
(ExistsBerkeleyDatabase(it->path()) || ExistsSQLiteDatabase(it->path()))) {
58-
// Found a directory which contains wallet.dat btree file, add it as a wallet.
59-
paths.emplace_back(path);
60-
} else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsBerkeleyDatabase(it->path())) {
61-
if (it->path().filename() == "wallet.dat") {
62-
// Found top-level wallet.dat btree file, add top level directory ""
63-
// as a wallet.
64-
paths.emplace_back();
65-
} else {
66-
// Found top-level btree file not called wallet.dat. Current bitcoin
67-
// software will never create these files but will allow them to be
68-
// opened in a shared database environment for backwards compatibility.
69-
// Add it to the list of available wallets.
57+
if (it->status().type() == fs::directory_file &&
58+
(ExistsBerkeleyDatabase(it->path()) || ExistsSQLiteDatabase(it->path()))) {
59+
// Found a directory which contains wallet.dat btree file, add it as a wallet.
7060
paths.emplace_back(path);
61+
} else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsBerkeleyDatabase(it->path())) {
62+
if (it->path().filename() == "wallet.dat") {
63+
// Found top-level wallet.dat btree file, add top level directory ""
64+
// as a wallet.
65+
paths.emplace_back();
66+
} else {
67+
// Found top-level btree file not called wallet.dat. Current bitcoin
68+
// software will never create these files but will allow them to be
69+
// opened in a shared database environment for backwards compatibility.
70+
// Add it to the list of available wallets.
71+
paths.emplace_back(path);
72+
}
7173
}
74+
} catch (const std::exception& e) {
75+
LogPrintf("%s: Error scanning %s: %s\n", __func__, it->path().string(), e.what());
76+
it.no_push();
7277
}
7378
}
7479

0 commit comments

Comments
 (0)