diff options
author | Pieter Wuille <pieter@wuille.net> | 2021-05-23 17:38:18 -0700 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2021-05-24 12:14:16 -0700 |
commit | 4b1cc08f9f94a1e6e1ecba6b97f99b73fb513872 (patch) | |
tree | 23032c2016b9012a22074a8b086affe59131cde8 /src | |
parent | b295395664bd37e26d168c329f238237b34aef8c (diff) |
Make XOnlyPubKey act like byte container
Diffstat (limited to 'src')
-rw-r--r-- | src/pubkey.h | 15 | ||||
-rw-r--r-- | src/uint256.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/pubkey.h b/src/pubkey.h index 1af1187006..7d09faa9c1 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -222,6 +222,12 @@ private: uint256 m_keydata; public: + /** Construct an empty x-only pubkey. */ + XOnlyPubKey() = default; + + XOnlyPubKey(const XOnlyPubKey&) = default; + XOnlyPubKey& operator=(const XOnlyPubKey&) = default; + /** Construct an x-only pubkey from exactly 32 bytes. */ explicit XOnlyPubKey(Span<const unsigned char> bytes); @@ -234,7 +240,14 @@ public: const unsigned char& operator[](int pos) const { return *(m_keydata.begin() + pos); } const unsigned char* data() const { return m_keydata.begin(); } - size_t size() const { return m_keydata.size(); } + static constexpr size_t size() { return decltype(m_keydata)::size(); } + const unsigned char* begin() const { return m_keydata.begin(); } + const unsigned char* end() const { return m_keydata.end(); } + unsigned char* begin() { return m_keydata.begin(); } + unsigned char* end() { return m_keydata.end(); } + bool operator==(const XOnlyPubKey& other) const { return m_keydata == other.m_keydata; } + bool operator!=(const XOnlyPubKey& other) const { return m_keydata != other.m_keydata; } + bool operator<(const XOnlyPubKey& other) const { return m_keydata < other.m_keydata; } }; struct CExtPubKey { diff --git a/src/uint256.h b/src/uint256.h index fadf2320af..d4917d0eac 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -75,7 +75,7 @@ public: return &m_data[WIDTH]; } - unsigned int size() const + static constexpr unsigned int size() { return sizeof(m_data); } |