Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | enum WalletFeature { | ||||
FEATURE_HD = 130000, | FEATURE_HD = 130000, | ||||
// Wallet with HD chain split (change outputs will use m/0'/1'/k) | // Wallet with HD chain split (change outputs will use m/0'/1'/k) | ||||
FEATURE_HD_SPLIT = 160300, | FEATURE_HD_SPLIT = 160300, | ||||
// Wallet without a default key written | // Wallet without a default key written | ||||
FEATURE_NO_DEFAULT_KEY = 190700, | FEATURE_NO_DEFAULT_KEY = 190700, | ||||
// HD is optional, use FEATURE_COMPRPUBKEY as latest version | FEATURE_LATEST = FEATURE_NO_DEFAULT_KEY | ||||
FEATURE_LATEST = FEATURE_COMPRPUBKEY, | |||||
}; | }; | ||||
enum class OutputType { | enum class OutputType { | ||||
NONE, | NONE, | ||||
LEGACY, | LEGACY, | ||||
}; | }; | ||||
//! Default for -addresstype | //! Default for -addresstype | ||||
constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::LEGACY}; | constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::LEGACY}; | ||||
/** A key pool entry */ | /** A key pool entry */ | ||||
class CKeyPool { | class CKeyPool { | ||||
public: | public: | ||||
int64_t nTime; | int64_t nTime; | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
bool fInternal; // for change outputs | // for change outputs | ||||
bool fInternal; | |||||
// For keys generated before keypool split upgrade | |||||
bool m_pre_split; | |||||
CKeyPool(); | CKeyPool(); | ||||
CKeyPool(const CPubKey &vchPubKeyIn, bool internalIn); | CKeyPool(const CPubKey &vchPubKeyIn, bool internalIn); | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
Show All 10 Lines | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
} catch (std::ios_base::failure &) { | } catch (std::ios_base::failure &) { | ||||
/** | /** | ||||
* flag as external address if we can't read the internal | * flag as external address if we can't read the internal | ||||
* boolean (this will be the case for any wallet before the HD | * boolean (this will be the case for any wallet before the HD | ||||
* chain split version) | * chain split version) | ||||
*/ | */ | ||||
fInternal = false; | fInternal = false; | ||||
} | } | ||||
try { | |||||
READWRITE(m_pre_split); | |||||
} catch (std::ios_base::failure &) { | |||||
/** | |||||
* flag as postsplit address if we can't read the m_pre_split | |||||
* boolean (this will be the case for any wallet that upgrades | |||||
* to HD chain split) | |||||
*/ | |||||
m_pre_split = false; | |||||
} | |||||
} else { | } else { | ||||
READWRITE(fInternal); | READWRITE(fInternal); | ||||
READWRITE(m_pre_split); | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** Address book data */ | /** Address book data */ | ||||
class CAddressBookData { | class CAddressBookData { | ||||
public: | public: | ||||
std::string name; | std::string name; | ||||
▲ Show 20 Lines • Show All 575 Lines • ▼ Show 20 Lines | private: | ||||
/* HD derive new child key (on internal or external chain) */ | /* HD derive new child key (on internal or external chain) */ | ||||
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, | void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, | ||||
CKey &secret, bool internal = false) | CKey &secret, bool internal = false) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
std::set<int64_t> setInternalKeyPool; | std::set<int64_t> setInternalKeyPool; | ||||
std::set<int64_t> setExternalKeyPool; | std::set<int64_t> setExternalKeyPool; | ||||
std::set<int64_t> set_pre_split_keypool; | |||||
int64_t m_max_keypool_index = 0; | int64_t m_max_keypool_index = 0; | ||||
std::map<CKeyID, int64_t> m_pool_key_to_index; | std::map<CKeyID, int64_t> m_pool_key_to_index; | ||||
int64_t nTimeFirstKey = 0; | int64_t nTimeFirstKey = 0; | ||||
/** | /** | ||||
* Private version of AddWatchOnly method which does not accept a timestamp, | * Private version of AddWatchOnly method which does not accept a timestamp, | ||||
* and which will reset the wallet's nTimeFirstKey value to 1 if the watch | * and which will reset the wallet's nTimeFirstKey value to 1 if the watch | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Get a name for this wallet for logging/debugging purposes. | * Get a name for this wallet for logging/debugging purposes. | ||||
*/ | */ | ||||
std::string GetName() const { return m_name; } | std::string GetName() const { return m_name; } | ||||
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) | void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
void MarkPreSplitKeys(); | |||||
// Map from Key ID to key metadata. | // Map from Key ID to key metadata. | ||||
std::map<CKeyID, CKeyMetadata> mapKeyMetadata; | std::map<CKeyID, CKeyMetadata> mapKeyMetadata; | ||||
// Map from Script ID to key metadata (for watch-only keys). | // Map from Script ID to key metadata (for watch-only keys). | ||||
std::map<CScriptID, CKeyMetadata> m_script_metadata; | std::map<CScriptID, CKeyMetadata> m_script_metadata; | ||||
typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | typedef std::map<unsigned int, CMasterKey> MasterKeyMap; | ||||
▲ Show 20 Lines • Show All 610 Lines • Show Last 20 Lines |