diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp --- a/src/dummywallet.cpp +++ b/src/dummywallet.cpp @@ -54,15 +54,17 @@ std::shared_ptr LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const std::string &name, std::string &error, - std::string &warning) { + std::vector &warnings) { throw std::logic_error("Wallet function called in non-wallet build."); } -WalletCreationStatus -CreateWallet(const CChainParams &chainParams, interfaces::Chain &chain, - const SecureString &passphrase, uint64_t wallet_creation_flags, - const std::string &name, std::string &error, std::string &warning, - std::shared_ptr &result) { +WalletCreationStatus CreateWallet(const CChainParams &chainParams, + interfaces::Chain &chain, + const SecureString &passphrase, + uint64_t wallet_creation_flags, + const std::string &name, std::string &error, + std::vector &warnings, + std::shared_ptr &result) { throw std::logic_error("Wallet function called in non-wallet build."); } diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -205,16 +205,16 @@ //! Attempts to load a wallet from file or directory. //! The loaded wallet is also notified to handlers previously registered //! with handleLoadWallet. - virtual std::unique_ptr loadWallet(const CChainParams ¶ms, - const std::string &name, - std::string &error, - std::string &warning) const = 0; + virtual std::unique_ptr + loadWallet(const CChainParams ¶ms, const std::string &name, + std::string &error, + std::vector &warnings) const = 0; //! Create a wallet from file virtual WalletCreationStatus createWallet(const CChainParams ¶ms, const SecureString &passphrase, uint64_t wallet_creation_flags, const std::string &name, - std::string &error, std::string &warning, + std::string &error, std::vector &warnings, std::unique_ptr &result) = 0; //! Register handler for init messages. diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -45,12 +45,14 @@ std::shared_ptr LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const std::string &name, std::string &error, - std::string &warning); -WalletCreationStatus -CreateWallet(const CChainParams ¶ms, interfaces::Chain &chain, - const SecureString &passphrase, uint64_t wallet_creation_flags, - const std::string &name, std::string &error, std::string &warning, - std::shared_ptr &result); + std::vector &warnings); +WalletCreationStatus CreateWallet(const CChainParams ¶ms, + interfaces::Chain &chain, + const SecureString &passphrase, + uint64_t wallet_creation_flags, + const std::string &name, std::string &error, + std::vector &warnings, + std::shared_ptr &result); namespace interfaces { @@ -280,19 +282,20 @@ } std::unique_ptr loadWallet(const CChainParams ¶ms, const std::string &name, - std::string &error, std::string &warning) const override { + std::string &error, + std::vector &warnings) const override { return MakeWallet( - LoadWallet(params, *m_context.chain, name, error, warning)); + LoadWallet(params, *m_context.chain, name, error, warnings)); } WalletCreationStatus createWallet(const CChainParams ¶ms, const SecureString &passphrase, uint64_t wallet_creation_flags, const std::string &name, - std::string &error, std::string &warning, + std::string &error, std::vector &warnings, std::unique_ptr &result) override { std::shared_ptr wallet; WalletCreationStatus status = CreateWallet( params, *m_context.chain, passphrase, wallet_creation_flags, - name, error, warning, wallet); + name, error, warnings, wallet); result = MakeWallet(wallet); return status; } diff --git a/src/qt/walletcontroller.h b/src/qt/walletcontroller.h --- a/src/qt/walletcontroller.h +++ b/src/qt/walletcontroller.h @@ -104,7 +104,7 @@ QProgressDialog *m_progress_dialog{nullptr}; WalletModel *m_wallet_model{nullptr}; std::string m_error_message; - std::string m_warning_message; + std::vector m_warning_message; const CChainParams &m_chainparams; }; diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -234,8 +235,9 @@ QMessageBox::critical(m_parent_widget, tr("Create wallet failed"), QString::fromStdString(m_error_message)); } else if (!m_warning_message.empty()) { - QMessageBox::warning(m_parent_widget, tr("Create wallet warning"), - QString::fromStdString(m_warning_message)); + QMessageBox::warning( + m_parent_widget, tr("Create wallet warning"), + QString::fromStdString(Join(m_warning_message, "\n"))); } if (m_wallet_model) { @@ -275,8 +277,9 @@ QMessageBox::critical(m_parent_widget, tr("Open wallet failed"), QString::fromStdString(m_error_message)); } else if (!m_warning_message.empty()) { - QMessageBox::warning(m_parent_widget, tr("Open wallet warning"), - QString::fromStdString(m_warning_message)); + QMessageBox::warning( + m_parent_widget, tr("Open wallet warning"), + QString::fromStdString(Join(m_warning_message, "\n"))); } if (m_wallet_model) { diff --git a/src/wallet/db.h b/src/wallet/db.h --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -255,7 +255,8 @@ std::string &errorStr); /* verifies the database file */ static bool - VerifyDatabaseFile(const fs::path &file_path, std::string &warningStr, + VerifyDatabaseFile(const fs::path &file_path, + std::vector &warnings, std::string &errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -423,8 +423,8 @@ } bool BerkeleyBatch::VerifyDatabaseFile( - const fs::path &file_path, std::string &warningStr, std::string &errorStr, - BerkeleyEnvironment::recoverFunc_type recoverFunc) { + const fs::path &file_path, std::vector &warnings, + std::string &errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc) { std::string walletFile; std::shared_ptr env = GetWalletEnv(file_path, walletFile); @@ -435,12 +435,12 @@ BerkeleyEnvironment::VerifyResult r = env->Verify(walletFile, recoverFunc, backup_filename); if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK) { - warningStr = strprintf( + warnings.push_back(strprintf( _("Warning: Wallet file corrupt, data salvaged! Original %s " "saved as %s in %s; if your balance or transactions are " "incorrect you should restore from a backup.") .translated, - walletFile, backup_filename, walletDir); + walletFile, backup_filename, walletDir)); } if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL) { errorStr = strprintf(_("%s corrupt, salvage failed").translated, diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -65,15 +66,15 @@ } std::string error_string; - std::string warning_string; + std::vector warnings; bool verify_success = CWallet::Verify(chainParams, chain, location, salvage_wallet, - error_string, warning_string); + error_string, warnings); if (!error_string.empty()) { chain.initError(error_string); } - if (!warning_string.empty()) { - chain.initWarning(warning_string); + if (!warnings.empty()) { + chain.initWarning(Join(warnings, "\n")); } if (!verify_success) { return false; @@ -86,9 +87,15 @@ bool LoadWallets(const CChainParams &chainParams, interfaces::Chain &chain, const std::vector &wallet_files) { for (const std::string &walletFile : wallet_files) { + std::string error; + std::vector warnings; std::shared_ptr pwallet = CWallet::CreateWalletFromFile( - chainParams, chain, WalletLocation(walletFile)); + chainParams, chain, WalletLocation(walletFile), error, warnings); + if (!warnings.empty()) { + chain.initWarning(Join(warnings, "\n")); + } if (!pwallet) { + chain.initError(error); return false; } AddWallet(pwallet); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -3033,7 +3034,8 @@ } } - std::string error, warning; + std::string error; + std::vector warning; std::shared_ptr const wallet = LoadWallet(chainParams, *g_rpc_chain, location, error, warning); if (!wallet) { @@ -3042,7 +3044,7 @@ UniValue obj(UniValue::VOBJ); obj.pushKV("name", wallet->GetName()); - obj.pushKV("warning", warning); + obj.pushKV("warning", Join(warning, "\n")); return obj; } @@ -3168,13 +3170,13 @@ SecureString passphrase; passphrase.reserve(100); - std::string warning; + std::vector warnings; if (!request.params[3].isNull()) { passphrase = request.params[3].get_str().c_str(); if (passphrase.empty()) { // Empty string means unencrypted - warning = "Empty string given as passphrase, wallet will not be " - "encrypted."; + warnings.emplace_back("Empty string given as passphrase, wallet " + "will not be encrypted."); } } @@ -3183,11 +3185,10 @@ } std::string error; - std::string create_warning; std::shared_ptr wallet; - WalletCreationStatus status = CreateWallet( - config.GetChainParams(), *g_rpc_chain, passphrase, flags, - request.params[0].get_str(), error, create_warning, wallet); + WalletCreationStatus status = + CreateWallet(config.GetChainParams(), *g_rpc_chain, passphrase, flags, + request.params[0].get_str(), error, warnings, wallet); switch (status) { case WalletCreationStatus::CREATION_FAILED: throw JSONRPCError(RPC_WALLET_ERROR, error); @@ -3198,15 +3199,9 @@ // no default case, so the compiler can warn about missing cases } - if (warning.empty()) { - warning = create_warning; - } else if (!warning.empty() && !create_warning.empty()) { - warning += "; " + create_warning; - } - UniValue obj(UniValue::VOBJ); obj.pushKV("name", wallet->GetName()); - obj.pushKV("warning", warning); + obj.pushKV("warning", Join(warnings, "\n")); return obj; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -52,15 +52,18 @@ std::shared_ptr LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, - std::string &error, std::string &warning); + std::string &error, + std::vector &warnings); enum class WalletCreationStatus { SUCCESS, CREATION_FAILED, ENCRYPTION_FAILED }; -WalletCreationStatus -CreateWallet(const CChainParams ¶ms, interfaces::Chain &chain, - const SecureString &passphrase, uint64_t wallet_creation_flags, - const std::string &name, std::string &error, std::string &warning, - std::shared_ptr &result); +WalletCreationStatus CreateWallet(const CChainParams ¶ms, + interfaces::Chain &chain, + const SecureString &passphrase, + uint64_t wallet_creation_flags, + const std::string &name, std::string &error, + std::vector &warnings, + std::shared_ptr &result); //! Default for -keypool static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; @@ -1558,7 +1561,7 @@ static bool Verify(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, bool salvage_wallet, std::string &error_string, - std::string &warning_string); + std::vector &warnings); /** * Initializes the wallet, returns a new CWallet instance or a null pointer @@ -1566,7 +1569,8 @@ */ static std::shared_ptr CreateWalletFromFile( const CChainParams &chainParams, interfaces::Chain &chain, - const WalletLocation &location, uint64_t wallet_creation_flags = 0); + const WalletLocation &location, std::string &error, + std::vector &warnings, uint64_t wallet_creation_flags = 0); /** * Wallet post-init setup diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -141,16 +141,18 @@ std::shared_ptr LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, - std::string &error, std::string &warning) { - if (!CWallet::Verify(chainParams, chain, location, false, error, warning)) { + std::string &error, + std::vector &warnings) { + if (!CWallet::Verify(chainParams, chain, location, false, error, + warnings)) { error = "Wallet file verification failed: " + error; return nullptr; } - std::shared_ptr wallet = - CWallet::CreateWalletFromFile(chainParams, chain, location); + std::shared_ptr wallet = CWallet::CreateWalletFromFile( + chainParams, chain, location, error, warnings); if (!wallet) { - error = "Wallet loading failed."; + error = "Wallet loading failed: " + error; return nullptr; } AddWallet(wallet); @@ -161,15 +163,18 @@ std::shared_ptr LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const std::string &name, std::string &error, - std::string &warning) { - return LoadWallet(chainParams, chain, WalletLocation(name), error, warning); -} - -WalletCreationStatus -CreateWallet(const CChainParams ¶ms, interfaces::Chain &chain, - const SecureString &passphrase, uint64_t wallet_creation_flags, - const std::string &name, std::string &error, std::string &warning, - std::shared_ptr &result) { + std::vector &warnings) { + return LoadWallet(chainParams, chain, WalletLocation(name), error, + warnings); +} + +WalletCreationStatus CreateWallet(const CChainParams ¶ms, + interfaces::Chain &chain, + const SecureString &passphrase, + uint64_t wallet_creation_flags, + const std::string &name, std::string &error, + std::vector &warnings, + std::shared_ptr &result) { // Indicate that the wallet is actually supposed to be blank and not just // blank to make it encrypted bool create_blank = (wallet_creation_flags & WALLET_FLAG_BLANK_WALLET); @@ -188,10 +193,8 @@ // Wallet::Verify will check if we're trying to create a wallet with a // duplicate name. - std::string wallet_error; - if (!CWallet::Verify(params, chain, location, false, wallet_error, - warning)) { - error = "Wallet file verification failed: " + wallet_error; + if (!CWallet::Verify(params, chain, location, false, error, warnings)) { + error = "Wallet file verification failed: " + error; return WalletCreationStatus::CREATION_FAILED; } @@ -206,9 +209,9 @@ // Make the wallet std::shared_ptr wallet = CWallet::CreateWalletFromFile( - params, chain, location, wallet_creation_flags); + params, chain, location, error, warnings, wallet_creation_flags); if (!wallet) { - error = "Wallet creation failed"; + error = "Wallet creation failed: " + error; return WalletCreationStatus::CREATION_FAILED; } @@ -4615,7 +4618,8 @@ bool CWallet::Verify(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, bool salvage_wallet, - std::string &error_string, std::string &warning_string) { + std::string &error_string, + std::vector &warnings) { // Do some checking on wallet path. It should be either a: // // 1. Path where a directory can be created. @@ -4681,8 +4685,7 @@ } } - return WalletBatch::VerifyDatabaseFile(wallet_path, warning_string, - error_string); + return WalletBatch::VerifyDatabaseFile(wallet_path, warnings, error_string); } void CWallet::MarkPreSplitKeys() { @@ -4707,7 +4710,8 @@ std::shared_ptr CWallet::CreateWalletFromFile( const CChainParams &chainParams, interfaces::Chain &chain, - const WalletLocation &location, uint64_t wallet_creation_flags) { + const WalletLocation &location, std::string &error, + std::vector &warnings, uint64_t wallet_creation_flags) { const std::string walletFile = WalletDataFilePath(location.GetPath()).string(); @@ -4723,9 +4727,8 @@ WalletDatabase::Create(location.GetPath())); DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); if (nZapWalletRet != DBErrors::LOAD_OK) { - chain.initError( - strprintf(_("Error loading %s: Wallet corrupted").translated, - walletFile)); + error = strprintf( + _("Error loading %s: Wallet corrupted").translated, walletFile); return nullptr; } } @@ -4743,33 +4746,31 @@ DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun); if (nLoadWalletRet != DBErrors::LOAD_OK) { if (nLoadWalletRet == DBErrors::CORRUPT) { - chain.initError( - strprintf(_("Error loading %s: Wallet corrupted").translated, - walletFile)); + error = strprintf( + _("Error loading %s: Wallet corrupted").translated, walletFile); return nullptr; } if (nLoadWalletRet == DBErrors::NONCRITICAL_ERROR) { - chain.initError(strprintf( + warnings.push_back(strprintf( _("Error reading %s! All keys read correctly, but transaction " "data or address book entries might be missing or incorrect.") .translated, walletFile)); } else if (nLoadWalletRet == DBErrors::TOO_NEW) { - chain.initError(strprintf( + error = strprintf( _("Error loading %s: Wallet requires newer version of %s") .translated, - walletFile, PACKAGE_NAME)); + walletFile, PACKAGE_NAME); return nullptr; } else if (nLoadWalletRet == DBErrors::NEED_REWRITE) { - chain.initError(strprintf( + error = strprintf( _("Wallet needed to be rewritten: restart %s to complete") .translated, - PACKAGE_NAME)); + PACKAGE_NAME); return nullptr; } else { - chain.initError( - strprintf(_("Error loading %s").translated, walletFile)); + error = strprintf(_("Error loading %s").translated, walletFile); return nullptr; } } @@ -4790,7 +4791,7 @@ } if (nMaxVersion < walletInstance->GetVersion()) { - chain.initError(_("Cannot downgrade wallet").translated); + error = _("Cannot downgrade wallet").translated; return nullptr; } @@ -4807,11 +4808,11 @@ if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) { - chain.initError( + error = _("Cannot upgrade a non HD split wallet without upgrading to " "support pre split keypool. Please use -upgradewallet=200300 " "or -upgradewallet with no version specified.") - .translated); + .translated; return nullptr; } @@ -4841,7 +4842,7 @@ // Regenerate the keypool if upgraded to HD if (hd_upgrade) { if (!walletInstance->TopUpKeyPool()) { - chain.initError(_("Unable to generate keys").translated); + error = _("Unable to generate keys").translated; return nullptr; } } @@ -4863,7 +4864,7 @@ // Top up the keypool if (walletInstance->CanGenerateKeys() && !walletInstance->TopUpKeyPool()) { - chain.initError(_("Unable to generate initial keys").translated); + error = _("Unable to generate initial keys").translated; return nullptr; } @@ -4871,20 +4872,19 @@ walletInstance->ChainStateFlushed(locked_chain->getTipLocator()); } else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) { // Make it impossible to disable private keys after creation - chain.initError( - strprintf(_("Error loading %s: Private keys can only be " - "disabled during creation") - .translated, - walletFile)); + error = strprintf(_("Error loading %s: Private keys can only be " + "disabled during creation") + .translated, + walletFile); return nullptr; } else if (walletInstance->IsWalletFlagSet( WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { LOCK(walletInstance->cs_KeyStore); if (!walletInstance->mapKeys.empty() || !walletInstance->mapCryptedKeys.empty()) { - chain.initWarning( - strprintf(_("Warning: Private keys detected in wallet " - "{%s} with disabled private keys") + warnings.push_back( + strprintf(_("Warning: Private keys detected in wallet {%s} " + "with disabled private keys") .translated, walletFile)); } @@ -4894,17 +4894,15 @@ Amount n = Amount::zero(); if (!ParseMoney(gArgs.GetArg("-mintxfee", ""), n) || n == Amount::zero()) { - chain.initError( - AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", "")) - .translated); + error = AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", "")) + .translated; return nullptr; } if (n > HIGH_TX_FEE_PER_KB) { - chain.initWarning( - AmountHighWarn("-mintxfee").translated + " " + - _("This is the minimum transaction fee you pay on " - "every transaction.") - .translated); + warnings.push_back(AmountHighWarn("-mintxfee").translated + " " + + _("This is the minimum transaction fee you pay " + "on every transaction.") + .translated); } walletInstance->m_min_fee = CFeeRate(n); } @@ -4912,17 +4910,16 @@ if (gArgs.IsArgSet("-fallbackfee")) { Amount nFeePerK = Amount::zero(); if (!ParseMoney(gArgs.GetArg("-fallbackfee", ""), nFeePerK)) { - chain.initError(strprintf( + error = strprintf( _("Invalid amount for -fallbackfee=: '%s'").translated, - gArgs.GetArg("-fallbackfee", ""))); + gArgs.GetArg("-fallbackfee", "")); return nullptr; } if (nFeePerK > HIGH_TX_FEE_PER_KB) { - chain.initWarning( - AmountHighWarn("-fallbackfee").translated + " " + - _("This is the transaction fee you may pay when fee " - "estimates are not available.") - .translated); + warnings.push_back(AmountHighWarn("-fallbackfee").translated + " " + + _("This is the transaction fee you may pay when " + "fee estimates are not available.") + .translated); } walletInstance->m_fallback_fee = CFeeRate(nFeePerK); } @@ -4933,25 +4930,23 @@ if (gArgs.IsArgSet("-paytxfee")) { Amount nFeePerK = Amount::zero(); if (!ParseMoney(gArgs.GetArg("-paytxfee", ""), nFeePerK)) { - chain.initError( - AmountErrMsg("paytxfee", gArgs.GetArg("-paytxfee", "")) - .translated); + error = AmountErrMsg("paytxfee", gArgs.GetArg("-paytxfee", "")) + .translated; return nullptr; } if (nFeePerK > HIGH_TX_FEE_PER_KB) { - chain.initWarning( - AmountHighWarn("-paytxfee").translated + " " + - _("This is the transaction fee you will pay if you " - "send a transaction.") - .translated); + warnings.push_back(AmountHighWarn("-paytxfee").translated + " " + + _("This is the transaction fee you will pay if " + "you send a transaction.") + .translated); } walletInstance->m_pay_tx_fee = CFeeRate(nFeePerK, 1000); if (walletInstance->m_pay_tx_fee < chain.relayMinFee()) { - chain.initError(strprintf( - _("Invalid amount for -paytxfee=: '%s' " - "(must be at least %s)") - .translated, - gArgs.GetArg("-paytxfee", ""), chain.relayMinFee().ToString())); + error = strprintf(_("Invalid amount for -paytxfee=: '%s' " + "(must be at least %s)") + .translated, + gArgs.GetArg("-paytxfee", ""), + chain.relayMinFee().ToString()); return nullptr; } } @@ -4959,29 +4954,28 @@ if (gArgs.IsArgSet("-maxtxfee")) { Amount nMaxFee = Amount::zero(); if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee)) { - chain.initError( - AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", "")) - .translated); + error = AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", "")) + .translated; return nullptr; } if (nMaxFee > HIGH_MAX_TX_FEE) { - chain.initWarning(_("-maxtxfee is set very high! Fees this large " - "could be paid on a single transaction.") - .translated); + warnings.push_back(_("-maxtxfee is set very high! Fees this large " + "could be paid on a single transaction.") + .translated); } if (CFeeRate(nMaxFee, 1000) < chain.relayMinFee()) { - chain.initError(strprintf( + error = strprintf( _("Invalid amount for -maxtxfee=: '%s' (must be at " "least the minrelay fee of %s to prevent stuck transactions)") .translated, - gArgs.GetArg("-maxtxfee", ""), chain.relayMinFee().ToString())); + gArgs.GetArg("-maxtxfee", ""), chain.relayMinFee().ToString()); return nullptr; } walletInstance->m_default_max_tx_fee = nMaxFee; } if (chain.relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) { - chain.initWarning( + warnings.push_back( AmountHighWarn("-minrelaytxfee").translated + " " + _("The wallet will avoid paying less than the minimum relay fee.") .translated); @@ -5039,11 +5033,10 @@ } if (rescan_height != block_height) { - chain.initError( - _("Prune: last wallet synchronisation goes beyond " - "pruned data. You need to -reindex (download the " - "whole blockchain again in case of pruned node)") - .translated); + error = _("Prune: last wallet synchronisation goes beyond " + "pruned data. You need to -reindex (download the " + "whole blockchain again in case of pruned node)") + .translated; return nullptr; } } @@ -5073,9 +5066,8 @@ locked_chain->getBlockHash(rescan_height), BlockHash(), reserver, true /* update */) .status)) { - chain.initError( - _("Failed to rescan the wallet during initialization") - .translated); + error = _("Failed to rescan the wallet during initialization") + .translated; return nullptr; } } diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -249,7 +249,7 @@ std::string &errorStr); /* verifies the database file */ static bool VerifyDatabaseFile(const fs::path &wallet_path, - std::string &warningStr, + std::vector &warnings, std::string &errorStr); //! write the hdchain model (external chain child index counter) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -779,9 +779,9 @@ } bool WalletBatch::VerifyDatabaseFile(const fs::path &wallet_path, - std::string &warningStr, + std::vector &warnings, std::string &errorStr) { - return BerkeleyBatch::VerifyDatabaseFile(wallet_path, warningStr, errorStr, + return BerkeleyBatch::VerifyDatabaseFile(wallet_path, warnings, errorStr, WalletBatch::Recover); } diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -431,14 +431,10 @@ self.log.info("Fail -upgradewallet that results in downgrade") assert_raises_rpc_error( -4, - "Wallet loading failed.", + 'Wallet loading failed: Error loading {}: Wallet requires newer version of {}'.format( + wallet_dir('high_minversion', 'wallet.dat'), self.config['environment']['PACKAGE_NAME']), lambda: self.nodes[0].loadwallet(filename='high_minversion'), ) - self.stop_node( - i=0, - expected_stderr='Error: Error loading {}: Wallet requires newer version of Bitcoin ABC'.format( - wallet_dir('high_minversion', 'wallet.dat')), - ) if __name__ == '__main__':