diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-11-10 10:49:58 +0100 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-04-27 19:53:17 +0200 |
commit | fae1006019188700e0c497a63fc1550fe00ca8bb (patch) | |
tree | 0b0befbf77427a934bb6aeffe1113095e8cb6e59 /src/util/strencodings.h | |
parent | fabdf81983e2542d60542b80fb94ccb1acdd204a (diff) | |
download | bitcoin-fae1006019188700e0c497a63fc1550fe00ca8bb.tar.xz |
util: Add ParseHex<std::byte>() helper
Diffstat (limited to 'src/util/strencodings.h')
-rw-r--r-- | src/util/strencodings.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/util/strencodings.h b/src/util/strencodings.h index ebb6d88952..ee58383528 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -55,7 +55,9 @@ enum class ByteUnit : uint64_t { * @return A new string without unsafe chars */ std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT); -std::vector<unsigned char> ParseHex(std::string_view str); +/** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. */ +template <typename Byte = uint8_t> +std::vector<Byte> ParseHex(std::string_view str); signed char HexDigit(char c); /* Returns true if each character in str is a hex character, and has an even * number of hex digits.*/ |