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 @@ -637,12 +637,9 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
637
637
638
638
// if we are using HD, replace the HD master key (seed) with a new one
639
639
if (IsHDEnabled ()) {
640
- CKey key;
641
- CPubKey masterPubKey = GenerateNewHDMasterKey ();
642
- // preserve the old chains version to not break backward compatibility
643
- CHDChain oldChain = GetHDChain ();
644
- if (!SetHDMasterKey (masterPubKey, &oldChain))
640
+ if (!SetHDMasterKey (GenerateNewHDMasterKey ())) {
645
641
return false ;
642
+ }
646
643
}
647
644
648
645
NewKeyPool ();
@@ -1308,17 +1305,14 @@ CPubKey CWallet::GenerateNewHDMasterKey()
1308
1305
return pubkey;
1309
1306
}
1310
1307
1311
- bool CWallet::SetHDMasterKey (const CPubKey& pubkey, CHDChain *possibleOldChain )
1308
+ bool CWallet::SetHDMasterKey (const CPubKey& pubkey)
1312
1309
{
1313
1310
LOCK (cs_wallet);
1314
1311
// store the keyid (hash160) together with
1315
1312
// the child index counter in the database
1316
1313
// as a hdchain object
1317
1314
CHDChain newHdChain;
1318
- if (possibleOldChain) {
1319
- // preserve the old chains version
1320
- newHdChain.nVersion = possibleOldChain->nVersion ;
1321
- }
1315
+ newHdChain.nVersion = CanSupportFeature (FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE;
1322
1316
newHdChain.masterKeyID = pubkey.GetID ();
1323
1317
SetHDChain (newHdChain, false );
1324
1318
Original file line number Diff line number Diff line change @@ -1056,9 +1056,10 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
1056
1056
CPubKey GenerateNewHDMasterKey ();
1057
1057
1058
1058
/* Set the current HD master key (will reset the chain child index counters)
1059
- If possibleOldChain is provided, the parameters from the old chain (version)
1060
- will be preserved. */
1061
- bool SetHDMasterKey (const CPubKey& key, CHDChain *possibleOldChain = nullptr );
1059
+ Sets the master key's version based on the current wallet version (so the
1060
+ caller must ensure the current wallet version is correct before calling
1061
+ this function). */
1062
+ bool SetHDMasterKey (const CPubKey& key);
1062
1063
};
1063
1064
1064
1065
/* * A key allocated from the key pool. */
You can’t perform that action at this time.
0 commit comments