Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 4,278 Lines • ▼ Show 20 Lines | if (gArgs.GetBoolArg("-upgradewallet", fFirstRun)) { | ||||
} | } | ||||
walletInstance->SetMaxVersion(nMaxVersion); | walletInstance->SetMaxVersion(nMaxVersion); | ||||
} | } | ||||
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. | ||||
if (!gArgs.GetBoolArg("-usehd", true)) { | |||||
InitError(strprintf(_("Error creating %s: You can't create non-HD " | |||||
"wallets with this version."), | |||||
walletFile)); | |||||
return nullptr; | |||||
} | |||||
walletInstance->SetMinVersion(FEATURE_NO_DEFAULT_KEY); | 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", true); | ||||
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 or create " | "already existing non-HD wallet"), | ||||
"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 245 Lines • Show Last 20 Lines |