31 wallet->SetupDescriptorScriptPubKeyMans();
38 if (!
wallet->AddWalletDescriptor(w_desc, provider,
"",
false))
assert(
false);
53 std::vector<bilingual_str> warnings;
68 std::vector<bilingual_str> warnings;
76 wallet->m_chain_notifications_handler.reset();
82 return std::make_unique<MockableDatabase>(
dynamic_cast<MockableDatabase&
>(database).m_records);
98 bool operator<(BytePrefix a, Span<const std::byte> b) {
return a.prefix < b.
subspan(0, std::min(a.prefix.size(), b.size())); }
99 bool operator<(Span<const std::byte> a,
BytePrefix b) {
return a.subspan(0, std::min(a.size(), b.prefix.size())) < b.
prefix; }
117 const auto& [key_data, value_data] = *
m_cursor;
119 value.
write(value_data);
130 const auto& it =
m_records.find(key_data);
135 value.
write(it->second);
146 auto [it, inserted] =
m_records.emplace(key_data, value_data);
147 if (!inserted && overwrite) {
148 it->second = value_data;
180 auto& key = it->first;
181 if (key.size() <
prefix.size() || std::search(key.begin(), key.end(),
prefix.begin(),
prefix.end()) != key.begin()) {
192 return std::make_unique<MockableDatabase>(records);
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
Status Next(DataStream &key, DataStream &value) override
enum wallet::CWallet::ScanResult::@17 status
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
CONSTEXPR_IF_NOT_DEBUG Span< C > subspan(std::size_t offset) const noexcept
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
bool ErasePrefix(Span< const std::byte > prefix) override
std::optional< int > last_scanned_height
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
An in-memory indexed chain of blocks.
std::map< SerializeData, SerializeData, std::less<> > MockableData
int Height() const
Return the maximal height in the chain.
MockableCursor(const MockableData &records, bool pass)
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or nullptr if none.
MockableData::const_iterator m_cursor
RAII object to check and reserve a wallet rescan.
bool reserve(bool with_passphrase=false)
CTxDestination getNewDestination(CWallet &w, OutputType output_type)
Returns a new destination, of an specific type, from the wallet.
void write(Span< const value_type > src)
std::unique_ptr< WalletDatabase > DuplicateMockDatabase(WalletDatabase &database)
MockableData::const_iterator m_cursor_end
std::shared_ptr< CWallet > TestLoadWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context, uint64_t create_flags)
uint256 GetBlockHash() const
Double ended buffer combining vector and stream-like interfaces.
std::vector< std::byte, zero_after_free_allocator< std::byte > > SerializeData
Byte-vector that clears its contents before deletion.
bool EraseKey(DataStream &&key) override
void NotifyWalletLoaded(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
Indicate that this wallet supports DescriptorScriptPubKeyMan.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
MockableDatabase & GetMockableDatabase(CWallet &wallet)
constexpr bool IsNull() const
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Descriptor with some wallet metadata.
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
std::unique_ptr< CWallet > CreateSyncedWallet(interfaces::Chain &chain, CChain &cchain, const CKey &key)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
A WalletDatabase whose contents and return values can be modified as needed for testing.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
bool error(const char *fmt, const Args &... args)
void TestUnloadWallet(std::shared_ptr< CWallet > &&wallet)
bool ReadKey(DataStream &&key, DataStream &value) override
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
interfaces::Chain * chain
std::string EncodeDestination(const CTxDestination &dest)
Span< const std::byte > prefix
An encapsulated private key.
std::shared_ptr< CWallet > wallet
bool HasKey(DataStream &&key) override
RPCHelpMan getnewaddress()
util::Result< CTxDestination > GetNewDestination(const OutputType type, const std::string label)
std::string EncodeSecret(const CKey &key)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
An instance of this class represents one database.
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
#define Assert(val)
Identity function.
static std::shared_ptr< CWallet > Create(WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)