mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
HDWallet fixes after moving wallet initialization
This commit is contained in:
parent
b3525b2e67
commit
332fbfc0e3
@ -4464,11 +4464,13 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
|
|||||||
// Create new keyUser and set as default key
|
// Create new keyUser and set as default key
|
||||||
RandAddSeedPerfmon();
|
RandAddSeedPerfmon();
|
||||||
|
|
||||||
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !pwalletMain->IsHDEnabled()) {
|
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) {
|
||||||
if (GetArg("-mnemonicpassphrase", "").size() > 256)
|
if (GetArg("-mnemonicpassphrase", "").size() > 256) {
|
||||||
return InitError(_("Mnemonic passphrase is too long, must be at most 256 characters"));
|
errorString += _("Mnemonic passphrase is too long, must be at most 256 characters");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
// generate a new master key
|
// generate a new master key
|
||||||
pwalletMain->GenerateNewHDChain();
|
walletInstance->GenerateNewHDChain();
|
||||||
|
|
||||||
// ensure this wallet.dat can only be opened by clients supporting HD
|
// ensure this wallet.dat can only be opened by clients supporting HD
|
||||||
pwalletMain->SetMinVersion(FEATURE_HD);
|
pwalletMain->SetMinVersion(FEATURE_HD);
|
||||||
@ -4489,25 +4491,38 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
|
|||||||
// Try to create wallet backup right after new wallet was created
|
// Try to create wallet backup right after new wallet was created
|
||||||
std::string strBackupWarning;
|
std::string strBackupWarning;
|
||||||
std::string strBackupError;
|
std::string strBackupError;
|
||||||
if(!AutoBackupWallet(pwalletMain, "", strBackupWarning, strBackupError)) {
|
if(!AutoBackupWallet(walletInstance, "", strBackupWarning, strBackupError)) {
|
||||||
if (!strBackupWarning.empty())
|
if (!strBackupWarning.empty()) {
|
||||||
InitWarning(strBackupWarning);
|
if (!warningString.empty())
|
||||||
if (!strBackupError.empty())
|
warningString += "\n";
|
||||||
return InitError(strBackupError);
|
warningString += strBackupWarning;
|
||||||
|
}
|
||||||
|
if (!strBackupError.empty()) {
|
||||||
|
errorString += strBackupError;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mapArgs.count("-usehd")) {
|
else if (mapArgs.count("-usehd")) {
|
||||||
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
|
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
|
||||||
if (pwalletMain->IsHDEnabled() && !useHD)
|
if (walletInstance->IsHDEnabled() && !useHD) {
|
||||||
return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), strWalletFile));
|
errorString += strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"),
|
||||||
if (!pwalletMain->IsHDEnabled() && useHD)
|
strWalletFile);
|
||||||
return InitError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), strWalletFile));
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!walletInstance->IsHDEnabled() && useHD) {
|
||||||
|
errorString += strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"),
|
||||||
|
strWalletFile);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn user every time he starts non-encrypted HD wallet
|
// Warn user every time he starts non-encrypted HD wallet
|
||||||
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !pwalletMain->IsLocked()) {
|
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsLocked()) {
|
||||||
InitWarning(_("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!"));
|
if (!warningString.empty())
|
||||||
|
warningString += "\n";
|
||||||
|
warningString += _("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
|
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
|
||||||
|
Loading…
Reference in New Issue
Block a user