32 wallet->SetupDescriptorScriptPubKeyMans();
38 auto& desc = descs.at(0);
40 Assert(
wallet->AddWalletDescriptor(w_desc, provider,
"",
false));
55 std::vector<bilingual_str> _warnings;
71 std::vector<bilingual_str> warnings;
80 std::vector<bilingual_str> warnings;
95 std::vector<bilingual_str> warnings;
103 wallet->chain().waitForNotificationsIfTipChanged({});
104 wallet->m_chain_notifications_handler.reset();
110 std::unique_ptr<DatabaseBatch> batch_orig = database.
MakeBatch();
111 std::unique_ptr<DatabaseCursor> cursor_orig = batch_orig->GetNewCursor();
114 std::unique_ptr<DatabaseBatch> new_db_batch = new_db->MakeBatch();
123 batch_new->
WriteKey(std::move(key), std::move(value));
146 return std::make_unique<MockableSQLiteDatabase>();
155 auto parsed_descs =
Parse(desc_str, keys, error,
false);
156 Assert(success == (!parsed_descs.empty()));
157 if (!success)
return nullptr;
158 auto& desc = parsed_descs.at(0);
160 const int64_t range_start = 0, range_end = 1, next_index = 0, timestamp = 1;
162 WalletDescriptor w_desc(std::move(desc), timestamp, range_start, range_end, next_index);
166 return &spkm.value().get();
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
#define Assert(val)
Identity function.
uint256 GetBlockHash() const
An in-memory indexed chain of blocks.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
An encapsulated private key.
Double ended buffer combining vector and stream-like interfaces.
constexpr bool IsNull() const
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...
static std::shared_ptr< CWallet > LoadExisting(WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, bilingual_str &error, std::vector< bilingual_str > &warnings)
util::Result< CTxDestination > GetNewDestination(OutputType type, const std::string &label)
RecursiveMutex cs_wallet
Main wallet lock.
static std::shared_ptr< CWallet > CreateNew(WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)
util::Result< std::reference_wrapper< DescriptorScriptPubKeyMan > > AddWalletDescriptor(WalletDescriptor &desc, const FlatSigningProvider &signing_provider, const std::string &label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type.
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
An instance of this class represents one SQLite3 database.
An instance of this class represents one database.
virtual std::unique_ptr< DatabaseBatch > MakeBatch()=0
Make a DatabaseBatch connected to this database.
Descriptor with some wallet metadata.
RAII object to check and reserve a wallet rescan.
bool reserve(bool with_passphrase=false)
static UniValue Parse(std::string_view raw, ParamFormat format=ParamFormat::JSON)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
std::string EncodeSecret(const CKey &key)
std::string EncodeDestination(const CTxDestination &dest)
wallet::DescriptorScriptPubKeyMan * CreateDescriptor(CWallet &keystore, const std::string &desc_str, const bool success)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase()
std::unique_ptr< CWallet > CreateSyncedWallet(interfaces::Chain &chain, CChain &cchain, const CKey &key)
void TestUnloadWallet(std::shared_ptr< CWallet > &&wallet)
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
void NotifyWalletLoaded(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
std::unique_ptr< WalletDatabase > DuplicateMockDatabase(WalletDatabase &database)
std::shared_ptr< CWallet > TestLoadWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context)
std::shared_ptr< CWallet > TestCreateWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context, uint64_t create_flags)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
void WaitForDeleteWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly delete the wallet.
RPCMethod getnewaddress()
CTxDestination getNewDestination(CWallet &w, OutputType output_type)
Returns a new destination, of an specific type, from the wallet.
std::optional< int > last_scanned_height
uint256 last_scanned_block
Hash and height of most recent block that was successfully scanned.
uint256 last_failed_block
Height of the most recent block that could not be scanned due to read errors or pruning.
enum wallet::CWallet::ScanResult::@18 status
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain