Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 4,269 Lines • ▼ Show 20 Lines | if (gArgs.GetBoolArg("-upgradewallet", fFirstRun)) { | ||||
InitError(_("Cannot downgrade wallet")); | InitError(_("Cannot downgrade wallet")); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
walletInstance->SetMaxVersion(nMaxVersion); | walletInstance->SetMaxVersion(nMaxVersion); | ||||
} | } | ||||
if (fFirstRun) { | if (fFirstRun) { | ||||
// Create new keyUser and set as default key. | |||||
if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && | |||||
!walletInstance->IsHDEnabled()) { | |||||
// 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. | // HD with chain split and expects no default key. | ||||
walletInstance->SetMinVersion(FEATURE_HD_SPLIT); | walletInstance->SetMinVersion(FEATURE_NO_DEFAULT_KEY); | ||||
// Generate a new master key. | // Generate a new master key. | ||||
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); | CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); | ||||
if (!walletInstance->SetHDMasterKey(masterPubKey)) { | if (!walletInstance->SetHDMasterKey(masterPubKey)) { | ||||
throw std::runtime_error(std::string(__func__) + | throw std::runtime_error(std::string(__func__) + | ||||
": Storing master key failed"); | ": Storing master key failed"); | ||||
} | } | ||||
} | |||||
// Top up the keypool | // Top up the keypool | ||||
if (!walletInstance->TopUpKeyPool()) { | if (!walletInstance->TopUpKeyPool()) { | ||||
InitError(_("Unable to generate initial keys") += "\n"); | InitError(_("Unable to generate initial keys") += "\n"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
walletInstance->ChainStateFlushed(chainActive.GetLocator()); | walletInstance->ChainStateFlushed(chainActive.GetLocator()); | ||||
} else if (gArgs.IsArgSet("-usehd")) { | } else if (gArgs.IsArgSet("-usehd")) { | ||||
bool useHD = gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET); | bool useHD = gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET); | ||||
if (walletInstance->IsHDEnabled() && !useHD) { | if (walletInstance->IsHDEnabled() && !useHD) { | ||||
InitError( | InitError( | ||||
strprintf(_("Error loading %s: You can't disable HD on an " | strprintf(_("Error loading %s: You can't disable HD on an " | ||||
"already existing HD wallet"), | "already existing HD wallet"), | ||||
walletFile)); | walletFile)); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
if (!walletInstance->IsHDEnabled() && useHD) { | if (!walletInstance->IsHDEnabled() && useHD) { | ||||
InitError(strprintf(_("Error loading %s: You can't enable HD on an " | InitError(strprintf(_("Error loading %s: You can't enable HD on an " | ||||
"already existing non-HD wallet"), | "already existing non-HD wallet or create " | ||||
"new non-HD wallets."), | |||||
walletFile)); | walletFile)); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
} | } | ||||
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart); | LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart); | ||||
// Try to top up keypool. No-op if the wallet is locked. | // Try to top up keypool. No-op if the wallet is locked. | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |