diff options
| author | Jonas Schnelli <[email protected]> | 2016-01-02 12:34:08 +0100 |
|---|---|---|
| committer | Jonas Schnelli <[email protected]> | 2016-05-31 14:47:00 +0200 |
| commit | f19025106de47a92396f9fb98e6d3bbc568c40b5 (patch) | |
| tree | 54d64f8e6aad10ec6866e5f25cad88d65dd3b4ab /src/wallet/walletdb.h | |
| parent | Merge #7891: Always require OS randomness when generating secret keys (diff) | |
| download | discoin-f19025106de47a92396f9fb98e6d3bbc568c40b5.tar.xz discoin-f19025106de47a92396f9fb98e6d3bbc568c40b5.zip | |
[Wallet] Add simplest BIP32/deterministic key generation implementation
Diffstat (limited to 'src/wallet/walletdb.h')
| -rw-r--r-- | src/wallet/walletdb.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 00c10ea70..71b0ff26d 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -40,6 +40,35 @@ enum DBErrors DB_NEED_REWRITE }; +/* simple hd chain data model */ +class CHDChain +{ +public: + uint32_t nExternalChainCounter; + CKeyID masterKeyID; //!< master key hash160 + + static const int CURRENT_VERSION = 1; + int nVersion; + + CHDChain() { SetNull(); } + ADD_SERIALIZE_METHODS; + template <typename Stream, typename Operation> + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(nExternalChainCounter); + READWRITE(masterKeyID); + } + + void SetNull() + { + nVersion = CHDChain::CURRENT_VERSION; + nExternalChainCounter = 0; + masterKeyID.SetNull(); + } +}; + class CKeyMetadata { public: @@ -134,6 +163,9 @@ public: static bool Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKeys); static bool Recover(CDBEnv& dbenv, const std::string& filename); + //! write the hdchain model (external chain child index counter) + bool WriteHDChain(const CHDChain& chain); + private: CWalletDB(const CWalletDB&); void operator=(const CWalletDB&); |