5#ifndef BITCOIN_WALLET_TEST_UTIL_H
6#define BITCOIN_WALLET_TEST_UTIL_H
47using MockableData = std::map<SerializeData, SerializeData, std::less<>>;
108 bool Backup(
const std::string& strDest)
const override {
return m_pass; }
111 std::string
Filename()
override {
return "mockable"; }
112 std::string
Format()
override {
return "mock"; }
119ScriptPubKeyMan*
CreateDescriptor(CWallet& keystore,
const std::string& desc_str,
const bool success);
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
An in-memory indexed chain of blocks.
An encapsulated private key.
Double ended buffer combining vector and stream-like interfaces.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
RAII class that provides access to a WalletDatabase.
bool ReadKey(DataStream &&key, DataStream &value) override
std::unique_ptr< DatabaseCursor > GetNewCursor() override
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(std::span< const std::byte > prefix) override
bool HasActiveTxn() override
bool EraseKey(DataStream &&key) override
bool TxnCommit() override
bool ErasePrefix(std::span< const std::byte > prefix) override
bool HasKey(DataStream &&key) override
MockableBatch(MockableData &records, bool pass)
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
MockableCursor(const MockableData &records, bool pass)
MockableData::const_iterator m_cursor_end
MockableData::const_iterator m_cursor
Status Next(DataStream &key, DataStream &value) override
~MockableCursor()=default
A WalletDatabase whose contents and return values can be modified as needed for testing.
MockableDatabase(MockableData records={})
void Open() override
Open the database if it is not already opened.
bool Rewrite(const char *pszSkip=nullptr) override
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
bool Backup(const std::string &strDest) const override
Back up the entire database to a file.
void Close() override
Flush to the database file and close the database.
std::string Format() override
std::unique_ptr< DatabaseBatch > MakeBatch() override
Make a DatabaseBatch connected to this database.
std::string Filename() override
Return path to main database file for logs and error messages.
~MockableDatabase()=default
An instance of this class represents one database.
WalletDatabase()=default
Create dummy DB handle.
const std::string ADDRESS_BCRT1_UNSPENDABLE
std::shared_ptr< CWallet > TestLoadWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context, uint64_t create_flags)
static const DatabaseFormat DATABASE_FORMATS[]
std::unique_ptr< CWallet > CreateSyncedWallet(interfaces::Chain &chain, CChain &cchain, const CKey &key)
void TestUnloadWallet(std::shared_ptr< CWallet > &&wallet)
MockableDatabase & GetMockableDatabase(CWallet &wallet)
wallet::ScriptPubKeyMan * CreateDescriptor(CWallet &keystore, const std::string &desc_str, const bool success)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
std::unique_ptr< WalletDatabase > DuplicateMockDatabase(WalletDatabase &database)
RPCHelpMan getnewaddress()
std::map< SerializeData, SerializeData, std::less<> > MockableData
CTxDestination getNewDestination(CWallet &w, OutputType output_type)
Returns a new destination, of an specific type, from the wallet.
WalletContext struct containing references to state shared between CWallet instances,...