Skip to content

Commit afcd77e

Browse files
committed
Detect -usehd mismatches when wallet.dat already exists
1 parent 17c0131 commit afcd77e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,13 @@ bool CWallet::InitLoadWallet()
32363236

32373237
walletInstance->SetBestChain(chainActive.GetLocator());
32383238
}
3239+
else if (mapArgs.count("-usehd")) {
3240+
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
3241+
if (!walletInstance->hdChain.masterKeyID.IsNull() && !useHD)
3242+
return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), walletFile));
3243+
if (walletInstance->hdChain.masterKeyID.IsNull() && useHD)
3244+
return InitError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), walletFile));
3245+
}
32393246

32403247
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
32413248

0 commit comments

Comments
 (0)