Changeset View
Changeset View
Standalone View
Standalone View
src/pubkey.h
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static unsigned int GetLen(uint8_t chHeader) { | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
//! Set this key data to be invalid | //! Set this key data to be invalid | ||||
void Invalidate() { vch[0] = 0xFF; } | void Invalidate() { vch[0] = 0xFF; } | ||||
public: | public: | ||||
bool static ValidSize(const std::vector<uint8_t> &vch) { | |||||
return vch.size() > 0 && GetLen(vch[0]) == vch.size(); | |||||
} | |||||
//! Construct an invalid public key. | //! Construct an invalid public key. | ||||
CPubKey() { Invalidate(); } | CPubKey() { Invalidate(); } | ||||
//! Initialize a public key using begin/end iterators to byte data. | //! Initialize a public key using begin/end iterators to byte data. | ||||
template <typename T> void Set(const T pbegin, const T pend) { | template <typename T> void Set(const T pbegin, const T pend) { | ||||
int len = pend == pbegin ? 0 : GetLen(pbegin[0]); | int len = pend == pbegin ? 0 : GetLen(pbegin[0]); | ||||
if (len && len == (pend - pbegin)) { | if (len && len == (pend - pbegin)) { | ||||
memcpy(vch, (uint8_t *)&pbegin[0], len); | memcpy(vch, (uint8_t *)&pbegin[0], len); | ||||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |