diff options
Diffstat (limited to 'src/util/transaction_identifier.h')
-rw-r--r-- | src/util/transaction_identifier.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/util/transaction_identifier.h b/src/util/transaction_identifier.h index d4a0ede25a..81b053843d 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<transaction_identifier> 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,9 +72,4 @@ using Txid = transaction_identifier<false>; /** Wtxid commits to all transaction fields including the witness. */ using Wtxid = transaction_identifier<true>; -inline Txid TxidFromString(std::string_view str) -{ - return Txid::FromUint256(uint256S(str.data())); -} - #endif // BITCOIN_UTIL_TRANSACTION_IDENTIFIER_H |