diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-05-03 09:10:59 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-05-03 09:11:45 +0200 |
| commit | d3dce0eb67e8691745be6cf7e04b920f5e419bd9 (patch) | |
| tree | 24cc063761eb68289261949f5d9bafb770dd1947 /src/wallet/wallet.cpp | |
| parent | Merge #10307: [tests] allow zmq test to be run in out-of-tree builds (diff) | |
| parent | Avoid reading the old hd master key during wallet encryption (diff) | |
| download | discoin-d3dce0eb67e8691745be6cf7e04b920f5e419bd9.tar.xz discoin-d3dce0eb67e8691745be6cf7e04b920f5e419bd9.zip | |
Merge #10115: Avoid reading the old hd master key during wallet encryption
185c7f0 Avoid reading the old hd master key during wallet encryption (Matt Corallo)
Tree-SHA512: b744e8490c0e948355bb77b2695902bb99f89a68af46aa2be9120bd2ccf3c340eb8a56340fec117f9a935192298028945c9b18120ee6b8b23e7da8ffdb635745
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a8f818a49..fa82c9c9d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -621,12 +621,9 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) // if we are using HD, replace the HD master key (seed) with a new one if (IsHDEnabled()) { - CKey key; - CPubKey masterPubKey = GenerateNewHDMasterKey(); - // preserve the old chains version to not break backward compatibility - CHDChain oldChain = GetHDChain(); - if (!SetHDMasterKey(masterPubKey, &oldChain)) + if (!SetHDMasterKey(GenerateNewHDMasterKey())) { return false; + } } NewKeyPool(); @@ -1324,17 +1321,14 @@ CPubKey CWallet::GenerateNewHDMasterKey() return pubkey; } -bool CWallet::SetHDMasterKey(const CPubKey& pubkey, CHDChain *possibleOldChain) +bool CWallet::SetHDMasterKey(const CPubKey& pubkey) { 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.nVersion = CanSupportFeature(FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE; newHdChain.masterKeyID = pubkey.GetID(); SetHDChain(newHdChain, false); |