6#ifndef BITCOIN_WALLET_WALLETDB_H 
    7#define BITCOIN_WALLET_WALLETDB_H 
   55extern const std::string 
ACENTRY;
 
   61extern const std::string 
CSCRIPT;
 
   64extern const std::string 
FLAGS;
 
   65extern const std::string 
HDCHAIN;
 
   66extern const std::string 
KEY;
 
   67extern 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;
 
   83extern const std::string 
WATCHS;
 
  103        READWRITE(obj.nVersion, obj.nExternalChainCounter, obj.seed_id);
 
  149        READWRITE(obj.nVersion, obj.nCreateTime);
 
  151            READWRITE(obj.hdKeypath, obj.hd_seed_id);
 
  181    template <
typename K, 
typename T>
 
  182    bool WriteIC(
const K& key, 
const T& value, 
bool fOverwrite = 
true)
 
  184        if (!
m_batch->Write(key, value, fOverwrite)) {
 
  194    template <
typename K>
 
  209        m_batch(database.MakeBatch(_fFlushOnClose)),
 
  216    bool WriteName(
const std::string& strAddress, 
const std::string& strName);
 
  217    bool EraseName(
const std::string& strAddress);
 
  219    bool WritePurpose(
const std::string& strAddress, 
const std::string& purpose);
 
  258    bool WriteDestData(
const std::string &address, 
const std::string &key, 
const std::string &value);
 
  260    bool EraseDestData(
const std::string &address, 
const std::string &key);
 
  269    static bool IsKeyType(
const std::string& strType);
 
Double ended buffer combining vector and stream-like interfaces.
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 outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
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.
Cache for single descriptor's derived extended pubkeys.
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 ErasePool(int64_t nPool)
WalletBatch(const WalletBatch &)=delete
bool WriteName(const std::string &strAddress, const std::string &strName)
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 std::string &strAddress)
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool EraseLockedUTXO(const COutPoint &output)
bool EraseWatchOnly(const CScript &script)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
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)
bool EraseDestData(const std::string &address, const std::string &key)
Erase destination data tuple from wallet database.
std::unique_ptr< DatabaseBatch > m_batch
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
bool ReadBestBlock(CBlockLocator &locator)
bool WriteDescriptorCacheItems(const uint256 &desc_id, const DescriptorCache &cache)
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.
DBErrors FindWalletTx(std::vector< uint256 > &vTxHash, std::list< CWalletTx > &vWtx)
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
bool WritePool(int64_t nPool, const CKeyPool &keypool)
bool WriteBestBlock(const CBlockLocator &locator)
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
bool EraseTx(uint256 hash)
bool WritePurpose(const std::string &strAddress, const std::string &purpose)
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
bool EraseName(const std::string &strAddress)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteLockedUTXO(const COutPoint &output)
bool WriteDescriptorLastHardenedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
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.
#define T(expected, seed, data)
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (SIZE bytes)
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 WALLETDESCRIPTOR
const std::string VERSION
const std::string KEYMETA
const std::string LOCKED_UTXO
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
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,...
bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue, std::string &strType, std::string &strErr, const KeyFilterFn &filter_fn=nullptr)
Unserialize a given Key-Value pair and load it into the wallet.
DBErrors
Error statuses for the wallet database.
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:
void MaybeCompactWalletDB(WalletContext &context)
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
std::function< bool(const std::string &)> KeyFilterFn
Callback for filtering key types to deserialize in ReadKeyValue.
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase()
Return object for accessing temporary in-memory database.