diff --git a/src/test/fuzz/hex.cpp b/src/test/fuzz/hex.cpp index 8bc0460bb8..0140c5947e 100644 --- a/src/test/fuzz/hex.cpp +++ b/src/test/fuzz/hex.cpp @@ -27,7 +27,6 @@ FUZZ_TARGET(hex) if (IsHex(random_hex_string)) { assert(ToLower(random_hex_string) == hex_data); } - (void)IsHexNumber(random_hex_string); if (uint256::FromHex(random_hex_string)) { assert(random_hex_string.length() == 64); assert(Txid::FromHex(random_hex_string)); diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index bf1fc1ea0a..c2c725d676 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -432,31 +432,6 @@ BOOST_AUTO_TEST_CASE(util_IsHex) BOOST_CHECK(!IsHex("0x0000")); } -BOOST_AUTO_TEST_CASE(util_IsHexNumber) -{ - BOOST_CHECK(IsHexNumber("0x0")); - BOOST_CHECK(IsHexNumber("0")); - BOOST_CHECK(IsHexNumber("0x10")); - BOOST_CHECK(IsHexNumber("10")); - BOOST_CHECK(IsHexNumber("0xff")); - BOOST_CHECK(IsHexNumber("ff")); - BOOST_CHECK(IsHexNumber("0xFfa")); - BOOST_CHECK(IsHexNumber("Ffa")); - BOOST_CHECK(IsHexNumber("0x00112233445566778899aabbccddeeffAABBCCDDEEFF")); - BOOST_CHECK(IsHexNumber("00112233445566778899aabbccddeeffAABBCCDDEEFF")); - - BOOST_CHECK(!IsHexNumber("")); // empty string not allowed - BOOST_CHECK(!IsHexNumber("0x")); // empty string after prefix not allowed - BOOST_CHECK(!IsHexNumber("0x0 ")); // no spaces at end, - BOOST_CHECK(!IsHexNumber(" 0x0")); // or beginning, - BOOST_CHECK(!IsHexNumber("0x 0")); // or middle, - BOOST_CHECK(!IsHexNumber(" ")); // etc. - BOOST_CHECK(!IsHexNumber("0x0ga")); // invalid character - BOOST_CHECK(!IsHexNumber("x0")); // broken prefix - BOOST_CHECK(!IsHexNumber("0x0x00")); // two prefixes not allowed - -} - BOOST_AUTO_TEST_CASE(util_seed_insecure_rand) { SeedRandomForTest(SeedRand::ZEROS); diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index e030262a32..15cb40aba1 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -46,16 +46,6 @@ bool IsHex(std::string_view str) return (str.size() > 0) && (str.size()%2 == 0); } -bool IsHexNumber(std::string_view str) -{ - if (str.substr(0, 2) == "0x") str.remove_prefix(2); - for (char c : str) { - if (HexDigit(c) < 0) return false; - } - // Return false for empty string or "0x". - return str.size() > 0; -} - template std::optional> TryParseHex(std::string_view str) { diff --git a/src/util/strencodings.h b/src/util/strencodings.h index e5c2d3ddf2..91ac35b132 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -70,10 +70,6 @@ std::vector ParseHex(std::string_view hex_str) /* Returns true if each character in str is a hex character, and has an even * number of hex digits.*/ bool IsHex(std::string_view str); -/** -* Return true if the string is a hex number, optionally prefixed with "0x" -*/ -bool IsHexNumber(std::string_view str); std::optional> DecodeBase64(std::string_view str); std::string EncodeBase64(Span input); inline std::string EncodeBase64(Span input) { return EncodeBase64(MakeUCharSpan(input)); }