diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -309,4 +309,15 @@ /** Return whether a wallet database is currently loaded. */ bool IsWalletLoaded(const fs::path &wallet_path); +/** Return object for accessing database at specified path. */ +std::unique_ptr CreateWalletDatabase(const fs::path &path); + +/** + * Return object for accessing dummy database with no read/write capabilities. + */ +std::unique_ptr CreateDummyWalletDatabase(); + +/** Return object for accessing temporary in-memory database. */ +std::unique_ptr CreateMockWalletDatabase(); + #endif // BITCOIN_WALLET_WALLETDB_H diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1128,3 +1128,23 @@ bool IsWalletLoaded(const fs::path &wallet_path) { return IsBDBWalletLoaded(wallet_path); } + +/** Return object for accessing database at specified path. */ +std::unique_ptr CreateWalletDatabase(const fs::path &path) { + std::string filename; + return std::make_unique(GetWalletEnv(path, filename), + std::move(filename)); +} + +/** + * Return object for accessing dummy database with no read/write capabilities. + */ +std::unique_ptr CreateDummyWalletDatabase() { + return std::make_unique(); +} + +/** Return object for accessing temporary in-memory database. */ +std::unique_ptr CreateMockWalletDatabase() { + return std::make_unique( + std::make_shared(), ""); +}