Bitcoin Core  22.99.0
P2P Digital Currency
walletdb.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_WALLET_WALLETDB_H
7 #define BITCOIN_WALLET_WALLETDB_H
8 
9 #include <script/sign.h>
10 #include <wallet/db.h>
11 #include <wallet/walletutil.h>
12 #include <key.h>
13 
14 #include <stdint.h>
15 #include <string>
16 #include <vector>
17 
18 class CScript;
19 class uint160;
20 class uint256;
21 struct CBlockLocator;
22 
23 namespace wallet {
24 class CKeyPool;
25 class CMasterKey;
26 class CWallet;
27 class CWalletTx;
28 struct WalletContext;
29 
42 static const bool DEFAULT_FLUSHWALLET = true;
43 
45 enum class DBErrors
46 {
47  LOAD_OK,
48  CORRUPT,
50  TOO_NEW,
51  LOAD_FAIL,
54 };
55 
56 namespace DBKeys {
57 extern const std::string ACENTRY;
58 extern const std::string ACTIVEEXTERNALSPK;
59 extern const std::string ACTIVEINTERNALSPK;
60 extern const std::string BESTBLOCK;
61 extern const std::string BESTBLOCK_NOMERKLE;
62 extern const std::string CRYPTED_KEY;
63 extern const std::string CSCRIPT;
64 extern const std::string DEFAULTKEY;
65 extern const std::string DESTDATA;
66 extern const std::string FLAGS;
67 extern const std::string HDCHAIN;
68 extern const std::string KEY;
69 extern const std::string KEYMETA;
70 extern const std::string LOCKED_UTXO;
71 extern const std::string MASTER_KEY;
72 extern const std::string MINVERSION;
73 extern const std::string NAME;
74 extern const std::string OLD_KEY;
75 extern const std::string ORDERPOSNEXT;
76 extern const std::string POOL;
77 extern const std::string PURPOSE;
78 extern const std::string SETTINGS;
79 extern const std::string TX;
80 extern const std::string VERSION;
81 extern const std::string WALLETDESCRIPTOR;
82 extern const std::string WALLETDESCRIPTORCKEY;
83 extern const std::string WALLETDESCRIPTORKEY;
84 extern const std::string WATCHMETA;
85 extern const std::string WATCHS;
86 } // namespace DBKeys
87 
88 /* simple HD chain data model */
89 class CHDChain
90 {
91 public:
95 
96  static const int VERSION_HD_BASE = 1;
97  static const int VERSION_HD_CHAIN_SPLIT = 2;
99  int nVersion;
100 
101  CHDChain() { SetNull(); }
102 
104  {
105  READWRITE(obj.nVersion, obj.nExternalChainCounter, obj.seed_id);
106  if (obj.nVersion >= VERSION_HD_CHAIN_SPLIT) {
107  READWRITE(obj.nInternalChainCounter);
108  }
109  }
110 
111  void SetNull()
112  {
116  seed_id.SetNull();
117  }
118 
119  bool operator==(const CHDChain& chain) const
120  {
121  return seed_id == chain.seed_id;
122  }
123 };
124 
126 {
127 public:
128  static const int VERSION_BASIC=1;
129  static const int VERSION_WITH_HDDATA=10;
130  static const int VERSION_WITH_KEY_ORIGIN = 12;
132  int nVersion;
133  int64_t nCreateTime; // 0 means unknown
134  std::string hdKeypath; //optional HD/bip32 keypath. Still used to determine whether a key is a seed. Also kept for backwards compatibility
135  CKeyID hd_seed_id; //id of the HD seed used to derive this key
136  KeyOriginInfo key_origin; // Key origin info with path and fingerprint
137  bool has_key_origin = false;
138 
140  {
141  SetNull();
142  }
143  explicit CKeyMetadata(int64_t nCreateTime_)
144  {
145  SetNull();
146  nCreateTime = nCreateTime_;
147  }
148 
150  {
151  READWRITE(obj.nVersion, obj.nCreateTime);
152  if (obj.nVersion >= VERSION_WITH_HDDATA) {
153  READWRITE(obj.hdKeypath, obj.hd_seed_id);
154  }
155  if (obj.nVersion >= VERSION_WITH_KEY_ORIGIN)
156  {
157  READWRITE(obj.key_origin);
158  READWRITE(obj.has_key_origin);
159  }
160  }
161 
162  void SetNull()
163  {
165  nCreateTime = 0;
166  hdKeypath.clear();
168  key_origin.clear();
169  has_key_origin = false;
170  }
171 };
172 
181 {
182 private:
183  template <typename K, typename T>
184  bool WriteIC(const K& key, const T& value, bool fOverwrite = true)
185  {
186  if (!m_batch->Write(key, value, fOverwrite)) {
187  return false;
188  }
190  if (m_database.nUpdateCounter % 1000 == 0) {
191  m_batch->Flush();
192  }
193  return true;
194  }
195 
196  template <typename K>
197  bool EraseIC(const K& key)
198  {
199  if (!m_batch->Erase(key)) {
200  return false;
201  }
203  if (m_database.nUpdateCounter % 1000 == 0) {
204  m_batch->Flush();
205  }
206  return true;
207  }
208 
209 public:
210  explicit WalletBatch(WalletDatabase &database, bool _fFlushOnClose = true) :
211  m_batch(database.MakeBatch(_fFlushOnClose)),
212  m_database(database)
213  {
214  }
215  WalletBatch(const WalletBatch&) = delete;
216  WalletBatch& operator=(const WalletBatch&) = delete;
217 
218  bool WriteName(const std::string& strAddress, const std::string& strName);
219  bool EraseName(const std::string& strAddress);
220 
221  bool WritePurpose(const std::string& strAddress, const std::string& purpose);
222  bool ErasePurpose(const std::string& strAddress);
223 
224  bool WriteTx(const CWalletTx& wtx);
225  bool EraseTx(uint256 hash);
226 
227  bool WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey, const bool overwrite);
228  bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata &keyMeta);
229  bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, const CKeyMetadata &keyMeta);
230  bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey);
231 
232  bool WriteCScript(const uint160& hash, const CScript& redeemScript);
233 
234  bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta);
235  bool EraseWatchOnly(const CScript &script);
236 
237  bool WriteBestBlock(const CBlockLocator& locator);
238  bool ReadBestBlock(CBlockLocator& locator);
239 
240  bool WriteOrderPosNext(int64_t nOrderPosNext);
241 
242  bool ReadPool(int64_t nPool, CKeyPool& keypool);
243  bool WritePool(int64_t nPool, const CKeyPool& keypool);
244  bool ErasePool(int64_t nPool);
245 
246  bool WriteMinVersion(int nVersion);
247 
248  bool WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey);
249  bool WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret);
250  bool WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor);
251  bool WriteDescriptorDerivedCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index, uint32_t der_index);
252  bool WriteDescriptorParentCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index);
253  bool WriteDescriptorLastHardenedCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index);
254  bool WriteDescriptorCacheItems(const uint256& desc_id, const DescriptorCache& cache);
255 
256  bool WriteLockedUTXO(const COutPoint& output);
257  bool EraseLockedUTXO(const COutPoint& output);
258 
260  bool WriteDestData(const std::string &address, const std::string &key, const std::string &value);
262  bool EraseDestData(const std::string &address, const std::string &key);
263 
264  bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bool internal);
265  bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal);
266 
267  DBErrors LoadWallet(CWallet* pwallet);
268  DBErrors FindWalletTx(std::vector<uint256>& vTxHash, std::list<CWalletTx>& vWtx);
269  DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut);
270  /* Function to determine if a certain KV/key-type is a key (cryptographical key) type */
271  static bool IsKeyType(const std::string& strType);
272 
274  bool WriteHDChain(const CHDChain& chain);
275 
276  bool WriteWalletFlags(const uint64_t flags);
278  bool TxnBegin();
280  bool TxnCommit();
282  bool TxnAbort();
283 private:
284  std::unique_ptr<DatabaseBatch> m_batch;
286 };
287 
290 
292 using KeyFilterFn = std::function<bool(const std::string&)>;
293 
295 bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, std::string& strType, std::string& strErr, const KeyFilterFn& filter_fn = nullptr);
296 
298 std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase();
299 
301 std::unique_ptr<WalletDatabase> CreateMockWalletDatabase();
302 } // namespace wallet
303 
304 #endif // BITCOIN_WALLET_WALLETDB_H
wallet::WalletBatch::ZapSelectTx
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
Definition: walletdb.cpp:1003
wallet::WalletDatabase
An instance of this class represents one database.
Definition: db.h:104
wallet::DBKeys::NAME
const std::string NAME
Definition: walletdb.cpp:47
wallet::WalletBatch::WriteDescriptorCacheItems
bool WriteDescriptorCacheItems(const uint256 &desc_id, const DescriptorCache &cache)
Definition: walletdb.cpp:267
wallet::WalletBatch::operator=
WalletBatch & operator=(const WalletBatch &)=delete
wallet::WalletBatch::EraseDestData
bool EraseDestData(const std::string &address, const std::string &key)
Erase destination data tuple from wallet database.
Definition: walletdb.cpp:1073
wallet::DBKeys::HDCHAIN
const std::string HDCHAIN
Definition: walletdb.cpp:41
wallet::DBKeys::ACENTRY
const std::string ACENTRY
Definition: walletdb.cpp:31
wallet::DBKeys::DESTDATA
const std::string DESTDATA
Definition: walletdb.cpp:39
wallet::DBKeys::VERSION
const std::string VERSION
Definition: walletdb.cpp:54
wallet::WalletBatch::WriteCryptedDescriptorKey
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
Definition: walletdb.cpp:232
wallet::WalletBatch::WriteHDChain
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
Definition: walletdb.cpp:1079
wallet::DBKeys::MASTER_KEY
const std::string MASTER_KEY
Definition: walletdb.cpp:45
wallet::CKeyMetadata
Definition: walletdb.h:125
wallet::WalletBatch::WriteMasterKey
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
Definition: walletdb.cpp:146
wallet::DBKeys::WALLETDESCRIPTORCKEY
const std::string WALLETDESCRIPTORCKEY
Definition: walletdb.cpp:58
wallet::DBKeys::CRYPTED_KEY
const std::string CRYPTED_KEY
Definition: walletdb.cpp:36
wallet::CKeyMetadata::SERIALIZE_METHODS
SERIALIZE_METHODS(CKeyMetadata, obj)
Definition: walletdb.h:149
wallet::DBKeys::BESTBLOCK_NOMERKLE
const std::string BESTBLOCK_NOMERKLE
Definition: walletdb.cpp:34
wallet::DBKeys::SETTINGS
const std::string SETTINGS
Definition: walletdb.cpp:52
wallet::WalletBatch::WriteDescriptorLastHardenedCache
bool WriteDescriptorLastHardenedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
Definition: walletdb.cpp:260
flags
int flags
Definition: bitcoin-tx.cpp:529
wallet::WalletBatch::WriteMinVersion
bool WriteMinVersion(int nVersion)
Definition: walletdb.cpp:204
wallet::CKeyPool
A key from a CWallet's keypool.
Definition: scriptpubkeyman.h:103
wallet::CKeyMetadata::SetNull
void SetNull()
Definition: walletdb.h:162
wallet::DBErrors::NONCRITICAL_ERROR
@ NONCRITICAL_ERROR
wallet::DBKeys::WALLETDESCRIPTOR
const std::string WALLETDESCRIPTOR
Definition: walletdb.cpp:55
wallet::WalletBatch::WriteLockedUTXO
bool WriteLockedUTXO(const COutPoint &output)
Definition: walletdb.cpp:289
wallet::DBKeys::KEY
const std::string KEY
Definition: walletdb.cpp:43
wallet::WalletBatch::m_database
WalletDatabase & m_database
Definition: walletdb.h:285
wallet::WalletBatch::WriteDescriptorKey
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
Definition: walletdb.cpp:221
CPrivKey
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (SIZE bytes)
Definition: key.h:23
wallet::CHDChain::SERIALIZE_METHODS
SERIALIZE_METHODS(CHDChain, obj)
Definition: walletdb.h:103
wallet::WalletBatch::WritePool
bool WritePool(int64_t nPool, const CKeyPool &keypool)
Definition: walletdb.cpp:194
wallet::WalletBatch::WriteOrderPosNext
bool WriteOrderPosNext(int64_t nOrderPosNext)
Definition: walletdb.cpp:184
wallet::CHDChain::CHDChain
CHDChain()
Definition: walletdb.h:101
wallet::DBErrors::NEED_REWRITE
@ NEED_REWRITE
base_blob::SetNull
void SetNull()
Definition: uint256.h:41
wallet::WalletBatch::WriteBestBlock
bool WriteBestBlock(const CBlockLocator &locator)
Definition: walletdb.cpp:172
wallet::DBKeys::BESTBLOCK
const std::string BESTBLOCK
Definition: walletdb.cpp:35
wallet::DBKeys::MINVERSION
const std::string MINVERSION
Definition: walletdb.cpp:46
wallet::CHDChain::nVersion
int nVersion
Definition: walletdb.h:99
wallet::KeyFilterFn
std::function< bool(const std::string &)> KeyFilterFn
Callback for filtering key types to deserialize in ReadKeyValue.
Definition: walletdb.h:292
wallet::DBErrors
DBErrors
Error statuses for the wallet database.
Definition: walletdb.h:45
wallet
Definition: node.h:38
wallet::DBKeys::PURPOSE
const std::string PURPOSE
Definition: walletdb.cpp:51
wallet::DBKeys::CSCRIPT
const std::string CSCRIPT
Definition: walletdb.cpp:37
wallet::WalletBatch::WriteDescriptor
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
Definition: walletdb.cpp:241
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:23
wallet::DBKeys::WALLETDESCRIPTORKEY
const std::string WALLETDESCRIPTORKEY
Definition: walletdb.cpp:59
wallet::CHDChain::VERSION_HD_BASE
static const int VERSION_HD_BASE
Definition: walletdb.h:96
wallet::CKeyMetadata::CURRENT_VERSION
static const int CURRENT_VERSION
Definition: walletdb.h:131
wallet::WalletBatch::TxnAbort
bool TxnAbort()
Abort current transaction.
Definition: walletdb.cpp:1099
wallet::WalletBatch::FindWalletTx
DBErrors FindWalletTx(std::vector< uint256 > &vTxHash, std::list< CWalletTx > &vWtx)
Definition: walletdb.cpp:952
wallet::CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:137
wallet::WalletBatch::EraseName
bool EraseName(const std::string &strAddress)
Definition: walletdb.cpp:73
wallet::CKeyMetadata::hdKeypath
std::string hdKeypath
Definition: walletdb.h:134
db.h
wallet::WalletBatch::WriteActiveScriptPubKeyMan
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
Definition: walletdb.cpp:209
wallet::CHDChain::operator==
bool operator==(const CHDChain &chain) const
Definition: walletdb.h:119
wallet::WalletBatch::ReadPool
bool ReadPool(int64_t nPool, CKeyPool &keypool)
Definition: walletdb.cpp:189
wallet::CKeyMetadata::nVersion
int nVersion
Definition: walletdb.h:132
wallet::DBErrors::CORRUPT
@ CORRUPT
wallet::WalletBatch::EraseWatchOnly
bool EraseWatchOnly(const CScript &script)
Definition: walletdb.cpp:164
wallet::CreateDummyWalletDatabase
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.
Definition: walletdb.cpp:1184
wallet::DBKeys::WATCHMETA
const std::string WATCHMETA
Definition: walletdb.cpp:60
wallet::CHDChain::VERSION_HD_CHAIN_SPLIT
static const int VERSION_HD_CHAIN_SPLIT
Definition: walletdb.h:97
wallet::WalletBatch::WalletBatch
WalletBatch(WalletDatabase &database, bool _fFlushOnClose=true)
Definition: walletdb.h:210
wallet::WalletBatch::WriteCryptedKey
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
Definition: walletdb.cpp:120
wallet::CKeyMetadata::nCreateTime
int64_t nCreateTime
Definition: walletdb.h:133
wallet::WalletBatch::TxnCommit
bool TxnCommit()
Commit current transaction.
Definition: walletdb.cpp:1094
walletutil.h
wallet::WalletDatabase::IncrementUpdateCounter
virtual void IncrementUpdateCounter()=0
wallet::CKeyMetadata::hd_seed_id
CKeyID hd_seed_id
Definition: walletdb.h:135
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:232
wallet::WalletBatch::m_batch
std::unique_ptr< DatabaseBatch > m_batch
Definition: walletdb.h:284
wallet::WalletBatch::ReadBestBlock
bool ReadBestBlock(CBlockLocator &locator)
Definition: walletdb.cpp:178
wallet::WalletBatch::WriteWalletFlags
bool WriteWalletFlags(const uint64_t flags)
Definition: walletdb.cpp:1084
wallet::CHDChain::CURRENT_VERSION
static const int CURRENT_VERSION
Definition: walletdb.h:98
wallet::DBErrors::LOAD_OK
@ LOAD_OK
wallet::CKeyMetadata::VERSION_WITH_HDDATA
static const int VERSION_WITH_HDDATA
Definition: walletdb.h:129
wallet::WalletBatch::WriteCScript
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
Definition: walletdb.cpp:151
wallet::DBKeys::POOL
const std::string POOL
Definition: walletdb.cpp:50
wallet::WalletBatch::WriteKeyMetadata
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
Definition: walletdb.cpp:100
wallet::WalletBatch::LoadWallet
DBErrors LoadWallet(CWallet *pwallet)
Definition: walletdb.cpp:762
wallet::WalletBatch::ErasePool
bool ErasePool(int64_t nPool)
Definition: walletdb.cpp:199
wallet::WalletBatch::WriteWatchOnly
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
Definition: walletdb.cpp:156
sign.h
wallet::WalletBatch
Access to the wallet database.
Definition: walletdb.h:180
wallet::CKeyMetadata::VERSION_WITH_KEY_ORIGIN
static const int VERSION_WITH_KEY_ORIGIN
Definition: walletdb.h:130
context
WalletContext context
Definition: notifications.cpp:37
wallet::CMasterKey
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key.
Definition: crypter.h:34
wallet::CHDChain::SetNull
void SetNull()
Definition: walletdb.h:111
wallet::CKeyMetadata::CKeyMetadata
CKeyMetadata()
Definition: walletdb.h:139
wallet::WalletBatch::WriteDescriptorDerivedCache
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
Definition: walletdb.cpp:246
KeyOriginInfo::clear
void clear()
Definition: keyorigin.h:42
wallet::CHDChain
Definition: walletdb.h:89
uint256
256-bit opaque blob.
Definition: uint256.h:126
READWRITE
#define READWRITE(...)
Definition: serialize.h:140
wallet::DBKeys::FLAGS
const std::string FLAGS
Definition: walletdb.cpp:40
wallet::CHDChain::seed_id
CKeyID seed_id
seed hash160
Definition: walletdb.h:94
wallet::WalletBatch::WriteTx
bool WriteTx(const CWalletTx &wtx)
Definition: walletdb.cpp:90
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
wallet::DBKeys::KEYMETA
const std::string KEYMETA
Definition: walletdb.cpp:42
wallet::CreateMockWalletDatabase
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase()
Return object for accessing temporary in-memory database.
Definition: walletdb.cpp:1190
DescriptorCache
Cache for single descriptor's derived extended pubkeys.
Definition: descriptor.h:19
wallet::WalletBatch::EraseTx
bool EraseTx(uint256 hash)
Definition: walletdb.cpp:95
wallet::WalletDatabase::nUpdateCounter
std::atomic< unsigned int > nUpdateCounter
Definition: db.h:149
wallet::WalletBatch::TxnBegin
bool TxnBegin()
Begin a new transaction.
Definition: walletdb.cpp:1089
wallet::WalletBatch::WriteDestData
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
Definition: walletdb.cpp:1068
key.h
wallet::DEFAULT_FLUSHWALLET
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
Definition: walletdb.h:42
uint160
160-bit opaque blob.
Definition: uint256.h:115
wallet::DBErrors::LOAD_FAIL
@ LOAD_FAIL
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
wallet::DBKeys::ACTIVEINTERNALSPK
const std::string ACTIVEINTERNALSPK
Definition: walletdb.cpp:33
wallet::CKeyMetadata::key_origin
KeyOriginInfo key_origin
Definition: walletdb.h:136
wallet::DBErrors::NEED_RESCAN
@ NEED_RESCAN
wallet::CHDChain::nExternalChainCounter
uint32_t nExternalChainCounter
Definition: walletdb.h:92
wallet::WalletBatch::IsKeyType
static bool IsKeyType(const std::string &strType)
Definition: walletdb.cpp:756
wallet::WalletBatch::WriteName
bool WriteName(const std::string &strAddress, const std::string &strName)
Definition: walletdb.cpp:68
wallet::WalletBatch::WriteDescriptorParentCache
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
Definition: walletdb.cpp:253
wallet::WalletBatch::EraseLockedUTXO
bool EraseLockedUTXO(const COutPoint &output)
Definition: walletdb.cpp:294
wallet::WalletBatch::ErasePurpose
bool ErasePurpose(const std::string &strAddress)
Definition: walletdb.cpp:85
wallet::WalletBatch::WriteIC
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
Definition: walletdb.h:184
wallet::DBKeys::ACTIVEEXTERNALSPK
const std::string ACTIVEEXTERNALSPK
Definition: walletdb.cpp:32
wallet::WalletBatch::EraseIC
bool EraseIC(const K &key)
Definition: walletdb.h:197
wallet::ReadKeyValue
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)
Definition: walletdb.cpp:322
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:184
wallet::WalletBatch::EraseActiveScriptPubKeyMan
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
Definition: walletdb.cpp:215
wallet::WalletDescriptor
Descriptor with some wallet metadata.
Definition: walletutil.h:76
wallet::CKeyMetadata::CKeyMetadata
CKeyMetadata(int64_t nCreateTime_)
Definition: walletdb.h:143
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
wallet::DBKeys::LOCKED_UTXO
const std::string LOCKED_UTXO
Definition: walletdb.cpp:44
wallet::DBKeys::WATCHS
const std::string WATCHS
Definition: walletdb.cpp:61
wallet::WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:35
wallet::WalletBatch::WriteKey
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
Definition: walletdb.cpp:105
CBlockLocator
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:114
wallet::CKeyMetadata::has_key_origin
bool has_key_origin
Whether the key_origin is useful.
Definition: walletdb.h:137
wallet::DBKeys::TX
const std::string TX
Definition: walletdb.cpp:53
wallet::MaybeCompactWalletDB
void MaybeCompactWalletDB(WalletContext &context)
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
Definition: walletdb.cpp:1041
wallet::DBKeys::OLD_KEY
const std::string OLD_KEY
Definition: walletdb.cpp:48
wallet::CHDChain::nInternalChainCounter
uint32_t nInternalChainCounter
Definition: walletdb.h:93
wallet::DBErrors::TOO_NEW
@ TOO_NEW
wallet::DBKeys::DEFAULTKEY
const std::string DEFAULTKEY
Definition: walletdb.cpp:38
CExtPubKey
Definition: pubkey.h:291
KeyOriginInfo
Definition: keyorigin.h:11
wallet::DBKeys::ORDERPOSNEXT
const std::string ORDERPOSNEXT
Definition: walletdb.cpp:49
wallet::WalletBatch::WritePurpose
bool WritePurpose(const std::string &strAddress, const std::string &purpose)
Definition: walletdb.cpp:80
wallet::CKeyMetadata::VERSION_BASIC
static const int VERSION_BASIC
Definition: walletdb.h:128