Changeset View
Changeset View
Standalone View
Standalone View
src/key.h
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | template <typename Stream> void Serialize(Stream &s) const { | ||||
unsigned int len = BIP32_EXTKEY_SIZE; | unsigned int len = BIP32_EXTKEY_SIZE; | ||||
::WriteCompactSize(s, len); | ::WriteCompactSize(s, len); | ||||
uint8_t code[BIP32_EXTKEY_SIZE]; | uint8_t code[BIP32_EXTKEY_SIZE]; | ||||
Encode(code); | Encode(code); | ||||
s.write((const char *)&code[0], len); | s.write((const char *)&code[0], len); | ||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
unsigned int len = ::ReadCompactSize(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]; | uint8_t code[BIP32_EXTKEY_SIZE]; | ||||
s.read((char *)&code[0], len); | s.read((char *)&code[0], len); | ||||
Decode(code); | Decode(code); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Initialize the elliptic curve support. May not be called twice without | * Initialize the elliptic curve support. May not be called twice without | ||||
Show All 14 Lines |