Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.h
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/* simple HD chain data model */ | /* simple HD chain data model */ | ||||
class CHDChain { | class CHDChain { | ||||
public: | public: | ||||
uint32_t nExternalChainCounter; | uint32_t nExternalChainCounter; | ||||
uint32_t nInternalChainCounter; | uint32_t nInternalChainCounter; | ||||
//!< master key hash160 | //!< master key hash160 | ||||
CKeyID masterKeyID; | CKeyID seed_id; | ||||
static const int VERSION_HD_BASE = 1; | static const int VERSION_HD_BASE = 1; | ||||
static const int VERSION_HD_CHAIN_SPLIT = 2; | static const int VERSION_HD_CHAIN_SPLIT = 2; | ||||
static const int CURRENT_VERSION = VERSION_HD_CHAIN_SPLIT; | static const int CURRENT_VERSION = VERSION_HD_CHAIN_SPLIT; | ||||
int nVersion; | int nVersion; | ||||
CHDChain() { SetNull(); } | CHDChain() { SetNull(); } | ||||
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) { | ||||
READWRITE(this->nVersion); | READWRITE(this->nVersion); | ||||
READWRITE(nExternalChainCounter); | READWRITE(nExternalChainCounter); | ||||
READWRITE(masterKeyID); | READWRITE(seed_id); | ||||
if (this->nVersion >= VERSION_HD_CHAIN_SPLIT) { | if (this->nVersion >= VERSION_HD_CHAIN_SPLIT) { | ||||
READWRITE(nInternalChainCounter); | READWRITE(nInternalChainCounter); | ||||
} | } | ||||
} | } | ||||
void SetNull() { | void SetNull() { | ||||
nVersion = CHDChain::CURRENT_VERSION; | nVersion = CHDChain::CURRENT_VERSION; | ||||
nExternalChainCounter = 0; | nExternalChainCounter = 0; | ||||
nInternalChainCounter = 0; | nInternalChainCounter = 0; | ||||
masterKeyID.SetNull(); | seed_id.SetNull(); | ||||
} | } | ||||
}; | }; | ||||
class CKeyMetadata { | class CKeyMetadata { | ||||
public: | public: | ||||
static const int VERSION_BASIC = 1; | static const int VERSION_BASIC = 1; | ||||
static const int VERSION_WITH_HDDATA = 10; | static const int VERSION_WITH_HDDATA = 10; | ||||
static const int CURRENT_VERSION = VERSION_WITH_HDDATA; | static const int CURRENT_VERSION = VERSION_WITH_HDDATA; | ||||
int nVersion; | int nVersion; | ||||
// 0 means unknown. | // 0 means unknown. | ||||
int64_t nCreateTime; | int64_t nCreateTime; | ||||
// optional HD/bip32 keypath. | // optional HD/bip32 keypath. | ||||
std::string hdKeypath; | std::string hdKeypath; | ||||
// Id of the HD masterkey used to derive this key. | // Id of the HD masterkey used to derive this key. | ||||
CKeyID hdMasterKeyID; | CKeyID hd_seed_id; | ||||
CKeyMetadata() { SetNull(); } | CKeyMetadata() { SetNull(); } | ||||
explicit CKeyMetadata(int64_t nCreateTime_) { | explicit CKeyMetadata(int64_t nCreateTime_) { | ||||
SetNull(); | SetNull(); | ||||
nCreateTime = nCreateTime_; | nCreateTime = nCreateTime_; | ||||
} | } | ||||
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) { | ||||
READWRITE(this->nVersion); | READWRITE(this->nVersion); | ||||
READWRITE(nCreateTime); | READWRITE(nCreateTime); | ||||
if (this->nVersion >= VERSION_WITH_HDDATA) { | if (this->nVersion >= VERSION_WITH_HDDATA) { | ||||
READWRITE(hdKeypath); | READWRITE(hdKeypath); | ||||
READWRITE(hdMasterKeyID); | READWRITE(hd_seed_id); | ||||
} | } | ||||
} | } | ||||
void SetNull() { | void SetNull() { | ||||
nVersion = CKeyMetadata::CURRENT_VERSION; | nVersion = CKeyMetadata::CURRENT_VERSION; | ||||
nCreateTime = 0; | nCreateTime = 0; | ||||
hdKeypath.clear(); | hdKeypath.clear(); | ||||
hdMasterKeyID.SetNull(); | hd_seed_id.SetNull(); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Access to the wallet database. | * Access to the wallet database. | ||||
* This represents a single transaction at the database. It will be committed | * This represents a single transaction at the database. It will be committed | ||||
* when the object goes out of scope. Optionally (on by default) it will flush | * when the object goes out of scope. Optionally (on by default) it will flush | ||||
* to disk as well. | * to disk as well. | ||||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |