diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 85aeaeb3ab4..e8b8b8abc12 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -10,8 +10,6 @@ #include -fs::path GetWalletDir(); - #ifdef USE_BDB bool ExistsBerkeleyDatabase(const fs::path& path); #else @@ -23,9 +21,8 @@ bool ExistsSQLiteDatabase(const fs::path& path); # define ExistsSQLiteDatabase(path) (false) #endif -std::vector ListWalletDir() +std::vector ListDatabases(const fs::path& wallet_dir) { - const fs::path wallet_dir = GetWalletDir(); const size_t offset = wallet_dir.string().size() + 1; std::vector paths; boost::system::error_code ec; diff --git a/src/wallet/db.h b/src/wallet/db.h index cc13f887b06..3d18e5cec0e 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -223,6 +223,9 @@ enum class DatabaseStatus { FAILED_ENCRYPT, }; +/** Recursively list database paths in directory. */ +std::vector ListDatabases(const fs::path& path); + std::unique_ptr MakeDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error); bool IsBDBFile(const fs::path& path); diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 3fbba9ab921..46ef6eee3ec 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -551,7 +551,7 @@ public: std::vector listWalletDir() override { std::vector paths; - for (auto& path : ListWalletDir()) { + for (auto& path : ListDatabases(GetWalletDir())) { paths.push_back(path.string()); } return paths; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7ea6a214b24..3802bb452a2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2537,7 +2537,7 @@ static RPCHelpMan listwalletdir() [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { UniValue wallets(UniValue::VARR); - for (const auto& path : ListWalletDir()) { + for (const auto& path : ListDatabases(GetWalletDir())) { UniValue wallet(UniValue::VOBJ); wallet.pushKV("name", path.string()); wallets.push_back(wallet); diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index 27521abd81c..d4143ceff47 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -65,9 +65,6 @@ enum WalletFlags : uint64_t { //! Get the path of the wallet directory. fs::path GetWalletDir(); -//! Get wallets in wallet directory. -std::vector ListWalletDir(); - /** Descriptor with some wallet metadata */ class WalletDescriptor {