6 #ifndef BITCOIN_WALLET_WALLETDB_H 7 #define BITCOIN_WALLET_WALLETDB_H 54 extern const std::string
ACENTRY;
60 extern const std::string
CSCRIPT;
63 extern const std::string
FLAGS;
64 extern const std::string
HDCHAIN;
65 extern const std::string
KEY;
66 extern const std::string
KEYMETA;
69 extern const std::string
NAME;
70 extern const std::string
OLD_KEY;
72 extern const std::string
POOL;
73 extern const std::string
PURPOSE;
75 extern const std::string
TX;
76 extern const std::string
VERSION;
81 extern const std::string
WATCHS;
101 READWRITE(obj.nVersion, obj.nExternalChainCounter, obj.seed_id);
147 READWRITE(obj.nVersion, obj.nCreateTime);
149 READWRITE(obj.hdKeypath, obj.hd_seed_id);
179 template <
typename K,
typename T>
180 bool WriteIC(
const K& key,
const T& value,
bool fOverwrite =
true)
182 if (!
m_batch->Write(key, value, fOverwrite)) {
192 template <
typename K>
207 m_batch(database.MakeBatch(_fFlushOnClose)),
214 bool WriteName(
const std::string& strAddress,
const std::string& strName);
215 bool EraseName(
const std::string& strAddress);
217 bool WritePurpose(
const std::string& strAddress,
const std::string& purpose);
253 bool WriteDestData(
const std::string &address,
const std::string &key,
const std::string &value);
255 bool EraseDestData(
const std::string &address,
const std::string &key);
264 static bool IsKeyType(
const std::string& strType);
296 #endif // BITCOIN_WALLET_WALLETDB_H bool TxnCommit()
Commit current transaction.
static const int CURRENT_VERSION
bool WriteName(const std::string &strAddress, const std::string &strName)
bool EraseIC(const K &key)
bool EraseDestData(const std::string &address, const std::string &key)
Erase destination data tuple from wallet database.
bool ErasePurpose(const std::string &strAddress)
bool ReadBestBlock(CBlockLocator &locator)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
bool operator==(const CHDChain &chain) const
const std::string SETTINGS
const std::string WALLETDESCRIPTORCKEY
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
WalletBatch(WalletDatabase &database, bool _fFlushOnClose=true)
const std::string CRYPTED_KEY
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
const std::string DEFAULTKEY
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
bool WriteMinVersion(int nVersion)
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key...
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
const std::string KEYMETA
bool WriteDescriptorCacheItems(const uint256 &desc_id, const DescriptorCache &cache)
uint32_t nExternalChainCounter
bool TxnBegin()
Begin a new transaction.
Double ended buffer combining vector and stream-like interfaces.
bool WriteTx(const CWalletTx &wtx)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
DBErrors
Error statuses for the wallet database.
const std::string ORDERPOSNEXT
bool WriteWalletFlags(const uint64_t flags)
const std::string VERSION
const std::string MASTER_KEY
bool EraseWatchOnly(const CScript &script)
Access to the wallet database.
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
bool WriteBestBlock(const CBlockLocator &locator)
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
secure_allocator is defined in allocators.h CPrivKey is a serialized private key, with all parameters...
bool TxnAbort()
Abort current transaction.
const std::string OLD_KEY
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase()
Return object for accessing temporary in-memory database.
const std::string HDCHAIN
static bool IsKeyType(const std::string &strType)
const std::string WALLETDESCRIPTOR
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
std::unique_ptr< DatabaseBatch > m_batch
const std::string ACTIVEINTERNALSPK
WalletDatabase & m_database
void MaybeCompactWalletDB()
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
An encapsulated public key.
const std::string WATCHMETA
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
const std::string WALLETDESCRIPTORKEY
const std::string DESTDATA
bool WriteOrderPosNext(int64_t nOrderPosNext)
Descriptor with some wallet metadata.
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.
A transaction with a bunch of additional info that only the owner cares about.
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
SERIALIZE_METHODS(CHDChain, obj)
bool ErasePool(int64_t nPool)
bool WritePool(int64_t nPool, const CKeyPool &keypool)
const std::string ACENTRY
bool WriteDescriptorLastHardenedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
std::atomic< unsigned int > nUpdateCounter
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
Cache for single descriptor's derived extended pubkeys.
Serialized script, used inside transaction inputs and outputs.
const std::string MINVERSION
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
A reference to a CKey: the Hash160 of its serialized public key.
const std::string ACTIVEEXTERNALSPK
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
bool WritePurpose(const std::string &strAddress, const std::string &purpose)
bool ReadPool(int64_t nPool, CKeyPool &keypool)
static const int VERSION_HD_CHAIN_SPLIT
virtual void IncrementUpdateCounter()=0
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
const std::string BESTBLOCK
const std::string CSCRIPT
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.
bool EraseTx(uint256 hash)
DBErrors FindWalletTx(std::vector< uint256 > &vTxHash, std::list< CWalletTx > &vWtx)
CKeyID seed_id
seed hash160
std::function< bool(const std::string &)> KeyFilterFn
Callback for filtering key types to deserialize in ReadKeyValue.
const std::string BESTBLOCK_NOMERKLE
static const int VERSION_HD_BASE
WalletBatch & operator=(const WalletBatch &)=delete
uint32_t nInternalChainCounter
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
A key from a CWallet's keypool.
bool EraseName(const std::string &strAddress)
const std::string PURPOSE
An instance of this class represents one database.