6#include <bitcoin-build-config.h>
41const std::string
FLAGS{
"flags"};
44const std::string
KEY{
"key"};
48const std::string
NAME{
"name"};
51const std::string
POOL{
"pool"};
54const std::string
TX{
"tx"};
103 for (
const auto& [wtxid, tx] : wtx.
GetTxs()) {
138 const auto keypair_hash =
Hash(vchPubKey, vchPrivKey);
140 return WriteIC(std::make_pair(
DBKeys::KEY, vchPubKey), std::make_pair(vchPrivKey, keypair_hash),
false);
144 const std::vector<unsigned char>& vchCryptedSecret,
155 if (!
WriteIC(key, std::make_pair(vchCryptedSecret, checksum),
false)) {
157 std::vector<unsigned char> val;
158 if (!
m_batch->Read(key, val)) {
161 if (!
WriteIC(key, std::make_pair(val, checksum),
true)) {
203 if (
auto cursor =
m_batch->GetNewPrefixCursor(prefix)) {
218 return WriteIC(make_pair(key, type),
id);
224 return EraseIC(make_pair(key, type));
230 const auto keypair_hash =
Hash(pubkey, privkey);
252 xpub.
Encode(ser_xpub.data());
259 xpub.
Encode(ser_xpub.data());
266 xpub.
Encode(ser_xpub.data());
278 for (
const auto& derived_xpub_pair : derived_xpub_map_pair.second) {
310 strErr =
"Error reading wallet database: CPubKey corrupt";
328 catch (
const std::ios_base::failure&) {}
330 bool fSkipCheck =
false;
335 const auto keypair_hash =
Hash(vchPubKey, pkey);
337 if (keypair_hash != hash)
339 strErr =
"Error reading wallet database: CPubKey/CPrivKey corrupt";
346 if (!key.
Load(pkey, vchPubKey, fSkipCheck))
348 strErr =
"Error reading wallet database: CPrivKey corrupt";
353 strErr =
"Error reading wallet database: LegacyDataSPKM::LoadKey failed";
356 }
catch (
const std::exception& e) {
357 if (strErr.empty()) {
373 strErr =
"Error reading wallet database: CPubKey corrupt";
376 std::vector<unsigned char> vchPrivKey;
377 ssValue >> vchPrivKey;
380 bool checksum_valid =
false;
381 if (!ssValue.
empty()) {
384 if (!(checksum_valid =
Hash(vchPrivKey) == checksum)) {
385 strErr =
"Error reading wallet database: Encrypted key corrupt";
392 strErr =
"Error reading wallet database: LegacyDataSPKM::LoadCryptedKey failed";
395 }
catch (
const std::exception& e) {
396 if (strErr.empty()) {
412 ssValue >> kMasterKey;
415 strErr =
strprintf(
"Error reading wallet database: duplicate CMasterKey id %u", nID);
422 }
catch (
const std::exception& e) {
423 if (strErr.empty()) {
438 }
catch (
const std::exception& e) {
439 if (strErr.empty()) {
452 if (!pwallet->LoadWalletFlags(flags)) {
453 pwallet->WalletLogPrintf(
"Error reading wallet database: Unknown non-tolerable wallet flags found\n");
481 pwallet->
WalletLogPrintf(
"Error getting database cursor for '%s' records\n", key);
491 pwallet->
WalletLogPrintf(
"Error reading next '%s' record for wallet database\n", key);
499 DBErrors record_res = load_func(pwallet, ssKey, ssValue, error);
513 return LoadRecords(pwallet, batch, key, prefix, load_func);
518 const auto& batch =
wallet.GetDatabase().MakeBatch();
533 throw std::runtime_error(
strprintf(
"Error getting database cursor for '%s' records", type));
552 pwallet->WalletLogPrintf(
"Error: Unexpected legacy entry found in descriptor wallet %s. The wallet might have been tampered with or created with malicious intent.\n", pwallet->GetName());
565 result = std::max(result, hd_chain_res.
m_result);
572 result = std::max(result, key_res.
m_result);
579 result = std::max(result, ckey_res.
m_result);
590 strErr =
"Error reading wallet database: LegacyDataSPKM::LoadCScript failed";
595 result = std::max(result, script_res.
m_result);
598 std::map<uint160, CHDChain> hd_chains;
612 bool internal =
false;
615 std::vector<uint32_t> path;
622 strErr =
"Error reading wallet database: keymeta with invalid HD keypath";
631 if (path.size() != 3) {
632 strErr =
"Error reading wallet database: keymeta found with unexpected path";
635 if (path[0] != BIP32_HARDENED_FLAG) {
636 strErr =
strprintf(
"Unexpected path index of 0x%08x (expected 0x80000000) for the element at index 0", path[0]);
639 if (path[1] != BIP32_HARDENED_FLAG && path[1] != (1 | BIP32_HARDENED_FLAG)) {
640 strErr =
strprintf(
"Unexpected path index of 0x%08x (expected 0x80000000 or 0x80000001) for the element at index 1", path[1]);
643 if ((path[2] & BIP32_HARDENED_FLAG) == 0) {
644 strErr =
strprintf(
"Unexpected path index of 0x%08x (expected to be greater than or equal to 0x80000000)", path[2]);
647 internal = path[1] == (1 | BIP32_HARDENED_FLAG);
648 index = path[2] & ~BIP32_HARDENED_FLAG;
668 result = std::max(result, keymeta_res.
m_result);
671 if (!hd_chains.empty()) {
674 for (
const auto& [hd_seed_id, chain] : hd_chains) {
680 pwallet->
WalletLogPrintf(
"Inactive HD chains found but no LegacyDataSPKM\n");
697 result = std::max(result, watch_script_res.
m_result);
709 result = std::max(result, watch_meta_res.
m_result);
721 value >> default_pubkey;
722 }
catch (
const std::exception& e) {
726 if (!default_pubkey.
IsValid()) {
727 err =
"Error reading wallet database: Default Key corrupt";
732 result = std::max(result, default_key_res.
m_result);
737 err =
"Found unsupported 'wkey' record, try loading with version 0.18";
740 result = std::max(result, wkey_res.
m_result);
744 pwallet->
WalletLogPrintf(
"Legacy Wallet Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total.\n",
751template<
typename... Args>
772 std::optional<WalletDescriptor> desc;
775 }
catch (
const std::ios_base::failure& e) {
776 strErr =
strprintf(
"Error: Unrecognized descriptor found in wallet %s. ", pwallet->
GetName());
777 strErr += (last_client >
CLIENT_VERSION) ?
"The wallet might have been created on a newer version. " :
778 "The database might be corrupted or the software version is not compatible with one of your wallet descriptors. ";
779 strErr +=
"Please try running the latest software version";
781 strErr =
strprintf(
"%s\nDetails: %s", strErr, e.what());
793 uint32_t key_exp_index;
797 key >> key_exp_index;
810 xpub.
Decode(ser_xpub.data());
818 result = std::max(result, key_cache_res.
m_result);
825 uint32_t key_exp_index;
828 key >> key_exp_index;
833 xpub.
Decode(ser_xpub.data());
837 result = std::max(result, lh_cache_res.
m_result);
854 strErr =
"Error reading wallet database: descriptor unencrypted key CPubKey corrupt";
865 const auto keypair_hash =
Hash(pubkey, pkey);
867 if (keypair_hash != hash)
869 strErr =
"Error reading wallet database: descriptor unencrypted key CPubKey/CPrivKey corrupt";
873 if (!privkey.
Load(pkey, pubkey,
true))
875 strErr =
"Error reading wallet database: descriptor unencrypted key CPrivKey corrupt";
881 result = std::max(result, key_res.
m_result);
896 err =
"Error reading wallet database: descriptor encrypted key CPubKey corrupt";
899 std::vector<unsigned char> privkey;
902 ckeys[pubkey.
GetID()] = std::make_pair(pubkey, privkey);
905 result = std::max(result, ckey_res.
m_result);
910 }
catch (std::runtime_error& e) {
920 pwallet->
WalletLogPrintf(
"Descriptors: %u, Descriptor Keys: %u plaintext, %u encrypted, %u total.\n",
921 desc_res.
m_records, num_keys, num_ckeys, num_keys + num_ckeys);
935 std::string strAddress;
939 pwallet->m_address_book[DecodeDestination(strAddress)].SetLabel(label);
940 return DBErrors::LOAD_OK;
942 result = std::max(result, name_res.
m_result);
947 std::string strAddress;
949 std::string purpose_str;
950 value >> purpose_str;
951 std::optional<AddressPurpose> purpose{PurposeFromString(purpose_str)};
953 pwallet->
WalletLogPrintf(
"Warning: nonstandard purpose string '%s' for address '%s'\n", purpose_str, strAddress);
958 result = std::max(result, purpose_res.m_result);
963 std::string strAddress, strKey, strValue;
967 const CTxDestination& dest{DecodeDestination(strAddress)};
968 if (strKey.compare(
"used") == 0) {
975 pwallet->LoadAddressPreviouslySpent(dest);
976 }
else if (strKey.starts_with(
"rr")) {
979 pwallet->LoadAddressReceiveRequest(dest, strKey.substr(2), strValue);
983 result = std::max(result, dest_res.m_result);
990 std::map<Wtxid, CTransactionRef> variants;
1009 if (tx->GetHash() != txid) {
1010 throw std::runtime_error(
strprintf(
"Corrupted witness variant, tx hash differs"));
1012 if (!variants.emplace(tx->GetWitnessHash(), std::move(tx)).second) {
1013 throw std::runtime_error(
strprintf(
"Duplicate witness variant"));
1025 any_unordered =
false;
1028 DBErrors result = DBErrors::LOAD_OK;
1032 CWalletTx wtx{deserialize, value, ReadWtxVariants(batch, hash)};
1033 if (wtx.GetHash() != hash) {
1034 result = std::max(result, DBErrors::NEED_RESCAN);
1037 if (wtx.nOrderPos == -1) {
1038 any_unordered = true;
1041 if (!pwallet->LoadToWallet(std::move(wtx))) {
1042 err =
"Error: Corrupt transaction found. This can be fixed by removing transactions from wallet and rescanning.";
1043 return DBErrors::CORRUPT;
1045 }
catch (
const std::exception& e) {
1046 err =
strprintf(
"Error: Corrupt tx record found: %s" ,e.what());
1051 result = std::max(result, tx_res.m_result);
1054 LoadResult locked_utxo_res = LoadRecords(pwallet, batch, DBKeys::LOCKED_UTXO,
1060 pwallet->LoadLockedCoin(COutPoint(hash, n), true);
1061 return DBErrors::LOAD_OK;
1063 result = std::max(result, locked_utxo_res.m_result);
1067 LoadResult order_pos_res = LoadRecords(pwallet, batch, DBKeys::ORDERPOSNEXT,
1070 value >> pwallet->nOrderPosNext;
1071 }
catch (
const std::exception& e) {
1073 return DBErrors::NONCRITICAL_ERROR;
1075 return DBErrors::LOAD_OK;
1077 result = std::max(result, order_pos_res.m_result);
1081 for (
auto& [
id, wtx] : pwallet->mapWallet) {
1082 if (wtx.IsCoinBase() && wtx.isInactive()) {
1096 std::set<std::pair<OutputType, bool>> seen_spks;
1100 uint8_t output_type;
1106 auto [it, insert] = seen_spks.emplace(
static_cast<OutputType>(output_type), internal);
1108 strErr =
"Multiple ScriptpubKeyMans specified for a single type";
1114 result = std::max(result, spkm_res.
m_result);
1137 bool any_unordered =
false;
1144 if (has_last_client) pwallet->
WalletLogPrintf(
"Last client version = %d\n", last_client);
1151#ifndef ENABLE_EXTERNAL_SIGNER
1153 pwallet->
WalletLogPrintf(
"Error: External signer wallet being loaded without external signer support compiled\n");
1179 }
catch (std::runtime_error& e) {
1215 pwallet->
WalletLogPrintf(
"Detected extraneous encryption keys in this wallet without private keys. Removing extraneous encryption keys.\n");
1218 pwallet->
WalletLogPrintf(
"Error: Unable to remove extraneous encryption key '%u'. Wallet corrupt.\n",
id);
1260 return previously_spent ?
WriteIC(key, std::string(
"1")) :
EraseIC(key);
1277 return m_batch->ErasePrefix(prefix);
1287 return std::all_of(types.begin(), types.end(), [&](
const std::string& type) {
1288 return m_batch->ErasePrefix(DataStream() << type);
1299 bool res =
m_batch->TxnCommit();
1302 listener.on_commit();
1312 bool res =
m_batch->TxnAbort();
1315 listener.on_abort();
1333 exists = fs::symlink_status(path).type() != fs::file_type::not_found;
1334 }
catch (
const fs::filesystem_error& e) {
1335 error =
Untranslated(
strprintf(
"Failed to access database path '%s': %s", fs::PathToString(path), e.code().message()));
1340 std::optional<DatabaseFormat> format;
1347 error =
Untranslated(
strprintf(
"Failed to load database path '%s'. Data is in ambiguous format.", fs::PathToString(path)));
1354 error =
Untranslated(
strprintf(
"Failed to load database path '%s'. Path does not exist.", fs::PathToString(path)));
1360 error =
Untranslated(
strprintf(
"Failed to load database path '%s'. Data is not in recognized format.", fs::PathToString(path)));
1366 error =
Untranslated(
strprintf(
"Failed to create database path '%s'. Database already exists.", fs::PathToString(path)));
1373 error =
Untranslated(
strprintf(
"Failed to open database path '%s'. The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC or the GUI option).", fs::PathToString(path)));
1380 error =
Untranslated(
strprintf(
"Failed to load database path '%s'. Data is not in required format.", fs::PathToString(path)));
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
bool ParseHDKeypath(const std::string &keypath_str, std::vector< uint32_t > &keypath)
Parse an HD keypaths like "m/7/0'/2000".
catch(const std::exception &e)
#define STR_INTERNAL_BUG(msg)
#define Assume(val)
Assume is the identity function.
An encapsulated private key.
bool Load(const CPrivKey &privkey, const CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization).
Serialized script, used inside transaction inputs and outputs.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
RecursiveMutex cs_wallet
Main wallet lock.
Double ended buffer combining vector and stream-like interfaces.
Cache for single descriptor's derived extended pubkeys.
std::unordered_map< uint32_t, ExtPubKeyMap > GetCachedDerivedExtPubKeys() const
Retrieve all cached derived xpubs.
void CacheDerivedExtPubKey(uint32_t key_exp_pos, uint32_t der_index, const CExtPubKey &xpub)
Cache an xpub derived at an index.
ExtPubKeyMap GetCachedParentExtPubKeys() const
Retrieve all cached parent xpubs.
ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const
Retrieve all cached last hardened xpubs.
void CacheParentExtPubKey(uint32_t key_exp_pos, const CExtPubKey &xpub)
Cache a parent xpub.
void CacheLastHardenedExtPubKey(uint32_t key_exp_pos, const CExtPubKey &xpub)
Cache a last hardened xpub.
constexpr bool IsNull() const
const uint256 & ToUint256() const LIFETIMEBOUND
static constexpr int VERSION_HD_CHAIN_SPLIT
uint32_t nInternalChainCounter
uint32_t nExternalChainCounter
CKeyID seed_id
seed hash160
static constexpr int VERSION_HD_BASE
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
unsigned int nMasterKeyMaxID
LegacyDataSPKM * GetLegacyDataSPKM() const
Get the LegacyDataSPKM used for all legacy output types and both internal and external chains.
bool HaveCryptedKeys() const
LegacyDataSPKM * GetOrCreateLegacyDataSPKM()
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc, const KeyMap &keys, const CryptedKeyMap &ckeys)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
void WalletLogPrintf(util::ConstevalFormatString< sizeof...(Params)> wallet_fmt, const Params &... params) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
bool HasEncryptionKeys() const override
MasterKeyMap mapMasterKeys
RecursiveMutex cs_wallet
Main wallet lock.
A transaction with a bunch of additional info that only the owner cares about.
const Txid & GetHash() const LIFETIMEBOUND
const std::map< Wtxid, CTransactionRef > & GetTxs() const
RAII class that provides access to a WalletDatabase.
virtual std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(std::span< const std::byte > prefix)=0
virtual void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet).
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, bool checksum_valid)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet).
void AddInactiveHDChain(const CHDChain &chain)
const CHDChain & GetHDChain() const
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet).
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
virtual void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet).
void LoadHDChain(const CHDChain &chain)
Load a HD chain model (used by LoadWallet).
Access to the wallet database.
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
bool TxnAbort()
Abort current transaction.
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
bool EraseName(const std::string &strAddress)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteBestBlock(const CBlockLocator &locator)
void RegisterTxnListener(const DbTxnListener &l)
Registers db txn callback functions.
bool ReadBestBlock(CBlockLocator &locator)
bool WriteDescriptorCacheItems(const uint256 &desc_id, const DescriptorCache &cache)
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
std::vector< DbTxnListener > m_txn_listeners
bool WriteWalletFlags(uint64_t flags)
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
bool TxnBegin()
Begin a new transaction.
bool WriteAddressPreviouslySpent(const CTxDestination &dest, bool previously_spent)
bool EraseAddressReceiveRequest(const CTxDestination &dest, const std::string &id)
bool TxnCommit()
Commit current transaction.
bool WriteName(const std::string &strAddress, const std::string &strName)
bool WritePurpose(const std::string &strAddress, const std::string &purpose)
std::unique_ptr< DatabaseBatch > m_batch
bool EraseRecords(const std::unordered_set< std::string > &types)
Delete records of the given types.
bool WriteDescriptorLastHardenedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
bool WriteIC(const K &key, const T &value, bool fOverwrite=true)
bool EraseAddressData(const CTxDestination &dest)
bool WriteOrderPosNext(int64_t nOrderPosNext)
bool WriteFullTx(const CWalletTx &wtx)
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
bool EraseIC(const K &key)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool ErasePurpose(const std::string &strAddress)
bool EraseLockedUTXO(const COutPoint &output)
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
bool WriteTxMetadata(const CWalletTx &wtx)
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< unsigned char > &secret)
bool WriteLockedUTXO(const COutPoint &output)
bool EraseMasterKey(unsigned int id)
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
bool WriteWtxVariant(const Txid &txid, const CTransactionRef &tx)
bool WriteVersion(int client_version)
Write the given client_version to m_batch, indicating the last version of client software to load thi...
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, bool overwrite)
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
bool WriteAddressReceiveRequest(const CTxDestination &dest, const std::string &id, const std::string &receive_request)
An instance of this class represents one database.
Descriptor with some wallet metadata.
static WalletDescriptor FromStream(deserialize_type, Stream &s)
constexpr int CLIENT_VERSION
bool AbandonTransaction(const Txid &hashTx)
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
DBErrors ReorderTransactions()
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade DescriptorCaches.
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (SIZE bytes).
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
std::string EncodeDestination(const CTxDestination &dest)
#define LogDebug(category,...)
const std::string BESTBLOCK
const std::string WALLETDESCRIPTORCKEY
const std::string WALLETDESCRIPTORLHCACHE
const std::string MINVERSION
const std::string WATCHMETA
const std::string DEFAULTKEY
const std::string OLD_KEY
const std::string WALLETDESCRIPTORKEY
const std::string WTX_VARIANT
const std::string ACENTRY
const std::string ACTIVEEXTERNALSPK
const std::string CRYPTED_KEY
const std::string DESTDATA
const std::string CSCRIPT
const std::unordered_set< std::string > LEGACY_TYPES
const std::string SETTINGS
const std::string BESTBLOCK_NOMERKLE
const std::string LOCKED_UTXO
const std::string ACTIVEINTERNALSPK
const std::string HDCHAIN
const std::string ORDERPOSNEXT
const std::string VERSION
const std::string WALLETDESCRIPTORCACHE
const std::string MASTER_KEY
const std::string KEYMETA
const std::string PURPOSE
const std::string WALLETDESCRIPTOR
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
bool LoadKey(CWallet *pwallet, DataStream &ssKey, DataStream &ssValue, std::string &strErr)
static DataStream PrefixStream(const Args &... args)
static DBErrors LoadLegacyWalletRecords(CWallet *pwallet, DatabaseBatch &batch, int last_client) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static bool RunWithinTxn(WalletBatch &batch, std::string_view process_desc, const std::function< bool(WalletBatch &)> &func)
std::function< DBErrors(CWallet *pwallet, DataStream &key, DataStream &value, std::string &err)> LoadFunc
bool LoadCryptedKey(CWallet *pwallet, DataStream &ssKey, DataStream &ssValue, std::string &strErr)
std::unique_ptr< SQLiteDatabase > MakeSQLiteDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
fs::path SQLiteDataFile(const fs::path &path)
DBErrors
Overview of wallet database classes:
@ UNEXPECTED_LEGACY_ENTRY
@ EXTERNAL_SIGNER_SUPPORT_REQUIRED
static DBErrors LoadWalletFlags(CWallet *pwallet, DatabaseBatch &batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static DBErrors LoadActiveSPKMs(CWallet *pwallet, DatabaseBatch &batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static DBErrors LoadDecryptionKeys(CWallet *pwallet, DatabaseBatch &batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
bool LoadEncryptionKey(CWallet *pwallet, DataStream &ssKey, DataStream &ssValue, std::string &strErr)
bool HasLegacyRecords(CWallet &wallet)
Returns true if there are any DBKeys::LEGACY_TYPES record in the wallet db.
bool IsBDBFile(const fs::path &path)
fs::path BDBDataFile(const fs::path &wallet_path)
bool LoadHDChain(CWallet *pwallet, DataStream &ssValue, std::string &strErr)
static DBErrors LoadTxRecords(CWallet *pwallet, DatabaseBatch &batch, bool &any_unordered) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
std::map< CKeyID, CKey > KeyMap
static std::map< Wtxid, CTransactionRef > ReadWtxVariants(DatabaseBatch &batch, const Txid &txid)
std::unique_ptr< BerkeleyRODatabase > MakeBerkeleyRODatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
Return object giving access to Berkeley Read Only database at specified path.
std::string SQLiteDatabaseVersion()
bool IsSQLiteFile(const fs::path &path)
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
static DBErrors LoadAddressBookRecords(CWallet *pwallet, DatabaseBatch &batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static LoadResult LoadRecords(CWallet *pwallet, DatabaseBatch &batch, const std::string &key, DataStream &prefix, LoadFunc load_func)
static DBErrors LoadDescriptorWalletRecords(CWallet *pwallet, DatabaseBatch &batch, int last_client) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
std::map< CKeyID, std::pair< CPubKey, std::vector< unsigned char > > > CryptedKeyMap
constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
constexpr unsigned int BIP32_EXTKEY_SIZE
void SerializeMany(Stream &s, const Args &... args)
Support for (un)serializing many things at once.
constexpr deserialize_type deserialize
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::vector< uint256 > vHave
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE])
std::vector< uint32_t > path
std::optional< DatabaseFormat > require_format
#define AssertLockHeld(cs)
std::vector< uint16_t > keys
#define EXCLUSIVE_LOCKS_REQUIRED(...)
transaction_identifier< false > Txid
Txid commits to all transaction fields except the witness.
consteval auto _(util::TranslatedLiteral str)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.