File tree Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Expand file tree Collapse file tree 2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -621,12 +621,9 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
621
621
622
622
// if we are using HD, replace the HD master key (seed) with a new one
623
623
if (IsHDEnabled ()) {
624
- CKey key;
625
- CPubKey masterPubKey = GenerateNewHDMasterKey ();
626
- // preserve the old chains version to not break backward compatibility
627
- CHDChain oldChain = GetHDChain ();
628
- if (!SetHDMasterKey (masterPubKey, &oldChain))
624
+ if (!SetHDMasterKey (GenerateNewHDMasterKey ())) {
629
625
return false ;
626
+ }
630
627
}
631
628
632
629
NewKeyPool ();
@@ -1324,17 +1321,14 @@ CPubKey CWallet::GenerateNewHDMasterKey()
1324
1321
return pubkey;
1325
1322
}
1326
1323
1327
- bool CWallet::SetHDMasterKey (const CPubKey& pubkey, CHDChain *possibleOldChain )
1324
+ bool CWallet::SetHDMasterKey (const CPubKey& pubkey)
1328
1325
{
1329
1326
LOCK (cs_wallet);
1330
1327
// store the keyid (hash160) together with
1331
1328
// the child index counter in the database
1332
1329
// as a hdchain object
1333
1330
CHDChain newHdChain;
1334
- if (possibleOldChain) {
1335
- // preserve the old chains version
1336
- newHdChain.nVersion = possibleOldChain->nVersion ;
1337
- }
1331
+ newHdChain.nVersion = CanSupportFeature (FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE;
1338
1332
newHdChain.masterKeyID = pubkey.GetID ();
1339
1333
SetHDChain (newHdChain, false );
1340
1334
Original file line number Diff line number Diff line change @@ -1100,9 +1100,10 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
1100
1100
CPubKey GenerateNewHDMasterKey ();
1101
1101
1102
1102
/* Set the current HD master key (will reset the chain child index counters)
1103
- If possibleOldChain is provided, the parameters from the old chain (version)
1104
- will be preserved. */
1105
- bool SetHDMasterKey (const CPubKey& key, CHDChain *possibleOldChain = nullptr );
1103
+ Sets the master key's version based on the current wallet version (so the
1104
+ caller must ensure the current wallet version is correct before calling
1105
+ this function). */
1106
+ bool SetHDMasterKey (const CPubKey& key);
1106
1107
};
1107
1108
1108
1109
/* * A key allocated from the key pool. */
You can’t perform that action at this time.
0 commit comments