From 9dbda86cb1f092fc0b0e964d74cf88c47f75bf44 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 15 Sep 2017 12:48:40 +0200 Subject: [PATCH] HDWallet error/warning message fixes --- src/init.cpp | 1 + src/wallet/wallet.cpp | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f72dc33fa..7a137647f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1115,6 +1115,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #ifdef ENABLE_WALLET if (!CWallet::ParameterInteraction()) return false; + std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); #endif // ENABLE_WALLET fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c7da743c6..aaa7f966a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4524,8 +4524,7 @@ bool CWallet::InitLoadWallet() if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) { if (GetArg("-mnemonicpassphrase", "").size() > 256) { - errorString += _("Mnemonic passphrase is too long, must be at most 256 characters"); - return NULL; + return UIError(_("Mnemonic passphrase is too long, must be at most 256 characters")); } // generate a new master key walletInstance->GenerateNewHDChain(); @@ -4548,13 +4547,10 @@ bool CWallet::InitLoadWallet() std::string strBackupError; if(!AutoBackupWallet(walletInstance, "", strBackupWarning, strBackupError)) { if (!strBackupWarning.empty()) { - if (!warningString.empty()) - warningString += "\n"; - warningString += strBackupWarning; + UIWarning(strBackupWarning); } if (!strBackupError.empty()) { - errorString += strBackupError; - return NULL; + return UIError(strBackupError); } } @@ -4562,22 +4558,18 @@ bool CWallet::InitLoadWallet() else if (mapArgs.count("-usehd")) { bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET); if (walletInstance->IsHDEnabled() && !useHD) { - errorString += strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), - strWalletFile); - return NULL; + return UIError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), + walletInstance->strWalletFile)); } if (!walletInstance->IsHDEnabled() && useHD) { - errorString += strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), - strWalletFile); - return NULL; + return UIError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), + walletInstance->strWalletFile)); } } // Warn user every time he starts non-encrypted HD wallet if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsLocked()) { - if (!warningString.empty()) - warningString += "\n"; - warningString += _("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!"); + UIWarning(_("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!")); } LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);