mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Make XOnlyPubKey act like byte container
This commit is contained in:
parent
b295395664
commit
4b1cc08f9f
2 changed files with 15 additions and 2 deletions
15
src/pubkey.h
15
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 {
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
return &m_data[WIDTH];
|
||||
}
|
||||
|
||||
unsigned int size() const
|
||||
static constexpr unsigned int size()
|
||||
{
|
||||
return sizeof(m_data);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue