7 #ifndef PIVX_WALLET_WALLETDB_H
8 #define PIVX_WALLET_WALLETDB_H
35 static const bool DEFAULT_FLUSHWALLET =
true;
87 if (obj.HasKeyOrigin()) {
88 READWRITE(obj.hd_seed_id, obj.key_origin);
114 template <
typename K,
typename T>
115 bool WriteIC(
const K& key,
const T& value,
bool fOverwrite =
true)
124 template <
typename K>
136 m_batch(database, pszMode, _fFlushOnClose),
143 bool WriteName(
const std::string& strAddress,
const std::string& strName);
144 bool EraseName(
const std::string& strAddress);
146 bool WritePurpose(
const std::string& strAddress,
const std::string& purpose);
189 const std::vector<unsigned char>& vchCryptedSecret,
199 bool WriteDestData(
const std::string& address,
const std::string& key,
const std::string& value);
201 bool EraseDestData(
const std::string& address,
const std::string& key);
208 static bool Recover(
const fs::path& wallet_path,
void *callbackDataIn,
bool (*recoverKVcallback)(
void* callbackData,
CDataStream ssKey,
CDataStream ssValue), std::string& out_backup_filename);
210 static bool Recover(
const fs::path& wallet_path, std::string& out_backup_filename);
214 static bool IsKeyType(
const std::string& strType);
216 static bool VerifyEnvironment(
const fs::path& wallet_path, std::string& errorStr);
218 static bool VerifyDatabaseFile(
const fs::path& wallet_path, std::string& warningStr, std::string& errorStr);
int64_t CAmount
Amount in PIV (Can be negative)
RAII class that provides access to a Berkeley database.
bool Write(const K &key, const T &value, bool fOverwrite=true)
An instance of this class represents one database.
void IncrementUpdateCounter()
A reference to a CKey: the Hash160 of its serialized public key.
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
A transaction with a bunch of additional info that only the owner cares about.
Access to the wallet database.
bool TxnCommit()
Commit current transaction.
bool WriteCustomFeeValue(const CAmount &nCustomFee)
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
static bool RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
bool ErasePool(int64_t nPool)
WalletBatch(const WalletBatch &)=delete
bool WriteName(const std::string &strAddress, const std::string &strName)
bool WriteSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk)
static bool Recover(const fs::path &wallet_path, void *callbackDataIn, bool(*recoverKVcallback)(void *callbackData, CDataStream ssKey, CDataStream ssValue), std::string &out_backup_filename)
bool WriteMinVersion(int nVersion)
DBErrors ZapWalletTx(CWallet *pwallet, std::vector< CWalletTx > &vWtx)
DBErrors ReorderTransactions(CWallet *pwallet)
static bool IsKeyType(const std::string &strType)
bool ErasePurpose(const std::string &strAddress)
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool EraseWatchOnly(const CScript &script)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
DBErrors FindWalletTx(CWallet *pwallet, std::vector< uint256 > &vTxHash, std::vector< CWalletTx > &vWtx)
bool ReadPool(int64_t nPool, CKeyPool &keypool)
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
bool WriteCryptedSaplingZKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool EraseDestData(const std::string &address, const std::string &key)
Erase destination data tuple from wallet database.
bool ReadVersion(int &nVersion)
Read wallet version.
WalletBatch(WalletDatabase &database, const char *pszMode="r+", bool _fFlushOnClose=true)
static bool VerifyEnvironment(const fs::path &wallet_path, std::string &errorStr)
bool WriteAutoCombineSettings(bool fEnable, CAmount nCombineThreshold, int frequency)
bool ReadSaplingCommonOVK(uint256 &ovkRet)
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external/internal chain child index counter)
bool ReadBestBlock(CBlockLocator &locator)
bool WriteOrderPosNext(int64_t nOrderPosNext)
bool WriteTx(const CWalletTx &wtx)
bool EraseIC(const K &key)
static bool VerifyDatabaseFile(const fs::path &wallet_path, std::string &warningStr, std::string &errorStr)
bool TxnBegin()
Begin a new transaction.
bool TxnAbort()
Abort current transaction.
bool WritePool(int64_t nPool, const CKeyPool &keypool)
bool WriteWitnessCacheSize(int64_t nWitnessCacheSize)
bool WriteUseCustomFee(bool fUse)
bool WriteBestBlock(const CBlockLocator &locator)
WalletBatch & operator=(const WalletBatch &)=delete
bool WriteVersion(int nVersion)
Write wallet version.
bool WriteWatchOnly(const CScript &script)
bool EraseTx(uint256 hash)
bool WriteStakeSplitThreshold(const CAmount &nStakeSplitThreshold)
bool WriteSaplingCommonOVK(const uint256 &ovk)
Common output viewing key, used when shielding transparent funds.
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 WriteSaplingZKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingExtendedSpendingKey &key, const CKeyMetadata &keyMeta)
Write extended spending key to wallet database, where the key is the incoming viewing key.
WalletDatabase & m_database
#define T(expected, seed, data)
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (PRIVATE_KEY_SIZE bytes)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
void MaybeCompactWalletDB()
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
DBErrors
Error statuses for the wallet database.
bool AutoBackupWallet(CWallet &wallet, std::string &strBackupWarning, std::string &strBackupError)
Called during init: Automatic backups.