Bitcoin
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
WalletBatch Class Reference

#include <walletdb.h>

Public Member Functions

 WalletBatch (WalletDatabase &database, const char *pszMode="r+", bool _fFlushOnClose=true)
 
 WalletBatch (const WalletBatch &)=delete
 
WalletBatchoperator= (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 WriteTx (const CWalletTx &wtx)
 
bool EraseTx (uint256 hash)
 
bool WriteKeyMetadata (const CKeyMetadata &meta, const CPubKey &pubkey, const 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 WriteCScript (const uint160 &hash, const CScript &redeemScript)
 
bool WriteWatchOnly (const CScript &script, const CKeyMetadata &keymeta)
 
bool EraseWatchOnly (const CScript &script)
 
bool WriteBestBlock (const CBlockLocator &locator)
 
bool ReadBestBlock (CBlockLocator &locator)
 
bool WriteOrderPosNext (int64_t nOrderPosNext)
 
bool ReadPool (int64_t nPool, CKeyPool &keypool)
 
bool WritePool (int64_t nPool, const CKeyPool &keypool)
 
bool ErasePool (int64_t nPool)
 
bool WriteMinVersion (int nVersion)
 
bool WriteDestData (const std::string &address, const std::string &key, const std::string &value)
 Write destination data key,value tuple to database. More...
 
bool EraseDestData (const std::string &address, const std::string &key)
 Erase destination data tuple from wallet database. More...
 
DBErrors LoadWallet (CWallet *pwallet)
 
DBErrors FindWalletTx (std::vector< uint256 > &vTxHash, std::vector< CWalletTx > &vWtx)
 
DBErrors ZapWalletTx (std::vector< CWalletTx > &vWtx)
 
DBErrors ZapSelectTx (std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
 
bool WriteHDChain (const CHDChain &chain)
 write the hdchain model (external chain child index counter) More...
 
bool WriteWalletFlags (const uint64_t flags)
 
bool TxnBegin ()
 Begin a new transaction. More...
 
bool TxnCommit ()
 Commit current transaction. More...
 
bool TxnAbort ()
 Abort current transaction. More...
 
bool ReadVersion (int &nVersion)
 Read wallet version. More...
 
bool WriteVersion (int nVersion)
 Write wallet version. More...
 

Static Public Member Functions

static bool Recover (const fs::path &wallet_path, void *callbackDataIn, bool(*recoverKVcallback)(void *callbackData, CDataStream ssKey, CDataStream ssValue), std::string &out_backup_filename)
 
static bool Recover (const fs::path &wallet_path, std::string &out_backup_filename)
 
static bool RecoverKeysOnlyFilter (void *callbackData, CDataStream ssKey, CDataStream ssValue)
 
static bool IsKeyType (const std::string &strType)
 
static bool VerifyEnvironment (const fs::path &wallet_path, std::string &errorStr)
 
static bool VerifyDatabaseFile (const fs::path &wallet_path, std::string &warningStr, std::string &errorStr)
 

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

BerkeleyBatch m_batch
 
WalletDatabasem_database
 

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.

Constructor & Destructor Documentation

◆ WalletBatch() [1/2]

WalletBatch::WalletBatch ( WalletDatabase database,
const char *  pszMode = "r+",
bool  _fFlushOnClose = true 
)
inlineexplicit

◆ WalletBatch() [2/2]

WalletBatch::WalletBatch ( const WalletBatch )
delete

Member Function Documentation

◆ EraseDestData()

bool WalletBatch::EraseDestData ( const std::string &  address,
const std::string &  key 
)

Erase destination data tuple from wallet database.

◆ EraseIC()

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

◆ EraseName()

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

◆ ErasePool()

bool WalletBatch::ErasePool ( int64_t  nPool)

◆ ErasePurpose()

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

◆ EraseTx()

bool WalletBatch::EraseTx ( uint256  hash)

◆ EraseWatchOnly()

bool WalletBatch::EraseWatchOnly ( const CScript script)

◆ FindWalletTx()

DBErrors WalletBatch::FindWalletTx ( std::vector< uint256 > &  vTxHash,
std::vector< CWalletTx > &  vWtx 
)

◆ IsKeyType()

bool WalletBatch::IsKeyType ( const std::string &  strType)
static

◆ LoadWallet()

DBErrors WalletBatch::LoadWallet ( CWallet pwallet)

◆ operator=()

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

◆ ReadBestBlock()

bool WalletBatch::ReadBestBlock ( CBlockLocator locator)

◆ ReadPool()

bool WalletBatch::ReadPool ( int64_t  nPool,
CKeyPool keypool 
)

◆ ReadVersion()

bool WalletBatch::ReadVersion ( int &  nVersion)

Read wallet version.

◆ Recover() [1/2]

bool WalletBatch::Recover ( const fs::path &  wallet_path,
void *  callbackDataIn,
bool(*)(void *callbackData, CDataStream ssKey, CDataStream ssValue)  recoverKVcallback,
std::string &  out_backup_filename 
)
static

◆ Recover() [2/2]

bool WalletBatch::Recover ( const fs::path &  wallet_path,
std::string &  out_backup_filename 
)
static

◆ RecoverKeysOnlyFilter()

bool WalletBatch::RecoverKeysOnlyFilter ( void *  callbackData,
CDataStream  ssKey,
CDataStream  ssValue 
)
static

◆ TxnAbort()

bool WalletBatch::TxnAbort ( )

Abort current transaction.

◆ TxnBegin()

bool WalletBatch::TxnBegin ( )

Begin a new transaction.

◆ TxnCommit()

bool WalletBatch::TxnCommit ( )

Commit current transaction.

◆ VerifyDatabaseFile()

bool WalletBatch::VerifyDatabaseFile ( const fs::path &  wallet_path,
std::string &  warningStr,
std::string &  errorStr 
)
static

◆ VerifyEnvironment()

bool WalletBatch::VerifyEnvironment ( const fs::path &  wallet_path,
std::string &  errorStr 
)
static

◆ WriteBestBlock()

bool WalletBatch::WriteBestBlock ( const CBlockLocator locator)

◆ WriteCryptedKey()

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

◆ WriteCScript()

bool WalletBatch::WriteCScript ( const uint160 hash,
const CScript redeemScript 
)

◆ WriteDestData()

bool WalletBatch::WriteDestData ( const std::string &  address,
const std::string &  key,
const std::string &  value 
)

Write destination data key,value tuple to database.

◆ WriteHDChain()

bool WalletBatch::WriteHDChain ( const CHDChain chain)

write the hdchain model (external chain child index counter)

◆ WriteIC()

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

◆ WriteKey()

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

◆ WriteKeyMetadata()

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

◆ WriteMasterKey()

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

◆ WriteMinVersion()

bool WalletBatch::WriteMinVersion ( int  nVersion)

◆ WriteName()

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

◆ WriteOrderPosNext()

bool WalletBatch::WriteOrderPosNext ( int64_t  nOrderPosNext)

◆ WritePool()

bool WalletBatch::WritePool ( int64_t  nPool,
const CKeyPool keypool 
)

◆ WritePurpose()

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

◆ WriteTx()

bool WalletBatch::WriteTx ( const CWalletTx wtx)

◆ WriteVersion()

bool WalletBatch::WriteVersion ( int  nVersion)

Write wallet version.

◆ WriteWalletFlags()

bool WalletBatch::WriteWalletFlags ( const uint64_t  flags)

◆ WriteWatchOnly()

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

◆ ZapSelectTx()

DBErrors WalletBatch::ZapSelectTx ( std::vector< uint256 > &  vHashIn,
std::vector< uint256 > &  vHashOut 
)

◆ ZapWalletTx()

DBErrors WalletBatch::ZapWalletTx ( std::vector< CWalletTx > &  vWtx)

Member Data Documentation

◆ m_batch

BerkeleyBatch WalletBatch::m_batch
private

◆ m_database

WalletDatabase& WalletBatch::m_database
private

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