Ensure previous clients can't open HD wallets

This commit is contained in:
janko33bd
2017-09-02 19:57:05 +01:00
parent 5b49f32c85
commit 87698fe7ce
2 changed files with 10 additions and 5 deletions

View File

@@ -1541,11 +1541,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Create new keyUser and set as default key
if (GetBoolArg("-usehd", true)) {
// generate a new master key
CKey key;
key.MakeNewKey(true);
if (!pwalletMain->SetHDMasterKey(key))
throw std::runtime_error("CWallet::GenerateNewKey(): Storing master key failed");
// generate a new master key
CKey key;
key.MakeNewKey(true);
if (!pwalletMain->SetHDMasterKey(key))
throw std::runtime_error("CWallet::GenerateNewKey(): Storing master key failed");
// ensure this wallet.dat can only be opened by clients supporting HD
pwalletMain->SetMinVersion(FEATURE_HD);
}
CPubKey newDefaultKey;
if (pwalletMain->GetKeyFromPool(newDefaultKey)) {

View File

@@ -82,6 +82,9 @@ enum WalletFeature
FEATURE_COMPRPUBKEY = 60000, // compressed public keys
FEATURE_LATEST = 60000
FEATURE_HD = 330000, // Hierarchical key derivation after BIP32 (HD Wallet)
FEATURE_LATEST = FEATURE_COMPRPUBKEY // HD is optional, use FEATURE_COMPRPUBKEY as latest version
};