Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 4,040 Lines • ▼ Show 20 Lines | if (gArgs.GetBoolArg("-upgradewallet", false)) { | ||||
error = | error = | ||||
_("Cannot upgrade a non HD split wallet without upgrading to " | _("Cannot upgrade a non HD split wallet without upgrading to " | ||||
"support pre split keypool. Please use -upgradewallet=200300 " | "support pre split keypool. Please use -upgradewallet=200300 " | ||||
"or -upgradewallet with no version specified.") | "or -upgradewallet with no version specified.") | ||||
.translated; | .translated; | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
bool hd_upgrade = false; | if (auto spk_man = walletInstance->m_spk_man.get()) { | ||||
bool split_upgrade = false; | if (!spk_man->Upgrade(prev_version, error)) { | ||||
if (walletInstance->CanSupportFeature(FEATURE_HD) && | chain.initError(error); | ||||
!walletInstance->m_spk_man->IsHDEnabled()) { | |||||
walletInstance->WalletLogPrintf("Upgrading wallet to HD\n"); | |||||
walletInstance->SetMinVersion(FEATURE_HD); | |||||
// generate a new master key | |||||
CPubKey masterPubKey = walletInstance->m_spk_man->GenerateNewSeed(); | |||||
walletInstance->m_spk_man->SetHDSeed(masterPubKey); | |||||
hd_upgrade = true; | |||||
} | |||||
// Upgrade to HD chain split if necessary | |||||
if (walletInstance->CanSupportFeature(FEATURE_HD_SPLIT)) { | |||||
walletInstance->WalletLogPrintf( | |||||
"Upgrading wallet to use HD chain split\n"); | |||||
walletInstance->SetMinVersion(FEATURE_PRE_SPLIT_KEYPOOL); | |||||
split_upgrade = FEATURE_HD_SPLIT > prev_version; | |||||
} | |||||
// Mark all keys currently in the keypool as pre-split | |||||
if (split_upgrade) { | |||||
walletInstance->MarkPreSplitKeys(); | |||||
} | |||||
// Regenerate the keypool if upgraded to HD | |||||
if (hd_upgrade) { | |||||
if (!walletInstance->m_spk_man->TopUp()) { | |||||
error = _("Unable to generate keys").translated; | |||||
return nullptr; | return nullptr; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (fFirstRun) { | if (fFirstRun) { | ||||
// Ensure this wallet.dat can only be opened by clients supporting | // Ensure this wallet.dat can only be opened by clients supporting | ||||
// HD with chain split and expects no default key. | // HD with chain split and expects no default key. | ||||
▲ Show 20 Lines • Show All 422 Lines • Show Last 20 Lines |