diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 2f6c2b883ac..6f383980764 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1023,3 +1023,22 @@ 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 MakeUnique(GetWalletEnv(path, filename), std::move(filename)); +} + +/** Return object for accessing dummy database with no read/write capabilities. */ +std::unique_ptr CreateDummyWalletDatabase() +{ + return MakeUnique(); +} + +/** Return object for accessing temporary in-memory database. */ +std::unique_ptr CreateMockWalletDatabase() +{ + return MakeUnique(std::make_shared(), ""); +} diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 1037bd579fe..61e0f19e562 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -293,4 +293,13 @@ bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, st /** 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