From 87698fe7ce5130e630443551c2bedd30655ced63 Mon Sep 17 00:00:00 2001 From: janko33bd Date: Sat, 2 Sep 2017 19:57:05 +0100 Subject: [PATCH] Ensure previous clients can't open HD wallets --- src/init.cpp | 12 +++++++----- src/wallet/wallet.h | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 0171a1453..63c02ef4a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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)) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9f0382cf6..0f573bca3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -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 };