From 399ed5b4d706ce5b058424e6653228bda18824b1 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 3 Nov 2021 16:08:24 -0600 Subject: [PATCH] Do not strip quotes when verifying mnemonic seed. --- qa/rpc-tests/wallet_import_export.py | 4 ++-- src/wallet/rpcwallet.cpp | 17 +++++------------ test/lint/lint-includes.sh | 1 - 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/qa/rpc-tests/wallet_import_export.py b/qa/rpc-tests/wallet_import_export.py index b28c8f1a4..d4d481fd7 100755 --- a/qa/rpc-tests/wallet_import_export.py +++ b/qa/rpc-tests/wallet_import_export.py @@ -32,7 +32,7 @@ class WalletImportExportTest (BitcoinTestFramework): errorString = e.error['message'] assert_equal("Error: Please acknowledge that you have backed up" in errorString, True) dump_path0 = self.nodes[0].z_exportwallet('walletdumpmnem') - (mnemonic, t_keys0, sprout_keys0, sapling_keys0) = parse_wallet_file(dump_path0) + (mnemonic, _, _, _) = parse_wallet_file(dump_path0) self.nodes[0].walletconfirmbackup(mnemonic) # Now that we've confirmed backup, we can generate addresses @@ -81,7 +81,7 @@ def parse_wallet_file(dump_path): assert_true("recovery_phrase" in file_lines[5], "Expected emergency recovery phrase") assert_true("language" in file_lines[6], "Expected mnemonic seed language") assert_true("fingerprint" in file_lines[7], "Expected mnemonic seed fingerprint") - mnemonic = file_lines[5].split("=")[1].strip() + mnemonic = file_lines[5].split("=")[1].replace("\"", "").strip() (t_keys, i) = parse_wallet_file_lines(file_lines, 0) (sprout_keys, i) = parse_wallet_file_lines(file_lines, i) (sapling_keys, i) = parse_wallet_file_lines(file_lines, i) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b3eb44df0..3c27e0eeb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -38,7 +38,6 @@ #include #include -#include #include #include @@ -1764,20 +1763,14 @@ UniValue walletconfirmbackup(const UniValue& params, bool fHelp) EnsureWalletIsUnlocked(); SecureString strMnemonicPhrase(params[0].get_str()); - boost::erase_all(strMnemonicPhrase, "\""); boost::trim(strMnemonicPhrase); - if (strMnemonicPhrase.length() > 0) { - if (!pwalletMain->VerifyMnemonicSeed(strMnemonicPhrase)) - throw JSONRPCError( - RPC_WALLET_PASSPHRASE_INCORRECT, - "Error: The emergency recovery phrase entered was incorrect."); + if (pwalletMain->VerifyMnemonicSeed(strMnemonicPhrase)) { + return NullUniValue; } else { - throw runtime_error( - "walletconfirmbackup \"emergency recovery phrase\"\n" - "Notify the wallet that the user has backed up the emergency recovery phrase"); + throw JSONRPCError( + RPC_WALLET_PASSPHRASE_INCORRECT, + "Error: The emergency recovery phrase entered was incorrect."); } - - return NullUniValue; } diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh index 29489c702..ece95d7a5 100755 --- a/test/lint/lint-includes.sh +++ b/test/lint/lint-includes.sh @@ -42,7 +42,6 @@ EXPECTED_BOOST_INCLUDES=( boost/algorithm/string.hpp boost/algorithm/string/case_conv.hpp boost/algorithm/string/classification.hpp - boost/algorithm/string/erase.hpp boost/algorithm/string/join.hpp boost/algorithm/string/predicate.hpp boost/algorithm/string/replace.hpp