diff options
author | Jonas Schnelli <dev@jonasschnelli.ch> | 2017-03-27 09:51:55 +0200 |
---|---|---|
committer | Jonas Schnelli <dev@jonasschnelli.ch> | 2017-03-27 09:51:55 +0200 |
commit | 9382f0425e87b30e4621e0e23a99d6e880ec2200 (patch) | |
tree | 6be2142f3b28b2918962928f09c2572e3abcd150 /src/wallet/wallet.cpp | |
parent | 1df08d1580fbab9e58017cf6c1ecb73550bf6ed7 (diff) |
Do not break backward compatibility during wallet encryption
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4e625f64d1..a998179584 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -639,7 +639,9 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) if (IsHDEnabled()) { CKey key; CPubKey masterPubKey = GenerateNewHDMasterKey(); - if (!SetHDMasterKey(masterPubKey)) + // preserve the old chains version to not break backward compatibility + CHDChain oldChain = GetHDChain(); + if (!SetHDMasterKey(masterPubKey, &oldChain)) return false; } @@ -1306,13 +1308,17 @@ CPubKey CWallet::GenerateNewHDMasterKey() return pubkey; } -bool CWallet::SetHDMasterKey(const CPubKey& pubkey) +bool CWallet::SetHDMasterKey(const CPubKey& pubkey, CHDChain *possibleOldChain) { LOCK(cs_wallet); // store the keyid (hash160) together with // the child index counter in the database // as a hdchain object CHDChain newHdChain; + if (possibleOldChain) { + // preserve the old chains version + newHdChain.nVersion = possibleOldChain->nVersion; + } newHdChain.masterKeyID = pubkey.GetID(); SetHDChain(newHdChain, false); |