Bitcoin Core 32.99.0
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
wallet::WalletBatch Class Reference

Access to the wallet database. More...

#include <walletdb.h>

Public Member Functions

 WalletBatch (WalletDatabase &database)
 
 WalletBatch (const WalletBatch &)=delete
 
WalletBatch & operator= (const WalletBatch &)=delete
 
bool WriteName (const std::string &strAddress, const std::string &strName)
 
bool EraseName (const std::string &strAddress)
 
bool WritePurpose (const std::string &strAddress, const std::string &purpose)
 
bool ErasePurpose (const std::string &strAddress)
 
bool WriteFullTx (const CWalletTx &wtx)
 
bool EraseTx (Txid hash)
 
bool WriteWtxVariant (const Txid &txid, const CTransactionRef &tx)
 
bool WriteTxMetadata (const CWalletTx &wtx)
 
bool WriteKeyMetadata (const CKeyMetadata &meta, const CPubKey &pubkey, bool overwrite)
 
bool WriteKey (const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
 
bool WriteCryptedKey (const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
 
bool WriteMasterKey (unsigned int nID, const CMasterKey &kMasterKey)
 
bool EraseMasterKey (unsigned int id)
 
bool WriteWatchOnly (const CScript &script, const CKeyMetadata &keymeta)
 
bool WriteBestBlock (const CBlockLocator &locator)
 
bool ReadBestBlock (CBlockLocator &locator)
 
bool IsEncrypted ()
 
bool WriteOrderPosNext (int64_t nOrderPosNext)
 
bool WriteDescriptorKey (const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
 
bool WriteCryptedDescriptorKey (const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
 
bool WriteDescriptor (const uint256 &desc_id, const WalletDescriptor &descriptor)
 
bool WriteDescriptorDerivedCache (const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
 
bool WriteDescriptorParentCache (const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
 
bool WriteDescriptorLastHardenedCache (const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
 
bool WriteDescriptorCacheItems (const uint256 &desc_id, const DescriptorCache &cache)
 
bool WriteLockedUTXO (const COutPoint &output)
 
bool EraseLockedUTXO (const COutPoint &output)
 
bool WriteAddressPreviouslySpent (const CTxDestination &dest, bool previously_spent)
 
bool WriteAddressReceiveRequest (const CTxDestination &dest, const std::string &id, const std::string &receive_request)
 
bool EraseAddressReceiveRequest (const CTxDestination &dest, const std::string &id)
 
bool EraseAddressData (const CTxDestination &dest)
 
bool WriteActiveScriptPubKeyMan (uint8_t type, const uint256 &id, bool internal)
 
bool EraseActiveScriptPubKeyMan (uint8_t type, bool internal)
 
DBErrors LoadWallet (CWallet *pwallet)
 
bool WriteLastOpenedVersion ()
 Write the current client version in the VERSION record. More...
 
bool WriteLastOpenedFeatures ()
 Write the current client features in the LAST_OPENED_FEATURES record. More...
 
bool WriteLastDecryptedFeatures ()
 Write the current wallet client features to the LAST_DECRYPTED_FEATURES record. More...
 
bool EraseRecords (const std::unordered_set< std::string > &types)
 Delete records of the given types. More...
 
bool WriteWalletFlags (uint64_t flags)
 
bool TxnBegin ()
 Begin a new transaction. More...
 
bool TxnCommit ()
 Commit current transaction. More...
 
bool TxnAbort ()
 Abort current transaction. More...
 
bool HasActiveTxn ()
 
void RegisterTxnListener (DbTxnListener l)
 Registers db txn callback functions. More...
 

Private Member Functions

template<typename K , typename T >
bool WriteIC (const K &key, const T &value, bool fOverwrite=true)
 
template<typename K >
bool EraseIC (const K &key)
 

Private Attributes

std::unique_ptr< DatabaseBatch > m_batch
 
std::vector< DbTxnListener > m_txn_listeners
 

Detailed Description

Access to the wallet database.

Opens the database and provides read and write access to it. Each read and write is its own transaction. Multiple operation transactions can be started using TxnBegin() and committed using TxnCommit() Otherwise the transaction will be committed when the object goes out of scope. Optionally (on by default) it will flush to disk on close. Every 1000 writes will automatically trigger a flush to disk.

Definition at line 198 of file walletdb.h.

Constructor & Destructor Documentation

◆ WalletBatch() [1/2]

wallet::WalletBatch::WalletBatch ( WalletDatabase &  database)
inlineexplicit

Definition at line 220 of file walletdb.h.

◆ WalletBatch() [2/2]

wallet::WalletBatch::WalletBatch ( const WalletBatch &  )
delete

Member Function Documentation

◆ EraseActiveScriptPubKeyMan()

bool wallet::WalletBatch::EraseActiveScriptPubKeyMan ( uint8_t  type,
bool  internal 
)

Definition at line 223 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EraseAddressData()

bool wallet::WalletBatch::EraseAddressData ( const CTxDestination &  dest)

Definition at line 1324 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EraseAddressReceiveRequest()

bool wallet::WalletBatch::EraseAddressReceiveRequest ( const CTxDestination &  dest,
const std::string &  id 
)

Definition at line 1319 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EraseIC()

template<typename K >
bool wallet::WalletBatch::EraseIC ( const K &  key)
inlineprivate

Definition at line 211 of file walletdb.h.

Here is the caller graph for this function:

◆ EraseLockedUTXO()

bool wallet::WalletBatch::EraseLockedUTXO ( const COutPoint &  output)

Definition at line 306 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EraseMasterKey()

bool wallet::WalletBatch::EraseMasterKey ( unsigned int  id)

Definition at line 176 of file walletdb.cpp.

Here is the call graph for this function:

◆ EraseName()

bool wallet::WalletBatch::EraseName ( const std::string &  strAddress)

Definition at line 84 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ErasePurpose()

bool wallet::WalletBatch::ErasePurpose ( const std::string &  strAddress)

Definition at line 96 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EraseRecords()

bool wallet::WalletBatch::EraseRecords ( const std::unordered_set< std::string > &  types)

Delete records of the given types.

Definition at line 1351 of file walletdb.cpp.

Here is the caller graph for this function:

◆ EraseTx()

bool wallet::WalletBatch::EraseTx ( Txid  hash)

Definition at line 111 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasActiveTxn()

bool wallet::WalletBatch::HasActiveTxn ( )
inline

Definition at line 296 of file walletdb.h.

Here is the caller graph for this function:

◆ IsEncrypted()

bool wallet::WalletBatch::IsEncrypted ( )

Definition at line 201 of file walletdb.cpp.

◆ LoadWallet()

DBErrors wallet::WalletBatch::LoadWallet ( CWallet *  pwallet)

Definition at line 1149 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

WalletBatch & wallet::WalletBatch::operator= ( const WalletBatch &  )
delete

◆ ReadBestBlock()

bool wallet::WalletBatch::ReadBestBlock ( CBlockLocator &  locator)

Definition at line 195 of file walletdb.cpp.

Here is the caller graph for this function:

◆ RegisterTxnListener()

void wallet::WalletBatch::RegisterTxnListener ( DbTxnListener  l)

Registers db txn callback functions.

Definition at line 1389 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TxnAbort()

bool wallet::WalletBatch::TxnAbort ( )

Abort current transaction.

Definition at line 1376 of file walletdb.cpp.

Here is the caller graph for this function:

◆ TxnBegin()

bool wallet::WalletBatch::TxnBegin ( )

Begin a new transaction.

Definition at line 1358 of file walletdb.cpp.

Here is the caller graph for this function:

◆ TxnCommit()

bool wallet::WalletBatch::TxnCommit ( )

Commit current transaction.

Definition at line 1363 of file walletdb.cpp.

Here is the caller graph for this function:

◆ WriteActiveScriptPubKeyMan()

bool wallet::WalletBatch::WriteActiveScriptPubKeyMan ( uint8_t  type,
const uint256 &  id,
bool  internal 
)

Definition at line 217 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteAddressPreviouslySpent()

bool wallet::WalletBatch::WriteAddressPreviouslySpent ( const CTxDestination &  dest,
bool  previously_spent 
)

Definition at line 1308 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteAddressReceiveRequest()

bool wallet::WalletBatch::WriteAddressReceiveRequest ( const CTxDestination &  dest,
const std::string &  id,
const std::string &  receive_request 
)

Definition at line 1314 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteBestBlock()

bool wallet::WalletBatch::WriteBestBlock ( const CBlockLocator &  locator)

Definition at line 189 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteCryptedDescriptorKey()

bool wallet::WalletBatch::WriteCryptedDescriptorKey ( const uint256 &  desc_id,
const CPubKey &  pubkey,
const std::vector< unsigned char > &  secret 
)

Definition at line 237 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteCryptedKey()

bool wallet::WalletBatch::WriteCryptedKey ( const CPubKey &  vchPubKey,
const std::vector< unsigned char > &  vchCryptedSecret,
const CKeyMetadata &  keyMeta 
)

Definition at line 145 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptor()

bool wallet::WalletBatch::WriteDescriptor ( const uint256 &  desc_id,
const WalletDescriptor &  descriptor 
)

Definition at line 253 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptorCacheItems()

bool wallet::WalletBatch::WriteDescriptorCacheItems ( const uint256 &  desc_id,
const DescriptorCache &  cache 
)

Definition at line 279 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptorDerivedCache()

bool wallet::WalletBatch::WriteDescriptorDerivedCache ( const CExtPubKey &  xpub,
const uint256 &  desc_id,
uint32_t  key_exp_index,
uint32_t  der_index 
)

Definition at line 258 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptorKey()

bool wallet::WalletBatch::WriteDescriptorKey ( const uint256 &  desc_id,
const CPubKey &  pubkey,
const CPrivKey &  privkey 
)

Definition at line 229 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptorLastHardenedCache()

bool wallet::WalletBatch::WriteDescriptorLastHardenedCache ( const CExtPubKey &  xpub,
const uint256 &  desc_id,
uint32_t  key_exp_index 
)

Definition at line 272 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDescriptorParentCache()

bool wallet::WalletBatch::WriteDescriptorParentCache ( const CExtPubKey &  xpub,
const uint256 &  desc_id,
uint32_t  key_exp_index 
)

Definition at line 265 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteFullTx()

bool wallet::WalletBatch::WriteFullTx ( const CWalletTx &  wtx)

Definition at line 101 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteIC()

template<typename K , typename T >
bool wallet::WalletBatch::WriteIC ( const K &  key,
const T &  value,
bool  fOverwrite = true 
)
inlineprivate

Definition at line 202 of file walletdb.h.

Here is the caller graph for this function:

◆ WriteKey()

bool wallet::WalletBatch::WriteKey ( const CPubKey &  vchPubKey,
const CPrivKey &  vchPrivKey,
const CKeyMetadata &  keyMeta 
)

Definition at line 133 of file walletdb.cpp.

Here is the call graph for this function:

◆ WriteKeyMetadata()

bool wallet::WalletBatch::WriteKeyMetadata ( const CKeyMetadata &  meta,
const CPubKey &  pubkey,
bool  overwrite 
)

Definition at line 128 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteLastDecryptedFeatures()

bool wallet::WalletBatch::WriteLastDecryptedFeatures ( )

Write the current wallet client features to the LAST_DECRYPTED_FEATURES record.

Definition at line 1346 of file walletdb.cpp.

Here is the caller graph for this function:

◆ WriteLastOpenedFeatures()

bool wallet::WalletBatch::WriteLastOpenedFeatures ( )

Write the current client features in the LAST_OPENED_FEATURES record.

Definition at line 1341 of file walletdb.cpp.

Here is the caller graph for this function:

◆ WriteLastOpenedVersion()

bool wallet::WalletBatch::WriteLastOpenedVersion ( )

Write the current client version in the VERSION record.

Definition at line 1336 of file walletdb.cpp.

Here is the caller graph for this function:

◆ WriteLockedUTXO()

bool wallet::WalletBatch::WriteLockedUTXO ( const COutPoint &  output)

Definition at line 301 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteMasterKey()

bool wallet::WalletBatch::WriteMasterKey ( unsigned int  nID,
const CMasterKey &  kMasterKey 
)

Definition at line 171 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteName()

bool wallet::WalletBatch::WriteName ( const std::string &  strAddress,
const std::string &  strName 
)

Definition at line 79 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteOrderPosNext()

bool wallet::WalletBatch::WriteOrderPosNext ( int64_t  nOrderPosNext)

Definition at line 212 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WritePurpose()

bool wallet::WalletBatch::WritePurpose ( const std::string &  strAddress,
const std::string &  purpose 
)

Definition at line 91 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteTxMetadata()

bool wallet::WalletBatch::WriteTxMetadata ( const CWalletTx &  wtx)

Definition at line 123 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteWalletFlags()

bool wallet::WalletBatch::WriteWalletFlags ( uint64_t  flags)

Definition at line 1331 of file walletdb.cpp.

Here is the caller graph for this function:

◆ WriteWatchOnly()

bool wallet::WalletBatch::WriteWatchOnly ( const CScript &  script,
const CKeyMetadata &  keymeta 
)

Definition at line 181 of file walletdb.cpp.

Here is the call graph for this function:

◆ WriteWtxVariant()

bool wallet::WalletBatch::WriteWtxVariant ( const Txid &  txid,
const CTransactionRef &  tx 
)

Definition at line 118 of file walletdb.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_batch

std::unique_ptr<DatabaseBatch> wallet::WalletBatch::m_batch
private

Definition at line 302 of file walletdb.h.

◆ m_txn_listeners

std::vector<DbTxnListener> wallet::WalletBatch::m_txn_listeners
private

Definition at line 306 of file walletdb.h.


The documentation for this class was generated from the following files: