7#ifndef BITCOIN_WALLET_WALLETDB_H
8#define BITCOIN_WALLET_WALLETDB_H
56extern const std::string
ACENTRY;
62extern const std::string
CSCRIPT;
65extern const std::string
FLAGS;
66extern const std::string
HDCHAIN;
67extern const std::string
KEY;
68extern const std::string
KEYMETA;
71extern const std::string
NAME;
72extern const std::string
OLD_KEY;
74extern const std::string
POOL;
75extern const std::string
PURPOSE;
77extern const std::string
TX;
78extern const std::string
VERSION;
84extern const std::string
WATCHS;
103 READWRITE(obj.nVersion, obj.nExternalChainCounter, obj.seed_id);
147 READWRITE(obj.nVersion, obj.nCreateTime);
149 READWRITE(obj.hdKeypath, obj.hd_seed_id);
178 template <
typename K,
typename T>
179 bool WriteIC(
const K &key,
const T &value,
bool fOverwrite =
true) {
180 if (!
m_batch->Write(key, value, fOverwrite)) {
190 template <
typename K>
bool EraseIC(
const K &key) {
211 const std::string &purpose);
218 const bool overwrite);
222 const std::vector<uint8_t> &vchCryptedSecret,
246 const std::vector<uint8_t> &secret);
251 uint32_t key_exp_index,
255 uint32_t key_exp_index);
259 const std::string &value);
270 std::vector<TxId> &txIdsOut);
273 static bool IsKeyType(
const std::string &strType);
300 std::string &strType, std::string &strErr,
const CScript redeemScript
static const int VERSION_HD_BASE
SERIALIZE_METHODS(CHDChain, obj)
uint32_t nInternalChainCounter
bool operator==(const CHDChain &chain) const
CKeyID seed_id
seed hash160
static const int VERSION_HD_CHAIN_SPLIT
static const int CURRENT_VERSION
uint32_t nExternalChainCounter
A reference to a CKey: the Hash160 of its serialized public key.
A key from a CWallet's keypool.
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key.
An encapsulated public key.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
A transaction with a bunch of additional info that only the owner cares about.
Double ended buffer combining vector and stream-like interfaces.
Access to the wallet database.
bool TxnCommit()
Commit current transaction.
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
bool WriteName(const CTxDestination &address, const std::string &strName)
bool ErasePool(int64_t nPool)
WalletBatch(const WalletBatch &)=delete
bool WritePurpose(const CTxDestination &address, const std::string &purpose)
bool WriteMinVersion(int nVersion)
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
static bool IsKeyType(const std::string &strType)
bool ErasePurpose(const CTxDestination &address)
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool EraseWatchOnly(const CScript &script)
bool EraseDestData(const CTxDestination &address, const std::string &key)
Erase destination data tuple from wallet database.
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
bool ReadPool(int64_t nPool, CKeyPool &keypool)
bool WriteWalletFlags(const uint64_t flags)
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
std::unique_ptr< DatabaseBatch > m_batch
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
bool ReadBestBlock(CBlockLocator &locator)
DBErrors FindWalletTx(std::vector< TxId > &txIds, std::list< CWalletTx > &vWtx)
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
bool WriteOrderPosNext(int64_t nOrderPosNext)
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
bool WriteTx(const CWalletTx &wtx)
bool EraseIC(const K &key)
bool TxnBegin()
Begin a new transaction.
bool TxnAbort()
Abort current transaction.
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
bool EraseName(const CTxDestination &address)
bool WritePool(int64_t nPool, const CKeyPool &keypool)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool WriteBestBlock(const CBlockLocator &locator)
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< uint8_t > &secret)
bool EraseTx(uint256 hash)
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteDestData(const CTxDestination &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
WalletBatch(WalletDatabase &database, bool _fFlushOnClose=true)
WalletBatch & operator=(const WalletBatch &)=delete
WalletDatabase & m_database
An instance of this class represents one database.
std::atomic< unsigned int > nUpdateCounter
virtual void IncrementUpdateCounter()=0
Descriptor with some wallet metadata.
std::vector< uint8_t, secure_allocator< uint8_t > > CPrivKey
secure_allocator is defined in allocators.h CPrivKey is a serialized private key, with all parameters...
const std::string ORDERPOSNEXT
const std::string DEFAULTKEY
const std::string CSCRIPT
const std::string BESTBLOCK_NOMERKLE
const std::string DESTDATA
const std::string WALLETDESCRIPTORKEY
const std::string SETTINGS
const std::string WALLETDESCRIPTORCKEY
const std::string ACTIVEEXTERNALSPK
const std::string MINVERSION
const std::string HDCHAIN
const std::string WALLETDESCRIPTORCACHE
const std::string WALLETDESCRIPTOR
const std::string VERSION
const std::string KEYMETA
const std::string WATCHMETA
const std::string ACENTRY
const std::string MASTER_KEY
const std::string ACTIVEINTERNALSPK
const std::string PURPOSE
const std::string OLD_KEY
const std::string CRYPTED_KEY
const std::string BESTBLOCK
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
WalletContext struct containing references to state shared between CWallet instances,...
DBErrors
Error statuses for the wallet database.
std::function< bool(const std::string &)> KeyFilterFn
Callback for filtering key types to deserialize in ReadKeyValue.
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
bool ReadKeyValue(CWallet *pwallet, DataStream &ssKey, DataStream &ssValue, std::string &strType, std::string &strErr, const KeyFilterFn &filter_fn=nullptr)
Unserialize a given Key-Value pair and load it into the wallet.
void MaybeCompactWalletDB(WalletContext &context)
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase()
Return object for accessing temporary in-memory database.