6 #ifndef BITCOIN_WALLET_WALLETDB_H 7 #define BITCOIN_WALLET_WALLETDB_H 59 extern const std::string
ACENTRY;
65 extern const std::string
CSCRIPT;
68 extern const std::string
FLAGS;
69 extern const std::string
HDCHAIN;
70 extern const std::string
KEY;
71 extern const std::string
KEYMETA;
75 extern const std::string
NAME;
76 extern const std::string
OLD_KEY;
78 extern const std::string
POOL;
79 extern const std::string
PURPOSE;
81 extern const std::string
TX;
82 extern const std::string
VERSION;
87 extern const std::string
WATCHS;
90 extern const std::unordered_set<std::string>
LEGACY_TYPES;
112 READWRITE(obj.nVersion, obj.nExternalChainCounter, obj.seed_id);
158 READWRITE(obj.nVersion, obj.nCreateTime);
160 READWRITE(obj.hdKeypath, obj.hd_seed_id);
190 template <
typename K,
typename T>
191 bool WriteIC(
const K& key,
const T& value,
bool fOverwrite =
true)
193 if (!
m_batch->Write(key, value, fOverwrite)) {
203 template <
typename K>
218 m_batch(database.MakeBatch(_fFlushOnClose)),
225 bool WriteName(
const std::string& strAddress,
const std::string& strName);
226 bool EraseName(
const std::string& strAddress);
228 bool WritePurpose(
const std::string& strAddress,
const std::string& purpose);
267 bool WriteDestData(
const std::string &address,
const std::string &key,
const std::string &value);
269 bool EraseDestData(
const std::string &address,
const std::string &key);
278 static bool IsKeyType(
const std::string& strType);
284 bool EraseRecords(
const std::unordered_set<std::string>& types);
315 #endif // BITCOIN_WALLET_WALLETDB_H const std::string MASTER_KEY
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key...
const std::string BESTBLOCK_NOMERKLE
const std::string SETTINGS
const std::string CRYPTED_KEY
const std::string HDCHAIN
WalletDatabase & m_database
const std::string ACENTRY
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
const std::string VERSION
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
const std::string DESTDATA
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
const std::string WALLETDESCRIPTORCKEY
bool WriteDescriptorCacheItems(const uint256 &desc_id, const DescriptorCache &cache)
DBErrors FindWalletTx(std::vector< uint256 > &vTxHash, std::list< CWalletTx > &vWtx)
bool EraseDestData(const std::string &address, const std::string &key)
Erase destination data tuple from wallet database.
const std::string BESTBLOCK
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
uint32_t nExternalChainCounter
int64_t m_next_internal_index
const std::string WALLETDESCRIPTOR
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
bool TxnAbort()
Abort current transaction.
bool EraseWatchOnly(const CScript &script)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool WriteLockedUTXO(const COutPoint &output)
Double ended buffer combining vector and stream-like interfaces.
bool WriteMinVersion(int nVersion)
Access to the wallet database.
bool WritePool(int64_t nPool, const CKeyPool &keypool)
A key from a CWallet's keypool.
const std::string CSCRIPT
bool WriteOrderPosNext(int64_t nOrderPosNext)
bool ReadBestBlock(CBlockLocator &locator)
const std::string PURPOSE
std::atomic< unsigned int > nUpdateCounter
const std::string MINVERSION
std::unique_ptr< DatabaseBatch > m_batch
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
const std::string WALLETDESCRIPTORKEY
const std::unordered_set< std::string > LEGACY_TYPES
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
int64_t m_next_external_index
void MaybeCompactWalletDB(WalletContext &context)
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
bool WriteBestBlock(const CBlockLocator &locator)
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (SIZE bytes)
A transaction with a bunch of additional info that only the owner cares about.
const std::string WATCHMETA
bool EraseName(const std::string &strAddress)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
bool TxnCommit()
Commit current transaction.
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
WalletBatch(WalletDatabase &database, bool _fFlushOnClose=true)
bool ReadPool(int64_t nPool, CKeyPool &keypool)
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase(DatabaseOptions &options)
Return object for accessing temporary in-memory database.
bool WriteTx(const CWalletTx &wtx)
std::function< bool(const std::string &)> KeyFilterFn
Callback for filtering key types to deserialize in ReadKeyValue.
An encapsulated public key.
virtual void IncrementUpdateCounter()=0
bool EraseRecords(const std::unordered_set< std::string > &types)
Delete records of the given types.
static bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue, CWalletScanState &wss, std::string &strType, std::string &strErr, const KeyFilterFn &filter_fn=nullptr) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
uint32_t nInternalChainCounter
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool WriteWalletFlags(const uint64_t flags)
An outpoint - a combination of a transaction hash and an index n into its vout.
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
bool ErasePurpose(const std::string &strAddress)
bool ErasePool(int64_t nPool)
Descriptor with some wallet metadata.
SERIALIZE_METHODS(CHDChain, obj)
const std::string ACTIVEINTERNALSPK
const std::string KEYMETA
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
bool EraseIC(const K &key)
const std::string ACTIVEEXTERNALSPK
Cache for single descriptor's derived extended pubkeys.
Serialized script, used inside transaction inputs and outputs.
A reference to a CKey: the Hash160 of its serialized public key.
bool TxnBegin()
Begin a new transaction.
bool EraseTx(uint256 hash)
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
const std::string LOCKED_UTXO
DBErrors
Error statuses for the wallet database.
static const int VERSION_HD_BASE
static bool IsKeyType(const std::string &strType)
bool WriteName(const std::string &strAddress, const std::string &strName)
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
const std::string DEFAULTKEY
bool operator==(const CHDChain &chain) const
bool EraseLockedUTXO(const COutPoint &output)
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
const std::string ORDERPOSNEXT
static const int CURRENT_VERSION
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
bool WritePurpose(const std::string &strAddress, const std::string &purpose)
CKeyID seed_id
seed hash160
WalletBatch & operator=(const WalletBatch &)=delete
An instance of this class represents one database.
const std::string OLD_KEY
bool WriteDescriptorLastHardenedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.
static const int VERSION_HD_CHAIN_SPLIT