aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-04-27 23:32:59 -0400
committerAndrew Chow <achow101-github@achow101.com>2018-05-12 13:15:21 -0400
commita8da482a8bc87ff26194612727d4a7b86b2fb60d (patch)
tree658a9e0b5c3dcd44742507d748e749a0859ca2bd /src/wallet/wallet.cpp
parentdfcd9f3e6abf3d53903227a085ff4cfecbfeb07f (diff)
Bump wallet version for pre split keypool
Bump the wallet version to indicate support for the pre split keypool. Also prevents any wallets from upgrading to versions between HD_SPLIT and PRE_SPLIT_KEYPOOL.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 26eb7198f2..74f79a011f 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -4060,6 +4060,14 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
// Upgrade to HD if explicit upgrade
if (gArgs.GetBoolArg("-upgradewallet", false)) {
LOCK(walletInstance->cs_wallet);
+
+ // Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
+ int max_version = walletInstance->nWalletVersion;
+ if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >=FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
+ InitError(_("Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use -upgradewallet=169900 or -upgradewallet with no version specified."));
+ return nullptr;
+ }
+
bool hd_upgrade = false;
bool split_upgrade = false;
if (walletInstance->CanSupportFeature(FEATURE_HD) && !walletInstance->IsHDEnabled()) {
@@ -4076,7 +4084,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
// Upgrade to HD chain split if necessary
if (walletInstance->CanSupportFeature(FEATURE_HD_SPLIT)) {
LogPrintf("Upgrading wallet to use HD chain split\n");
- walletInstance->SetMinVersion(FEATURE_HD_SPLIT);
+ walletInstance->SetMinVersion(FEATURE_PRE_SPLIT_KEYPOOL);
split_upgrade = FEATURE_HD_SPLIT > prev_version;
}
// Mark all keys currently in the keypool as pre-split