Skip to content

Commit 081538c

Browse files
committed
Make decode_hash(1) throw, prevents null_hash when invalid.
1 parent 9b29f4e commit 081538c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

include/bitcoin/system/impl/radix/base_16.ipp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ constexpr bool decode_hash(data_array<Size>& out,
194194
}
195195

196196
template <size_t Size>
197-
constexpr data_array<Size> decode_hash(const std::string_view& in) NOEXCEPT
197+
constexpr data_array<Size> decode_hash(const std::string_view& in) THROWS
198198
{
199199
data_array<Size> out{};
200200
if (!decode_hash(out, in))
201-
return {};
201+
throw istream_exception{ "decode_hash" };
202202

203203
return out;
204204
}

include/bitcoin/system/radix/base_16.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ template <size_t Size>
6969
constexpr bool decode_hash(data_array<Size>& out,
7070
const std::string_view& in) NOEXCEPT;
7171

72-
/// Returns null_hash on error.
72+
/// Throws istream_exception on input error.
7373
template <size_t Size>
74-
constexpr data_array<Size> decode_hash(const std::string_view& in) NOEXCEPT;
74+
constexpr data_array<Size> decode_hash(const std::string_view& in) THROWS;
7575

7676
/// Literal decodings of hex string, errors reflected as zero-filled data.
7777
/// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)