Changeset View
Changeset View
Standalone View
Standalone View
src/key.h
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | friend bool operator==(const CExtKey &a, const CExtKey &b) { | ||||
a.key == b.key; | a.key == b.key; | ||||
} | } | ||||
void Encode(uint8_t code[BIP32_EXTKEY_SIZE]) const; | void Encode(uint8_t code[BIP32_EXTKEY_SIZE]) const; | ||||
void Decode(const uint8_t code[BIP32_EXTKEY_SIZE]); | void Decode(const uint8_t code[BIP32_EXTKEY_SIZE]); | ||||
bool Derive(CExtKey &out, unsigned int nChild) const; | bool Derive(CExtKey &out, unsigned int nChild) const; | ||||
CExtPubKey Neuter() const; | CExtPubKey Neuter() const; | ||||
void SetSeed(const uint8_t *seed, unsigned int nSeedLen); | void SetSeed(const uint8_t *seed, unsigned int nSeedLen); | ||||
template <typename Stream> void Serialize(Stream &s) const { | |||||
unsigned int len = BIP32_EXTKEY_SIZE; | |||||
::WriteCompactSize(s, len); | |||||
uint8_t code[BIP32_EXTKEY_SIZE]; | |||||
Encode(code); | |||||
s.write((const char *)&code[0], len); | |||||
} | |||||
template <typename Stream> void Unserialize(Stream &s) { | |||||
unsigned int len = ::ReadCompactSize(s); | |||||
if (len != BIP32_EXTKEY_SIZE) { | |||||
throw std::runtime_error("Invalid extended key size\n"); | |||||
} | |||||
uint8_t code[BIP32_EXTKEY_SIZE]; | |||||
s.read((char *)&code[0], len); | |||||
Decode(code); | |||||
} | |||||
CExtKey() = default; | CExtKey() = default; | ||||
}; | }; | ||||
/** | /** | ||||
* Initialize the elliptic curve support. May not be called twice without | * Initialize the elliptic curve support. May not be called twice without | ||||
* calling ECC_Stop first. | * calling ECC_Stop first. | ||||
*/ | */ | ||||
Show All 12 Lines |