5#ifndef BITCOIN_PRIMITIVES_TRANSACTION_IDENTIFIER_H
6#define BITCOIN_PRIMITIVES_TRANSACTION_IDENTIFIER_H
19template <
bool has_witness>
28 template <
typename Other>
29 constexpr int Compare(
const Other& other)
const
31 static_assert(ALWAYS_FALSE<Other>,
"Forbidden comparison type");
38 template <
typename Other>
40 template <
typename Other>
42 template <
typename Other>
51 static std::optional<transaction_identifier>
FromHex(std::string_view hex)
54 if (!u)
return std::nullopt;
60 constexpr const std::byte*
data()
const {
return reinterpret_cast<const std::byte*
>(
m_wrapped.
data()); }
61 constexpr const std::byte*
begin()
const {
return reinterpret_cast<const std::byte*
>(
m_wrapped.
begin()); }
62 constexpr const std::byte*
end()
const {
return reinterpret_cast<const std::byte*
>(
m_wrapped.
end()); }
73concept TxidOrWtxid = std::is_same_v<T, Txid> || std::is_same_v<T, Wtxid>;
75class GenTxid :
public std::variant<Txid, Wtxid>
78 using variant::variant;
80 bool IsWtxid()
const {
return std::holds_alternative<Wtxid>(*
this); }
84 return std::visit([](
const auto&
id) ->
const uint256& {
return id.ToUint256(); }, *
this);
const uint256 & ToUint256() const LIFETIMEBOUND
friend auto operator<=>(const GenTxid &a, const GenTxid &b)
constexpr bool IsNull() const
constexpr unsigned char * end()
void Unserialize(Stream &s)
std::string ToString() const
constexpr int Compare(const base_blob &other) const
Lexicographic ordering.
constexpr unsigned char * begin()
void Serialize(Stream &s) const
std::string GetHex() const
constexpr const unsigned char * data() const
transaction_identifier represents the two canonical transaction identifier types (txid,...
std::string ToString() const
static constexpr auto size()
void Unserialize(Stream &s)
void Serialize(Stream &s) const
constexpr const std::byte * begin() const
const uint256 & ToUint256() const LIFETIMEBOUND
constexpr bool IsNull() const
Wrapped uint256 methods.
transaction_identifier(const uint256 &wrapped)
bool operator<(const Other &other) const
bool operator==(const Other &other) const
constexpr int Compare(const Other &other) const
std::string GetHex() const
bool operator!=(const Other &other) const
constexpr const std::byte * data() const
static transaction_identifier FromUint256(const uint256 &id)
constexpr const std::byte * end() const
constexpr int Compare(const transaction_identifier< has_witness > &other) const
static std::optional< transaction_identifier > FromHex(std::string_view hex)
static std::optional< uint256 > FromHex(std::string_view str)