From fab6ddbee64e50d5e2f499aebca35b5911896ec4 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 19 Jul 2024 08:48:45 +0200 Subject: [PATCH] refactor: Expose FromHex in transaction_identifier This is needed for the next commit. --- src/util/transaction_identifier.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/transaction_identifier.h b/src/util/transaction_identifier.h index 1ca48a0454..0e3251f4fc 100644 --- a/src/util/transaction_identifier.h +++ b/src/util/transaction_identifier.h @@ -42,6 +42,12 @@ public: /** Wrapped `uint256` methods. */ constexpr bool IsNull() const { return m_wrapped.IsNull(); } constexpr void SetNull() { m_wrapped.SetNull(); } + static std::optional FromHex(std::string_view hex) + { + auto u{uint256::FromHex(hex)}; + if (!u) return std::nullopt; + return FromUint256(*u); + } std::string GetHex() const { return m_wrapped.GetHex(); } std::string ToString() const { return m_wrapped.ToString(); } static constexpr auto size() { return decltype(m_wrapped)::size(); } @@ -66,6 +72,7 @@ using Txid = transaction_identifier; /** Wtxid commits to all transaction fields including the witness. */ using Wtxid = transaction_identifier; +/** DEPRECATED due to missing length-check and hex-check, please use the safer FromHex, or FromUint256 */ inline Txid TxidFromString(std::string_view str) { return Txid::FromUint256(uint256S(str));