6 #ifndef BITCOIN_UINT256_H
7 #define BITCOIN_UINT256_H
20 template<
unsigned int BITS>
24 static constexpr
int WIDTH = BITS / 8;
25 static_assert(BITS % 8 == 0,
"base_blob currently only supports whole bytes.");
27 static_assert(
WIDTH ==
sizeof(
m_data),
"Sanity check");
44 return std::all_of(
m_data.begin(),
m_data.end(), [](uint8_t val) {
60 std::string
GetHex()
const;
61 void SetHex(
const char* psz);
62 void SetHex(
const std::string& str);
65 constexpr
const unsigned char*
data()
const {
return m_data.data(); }
66 constexpr
unsigned char*
data() {
return m_data.data(); }
71 constexpr
const unsigned char*
begin()
const {
return m_data.data(); }
74 static constexpr
unsigned int size() {
return WIDTH; }
78 template<
typename Stream>
84 template<
typename Stream>
constexpr std::size_t size() const noexcept
constexpr C * end() const noexcept
constexpr C * begin() const noexcept
Template base class for fixed-sized opaque blobs.
constexpr base_blob(uint8_t v)
constexpr bool IsNull() const
constexpr unsigned char * end()
static constexpr int WIDTH
static constexpr unsigned int size()
void SetHex(const char *psz)
constexpr uint64_t GetUint64(int pos) const
void Unserialize(Stream &s)
std::string ToString() const
constexpr const unsigned char * data() const
constexpr const unsigned char * begin() const
constexpr friend bool operator!=(const base_blob &a, const base_blob &b)
constexpr friend bool operator<(const base_blob &a, const base_blob &b)
constexpr int Compare(const base_blob &other) const
constexpr unsigned char * begin()
constexpr friend bool operator==(const base_blob &a, const base_blob &b)
constexpr unsigned char * data()
void Serialize(Stream &s) const
constexpr const unsigned char * end() const
std::string GetHex() const
constexpr base_blob(Span< const unsigned char > vch)
std::array< uint8_t, WIDTH > m_data
constexpr uint160(Span< const unsigned char > vch)
constexpr uint160()=default
constexpr uint256(Span< const unsigned char > vch)
constexpr uint256()=default
static const uint256 ZERO
constexpr uint256(uint8_t v)
static uint64_t ReadLE64(const unsigned char *ptr)
Span(T *, EndOrSize) -> Span< T >
Span< std::byte > MakeWritableByteSpan(V &&v) noexcept
uint256 uint256S(const char *str)