diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-04-21 03:10:12 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2018-05-12 13:15:21 -0400 |
commit | dfcd9f3e6abf3d53903227a085ff4cfecbfeb07f (patch) | |
tree | 2dc6ed3933a155ee328932f820e4c1643a5eeda7 /src/wallet/wallet.h | |
parent | 5c50e93d52c14fc7bc41130cdb1568f2c11e45de (diff) |
Use a keypool of presplit keys after upgrading to hd chain split
After upgrading to HD chain split, we want to continue to use keys
from the old keypool. To do this, before we generate any new keys after
upgrading, we mark all of the keypool entries as being pre-chain
split and move them to a separate pre chain split keypool. Keys are
fetched from that keypool until it is emptied. Only then are the new
internal and external keypools used.
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r-- | src/wallet/wallet.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 215145a62b..d81f3ef206 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -119,6 +119,7 @@ public: int64_t nTime; CPubKey vchPubKey; bool fInternal; // for change outputs + bool m_pre_split; // For keys generated before keypool split upgrade CKeyPool(); CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn); @@ -141,9 +142,18 @@ public: (this will be the case for any wallet before the HD chain split version) */ 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 { READWRITE(fInternal); + READWRITE(m_pre_split); } } }; @@ -708,6 +718,7 @@ private: std::set<int64_t> setInternalKeyPool; std::set<int64_t> setExternalKeyPool; + std::set<int64_t> set_pre_split_keypool; int64_t m_max_keypool_index = 0; std::map<CKeyID, int64_t> m_pool_key_to_index; @@ -774,6 +785,7 @@ public: const std::string& GetName() const { return m_name; } void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool); + void MarkPreSplitKeys(); // Map from Key ID to key metadata. std::map<CKeyID, CKeyMetadata> mapKeyMetadata; |