Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Access to the wallet database. More...
#include <walletdb.h>
Public Member Functions | |
WalletBatch (WalletDatabase &database, const char *pszMode="r+", bool _fFlushOnClose=true) | |
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 | WriteTx (const CWalletTx &wtx) |
bool | EraseTx (uint256 hash) |
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 | WriteAccountingEntry (const uint64_t nAccEntryNum, const CAccountingEntry &acentry) |
This writes directly to the database, and will not update the CWallet's cached accounting entries! Use wallet.AddAccountingEntry instead, to write and update its caches. More... | |
bool | ReadAccount (const std::string &strAccount, CAccount &account) |
bool | WriteAccount (const std::string &strAccount, const CAccount &account) |
bool | ReadPrivateSendSalt (uint256 &salt) |
bool | WritePrivateSendSalt (const uint256 &salt) |
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... | |
CAmount | GetAccountCreditDebit (const std::string &strAccount) |
void | ListAccountCreditDebit (const std::string &strAccount, std::list< CAccountingEntry > &acentries) |
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 | WriteCryptedHDChain (const CHDChain &chain) |
bool | WriteHDPubKey (const CHDPubKey &hdPubKey, const CKeyMetadata &keyMeta) |
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 |
WalletDatabase & | m_database |
Detailed Description
Access to the wallet database.
This represents a single transaction at the database. It will be committed when the object goes out of scope. Optionally (on by default) it will flush to disk as well.
Definition at line 96 of file walletdb.h.
Constructor & Destructor Documentation
◆ WalletBatch() [1/2]
|
inlineexplicit |
Definition at line 120 of file walletdb.h.
◆ WalletBatch() [2/2]
|
delete |
Member Function Documentation
◆ EraseDestData()
bool WalletBatch::EraseDestData | ( | const std::string & | address, |
const std::string & | key | ||
) |
Erase destination data tuple from wallet database.
Definition at line 872 of file walletdb.cpp.
References EraseIC().
Referenced by CWallet::DelAddressBook(), and CWallet::EraseDestData().
◆ EraseIC()
|
inlineprivate |
Definition at line 110 of file walletdb.h.
References BerkeleyBatch::Erase(), BerkeleyDatabase::IncrementUpdateCounter(), m_batch, and m_database.
Referenced by EraseDestData(), EraseName(), ErasePool(), ErasePurpose(), EraseTx(), EraseWatchOnly(), WriteCryptedHDChain(), and WriteCryptedKey().
◆ EraseName()
bool WalletBatch::EraseName | ( | const std::string & | strAddress | ) |
Definition at line 34 of file walletdb.cpp.
References EraseIC().
Referenced by CWallet::DelAddressBook().
◆ ErasePool()
bool WalletBatch::ErasePool | ( | int64_t | nPool | ) |
Definition at line 145 of file walletdb.cpp.
References EraseIC().
Referenced by CWallet::KeepKey(), CWallet::MarkReserveKeysAsUsed(), and CWallet::NewKeyPool().
◆ ErasePurpose()
bool WalletBatch::ErasePurpose | ( | const std::string & | strAddress | ) |
Definition at line 46 of file walletdb.cpp.
References EraseIC().
Referenced by CWallet::DelAddressBook().
◆ EraseTx()
bool WalletBatch::EraseTx | ( | uint256 | hash | ) |
Definition at line 56 of file walletdb.cpp.
References EraseIC().
Referenced by ZapSelectTx(), and ZapWalletTx().
◆ EraseWatchOnly()
bool WalletBatch::EraseWatchOnly | ( | const CScript & | script | ) |
Definition at line 110 of file walletdb.cpp.
References EraseIC().
Referenced by CWallet::RemoveWatchOnly().
◆ FindWalletTx()
DBErrors WalletBatch::FindWalletTx | ( | std::vector< uint256 > & | vTxHash, |
std::vector< CWalletTx > & | vWtx | ||
) |
Definition at line 675 of file walletdb.cpp.
References CLIENT_VERSION, DB_CORRUPT, DB_LOAD_OK, DB_TOO_NEW, BerkeleyBatch::GetCursor(), LogPrintf, m_batch, BerkeleyBatch::Read(), BerkeleyBatch::ReadAtCursor(), and SER_DISK.
Referenced by ZapSelectTx(), and ZapWalletTx().
◆ GetAccountCreditDebit()
CAmount WalletBatch::GetAccountCreditDebit | ( | const std::string & | strAccount | ) |
Definition at line 181 of file walletdb.cpp.
References ListAccountCreditDebit().
Referenced by CWallet::GetLegacyBalance().
◆ IsKeyType()
|
static |
Definition at line 557 of file walletdb.cpp.
Referenced by LoadWallet(), and RecoverKeysOnlyFilter().
◆ ListAccountCreditDebit()
void WalletBatch::ListAccountCreditDebit | ( | const std::string & | strAccount, |
std::list< CAccountingEntry > & | acentries | ||
) |
Definition at line 193 of file walletdb.cpp.
References CLIENT_VERSION, BerkeleyBatch::GetCursor(), m_batch, BerkeleyBatch::ReadAtCursor(), SER_DISK, and CAccountingEntry::strAccount.
Referenced by GetAccountCreditDebit(), CWallet::ListAccountCreditDebit(), LoadWallet(), and CWallet::ReorderTransactions().
◆ LoadWallet()
Definition at line 564 of file walletdb.cpp.
References CLIENT_VERSION, cs_main, CWallet::cs_wallet, DB_CORRUPT, DB_LOAD_OK, DB_NEED_REWRITE, DB_NONCRITICAL_ERROR, DB_TOO_NEW, CWalletScanState::fAnyUnordered, CWalletScanState::fIsEncrypted, gArgs, BerkeleyBatch::GetCursor(), IsKeyType(), CWallet::KeypoolCountExternalKeys(), CWallet::laccentries, ListAccountCreditDebit(), CWallet::LoadMinVersion(), LOCK2, LogPrintf, m_batch, CWallet::mapWallet, CWalletScanState::nCKeys, CWalletScanState::nFileVersion, CWalletScanState::nHDPubKeys, CWalletScanState::nKeyMeta, CWalletScanState::nKeys, CWallet::nKeysLeftSinceAutoBackup, CAccountingEntry::nOrderPos, CWalletScanState::nWatchKeys, BerkeleyBatch::Read(), BerkeleyBatch::ReadAtCursor(), ReadKeyValue(), CWallet::ReorderTransactions(), SER_DISK, ArgsManager::SoftSetBoolArg(), CWallet::UpdateTimeFirstKey(), CWalletScanState::vWalletUpgrade, WriteTx(), WriteVersion(), and CWallet::wtxOrdered.
Referenced by CWallet::LoadWallet().
◆ operator=()
|
delete |
◆ ReadAccount()
bool WalletBatch::ReadAccount | ( | const std::string & | strAccount, |
CAccount & | account | ||
) |
Definition at line 155 of file walletdb.cpp.
References m_batch, BerkeleyBatch::Read(), and CAccount::SetNull().
Referenced by CWallet::GetAccountDestination().
◆ ReadBestBlock()
bool WalletBatch::ReadBestBlock | ( | CBlockLocator & | locator | ) |
Definition at line 124 of file walletdb.cpp.
References m_batch, BerkeleyBatch::Read(), and CBlockLocator::vHave.
Referenced by CWallet::CreateWalletFromFile().
◆ ReadPool()
bool WalletBatch::ReadPool | ( | int64_t | nPool, |
CKeyPool & | keypool | ||
) |
Definition at line 135 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::Read().
Referenced by GetOldestKeyInPool(), CWallet::MarkReserveKeysAsUsed(), and CWallet::ReserveKeyFromKeyPool().
◆ ReadPrivateSendSalt()
bool WalletBatch::ReadPrivateSendSalt | ( | uint256 & | salt | ) |
Definition at line 171 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::Read().
◆ ReadVersion()
bool WalletBatch::ReadVersion | ( | int & | nVersion | ) |
Read wallet version.
Definition at line 915 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::ReadVersion().
◆ Recover() [1/2]
|
static |
Definition at line 822 of file walletdb.cpp.
References BerkeleyBatch::Recover().
Referenced by Recover(), CWallet::Verify(), and VerifyDatabaseFile().
◆ Recover() [2/2]
|
static |
Definition at line 827 of file walletdb.cpp.
References Recover().
◆ RecoverKeysOnlyFilter()
|
static |
Definition at line 834 of file walletdb.cpp.
References CWallet::cs_wallet, IsKeyType(), LOCK, LogPrintf, and ReadKeyValue().
Referenced by CWallet::Verify().
◆ TxnAbort()
bool WalletBatch::TxnAbort | ( | ) |
Abort current transaction.
Definition at line 910 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::TxnAbort().
Referenced by CWallet::EncryptWallet().
◆ TxnBegin()
bool WalletBatch::TxnBegin | ( | ) |
Begin a new transaction.
Definition at line 900 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::TxnBegin().
Referenced by CWallet::AccountMove(), CTransactionBuilder::CTransactionBuilder(), and CWallet::EncryptWallet().
◆ TxnCommit()
bool WalletBatch::TxnCommit | ( | ) |
Commit current transaction.
Definition at line 905 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::TxnCommit().
Referenced by CWallet::AccountMove(), and CWallet::EncryptWallet().
◆ VerifyDatabaseFile()
|
static |
Definition at line 862 of file walletdb.cpp.
References Recover(), and BerkeleyBatch::VerifyDatabaseFile().
Referenced by CWallet::Verify().
◆ VerifyEnvironment()
|
static |
Definition at line 857 of file walletdb.cpp.
References BerkeleyBatch::VerifyEnvironment().
Referenced by CWallet::Verify().
◆ WriteAccount()
bool WalletBatch::WriteAccount | ( | const std::string & | strAccount, |
const CAccount & | account | ||
) |
Definition at line 161 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::GetAccountDestination().
◆ WriteAccountingEntry()
bool WalletBatch::WriteAccountingEntry | ( | const uint64_t | nAccEntryNum, |
const CAccountingEntry & | acentry | ||
) |
This writes directly to the database, and will not update the CWallet's cached accounting entries! Use wallet.AddAccountingEntry instead, to write and update its caches.
Definition at line 166 of file walletdb.cpp.
References CAccountingEntry::strAccount, and WriteIC().
Referenced by CWallet::AddAccountingEntry(), and CWallet::ReorderTransactions().
◆ WriteBestBlock()
bool WalletBatch::WriteBestBlock | ( | const CBlockLocator & | locator | ) |
Definition at line 118 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::SetBestChain().
◆ WriteCryptedHDChain()
bool WalletBatch::WriteCryptedHDChain | ( | const CHDChain & | chain | ) |
Definition at line 882 of file walletdb.cpp.
References EraseIC(), and WriteIC().
Referenced by CWallet::SetCryptedHDChain().
◆ WriteCryptedKey()
bool WalletBatch::WriteCryptedKey | ( | const CPubKey & | vchPubKey, |
const std::vector< unsigned char > & | vchCryptedSecret, | ||
const CKeyMetadata & | keyMeta | ||
) |
Definition at line 76 of file walletdb.cpp.
References EraseIC(), and WriteIC().
Referenced by CWallet::AddCryptedKey().
◆ WriteCScript()
Definition at line 97 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::AddCScript().
◆ WriteDestData()
bool WalletBatch::WriteDestData | ( | const std::string & | address, |
const std::string & | key, | ||
const std::string & | value | ||
) |
Write destination data key,value tuple to database.
Definition at line 867 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::AddDestData().
◆ WriteHDChain()
bool WalletBatch::WriteHDChain | ( | const CHDChain & | chain | ) |
write the hdchain model (external chain child index counter)
Definition at line 877 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::SetHDChain().
◆ WriteHDPubKey()
bool WalletBatch::WriteHDPubKey | ( | const CHDPubKey & | hdPubKey, |
const CKeyMetadata & | keyMeta | ||
) |
Definition at line 892 of file walletdb.cpp.
References CHDPubKey::extPubKey, CExtPubKey::pubkey, and WriteIC().
Referenced by CWallet::AddHDPubKey().
◆ WriteIC()
|
inlineprivate |
Definition at line 100 of file walletdb.h.
References BerkeleyDatabase::IncrementUpdateCounter(), m_batch, m_database, and BerkeleyBatch::Write().
Referenced by WriteAccount(), WriteAccountingEntry(), WriteBestBlock(), WriteCryptedHDChain(), WriteCryptedKey(), WriteCScript(), WriteDestData(), WriteHDChain(), WriteHDPubKey(), WriteKey(), WriteMasterKey(), WriteMinVersion(), WriteName(), WriteOrderPosNext(), WritePool(), WritePrivateSendSalt(), WritePurpose(), WriteTx(), and WriteWatchOnly().
◆ WriteKey()
bool WalletBatch::WriteKey | ( | const CPubKey & | vchPubKey, |
const CPrivKey & | vchPrivKey, | ||
const CKeyMetadata & | keyMeta | ||
) |
Definition at line 61 of file walletdb.cpp.
References CPubKey::begin(), CPubKey::end(), Hash(), CPubKey::size(), and WriteIC().
Referenced by CWallet::AddKeyPubKeyWithDB().
◆ WriteMasterKey()
bool WalletBatch::WriteMasterKey | ( | unsigned int | nID, |
const CMasterKey & | kMasterKey | ||
) |
Definition at line 92 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::ChangeWalletPassphrase(), and CWallet::EncryptWallet().
◆ WriteMinVersion()
bool WalletBatch::WriteMinVersion | ( | int | nVersion | ) |
Definition at line 150 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::SetMinVersion().
◆ WriteName()
bool WalletBatch::WriteName | ( | const std::string & | strAddress, |
const std::string & | strName | ||
) |
Definition at line 29 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::SetAddressBook().
◆ WriteOrderPosNext()
bool WalletBatch::WriteOrderPosNext | ( | int64_t | nOrderPosNext | ) |
Definition at line 130 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::IncOrderPosNext(), and CWallet::ReorderTransactions().
◆ WritePool()
bool WalletBatch::WritePool | ( | int64_t | nPool, |
const CKeyPool & | keypool | ||
) |
Definition at line 140 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::TopUpKeyPool().
◆ WritePrivateSendSalt()
bool WalletBatch::WritePrivateSendSalt | ( | const uint256 & | salt | ) |
Definition at line 176 of file walletdb.cpp.
References WriteIC().
◆ WritePurpose()
bool WalletBatch::WritePurpose | ( | const std::string & | strAddress, |
const std::string & | purpose | ||
) |
Definition at line 41 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::SetAddressBook().
◆ WriteTx()
bool WalletBatch::WriteTx | ( | const CWalletTx & | wtx | ) |
Definition at line 51 of file walletdb.cpp.
References CMerkleTx::GetHash(), and WriteIC().
Referenced by CWallet::AbandonTransaction(), CWallet::AddToWallet(), CWallet::CreateWalletFromFile(), LoadWallet(), CWallet::MarkConflicted(), and CWallet::ReorderTransactions().
◆ WriteVersion()
bool WalletBatch::WriteVersion | ( | int | nVersion | ) |
Write wallet version.
Definition at line 920 of file walletdb.cpp.
References m_batch, and BerkeleyBatch::WriteVersion().
Referenced by LoadWallet().
◆ WriteWatchOnly()
bool WalletBatch::WriteWatchOnly | ( | const CScript & | script, |
const CKeyMetadata & | keymeta | ||
) |
Definition at line 102 of file walletdb.cpp.
References WriteIC().
Referenced by CWallet::AddWatchOnly().
◆ ZapSelectTx()
DBErrors WalletBatch::ZapSelectTx | ( | std::vector< uint256 > & | vHashIn, |
std::vector< uint256 > & | vHashOut | ||
) |
Definition at line 734 of file walletdb.cpp.
References BCLog::DB, DB_CORRUPT, DB_LOAD_OK, EraseTx(), FindWalletTx(), and LogPrint.
Referenced by CWallet::ZapSelectTx().
◆ ZapWalletTx()
Definition at line 772 of file walletdb.cpp.
References DB_CORRUPT, DB_LOAD_OK, EraseTx(), and FindWalletTx().
Referenced by CWallet::ZapWalletTx().
Member Data Documentation
◆ m_batch
|
private |
Definition at line 207 of file walletdb.h.
Referenced by EraseIC(), FindWalletTx(), ListAccountCreditDebit(), LoadWallet(), ReadAccount(), ReadBestBlock(), ReadPool(), ReadPrivateSendSalt(), ReadVersion(), TxnAbort(), TxnBegin(), TxnCommit(), WriteIC(), and WriteVersion().
◆ m_database
|
private |
Definition at line 208 of file walletdb.h.
The documentation for this class was generated from the following files:
- src/wallet/walletdb.h
- src/wallet/walletdb.cpp