Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
//! Default for -changetype | //! Default for -changetype | ||||
constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO}; | constexpr OutputType DEFAULT_CHANGE_TYPE{OutputType::CHANGE_AUTO}; | ||||
enum WalletFlags : uint64_t { | enum WalletFlags : uint64_t { | ||||
// Wallet flags in the upper section (> 1 << 31) will lead to not opening | // Wallet flags in the upper section (> 1 << 31) will lead to not opening | ||||
// the wallet if flag is unknown. | // the wallet if flag is unknown. | ||||
// Unknown wallet flags in the lower section <= (1 << 31) will be tolerated. | // Unknown wallet flags in the lower section <= (1 << 31) will be tolerated. | ||||
// Indicates that the metadata has already been upgraded to contain key | |||||
// origins | |||||
WALLET_FLAG_KEY_ORIGIN_METADATA = (1ULL << 1), | |||||
// Will enforce the rule that the wallet can't contain any private keys | // Will enforce the rule that the wallet can't contain any private keys | ||||
// (only watch-only/pubkeys). | // (only watch-only/pubkeys). | ||||
WALLET_FLAG_DISABLE_PRIVATE_KEYS = (1ULL << 32), | WALLET_FLAG_DISABLE_PRIVATE_KEYS = (1ULL << 32), | ||||
//! Flag set when a wallet contains no HD seed and no private keys, scripts, | //! Flag set when a wallet contains no HD seed and no private keys, scripts, | ||||
//! addresses, and other watch only things, and is therefore "blank." | //! addresses, and other watch only things, and is therefore "blank." | ||||
//! | //! | ||||
//! The only function this flag serves is to distinguish a blank wallet from | //! The only function this flag serves is to distinguish a blank wallet from | ||||
//! a newly created wallet when the wallet database is loaded, to avoid | //! a newly created wallet when the wallet database is loaded, to avoid | ||||
//! initialization that should only happen on first run. | //! initialization that should only happen on first run. | ||||
//! | //! | ||||
//! This flag is also a mandatory flag to prevent previous versions of | //! This flag is also a mandatory flag to prevent previous versions of | ||||
//! bitcoin from opening the wallet, thinking it was newly created, and | //! bitcoin from opening the wallet, thinking it was newly created, and | ||||
//! then improperly reinitializing it. | //! then improperly reinitializing it. | ||||
WALLET_FLAG_BLANK_WALLET = (1ULL << 33), | WALLET_FLAG_BLANK_WALLET = (1ULL << 33), | ||||
}; | }; | ||||
static constexpr uint64_t g_known_wallet_flags = | static constexpr uint64_t g_known_wallet_flags = | ||||
WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET; | WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET | | ||||
WALLET_FLAG_KEY_ORIGIN_METADATA; | |||||
/** A key pool entry */ | /** A key pool entry */ | ||||
class CKeyPool { | class CKeyPool { | ||||
public: | public: | ||||
int64_t nTime; | int64_t nTime; | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
// for change outputs | // for change outputs | ||||
bool fInternal; | bool fInternal; | ||||
▲ Show 20 Lines • Show All 818 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
//! Load metadata (used by LoadWallet) | //! Load metadata (used by LoadWallet) | ||||
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata) | void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
void LoadScriptMetadata(const CScriptID &script_id, | void LoadScriptMetadata(const CScriptID &script_id, | ||||
const CKeyMetadata &metadata) | const CKeyMetadata &metadata) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
//! Upgrade stored CKeyMetadata objects to store key origin info as | |||||
//! KeyOriginInfo | |||||
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | |||||
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { | bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
nWalletVersion = nVersion; | nWalletVersion = nVersion; | ||||
nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); | nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); | ||||
return true; | return true; | ||||
} | } | ||||
void UpdateTimeFirstKey(int64_t nCreateTime) | void UpdateTimeFirstKey(int64_t nCreateTime) | ||||
▲ Show 20 Lines • Show All 534 Lines • Show Last 20 Lines |