|
|
@ -23,6 +23,8 @@
|
|
|
|
* script supports up to 75 for single byte push
|
|
|
|
* script supports up to 75 for single byte push
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const unsigned int BIP32_EXTKEY_SIZE = 74;
|
|
|
|
|
|
|
|
|
|
|
|
/** A reference to a CKey: the Hash160 of its serialized public key */
|
|
|
|
/** A reference to a CKey: the Hash160 of its serialized public key */
|
|
|
|
class CKeyID : public uint160
|
|
|
|
class CKeyID : public uint160
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -205,9 +207,33 @@ struct CExtPubKey {
|
|
|
|
a.chaincode == b.chaincode && a.pubkey == b.pubkey;
|
|
|
|
a.chaincode == b.chaincode && a.pubkey == b.pubkey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Encode(unsigned char code[74]) const;
|
|
|
|
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const;
|
|
|
|
void Decode(const unsigned char code[74]);
|
|
|
|
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
|
|
|
|
bool Derive(CExtPubKey& out, unsigned int nChild) const;
|
|
|
|
bool Derive(CExtPubKey& out, unsigned int nChild) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int GetSerializeSize(int nType, int nVersion) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return BIP32_EXTKEY_SIZE+1; //add one byte for the size (compact int)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Stream>
|
|
|
|
|
|
|
|
void Serialize(Stream& s, int nType, int nVersion) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned int len = BIP32_EXTKEY_SIZE;
|
|
|
|
|
|
|
|
::WriteCompactSize(s, len);
|
|
|
|
|
|
|
|
unsigned char code[BIP32_EXTKEY_SIZE];
|
|
|
|
|
|
|
|
Encode(code);
|
|
|
|
|
|
|
|
s.write((const char *)&code[0], len);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Stream>
|
|
|
|
|
|
|
|
void Unserialize(Stream& s, int nType, int nVersion)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned int len = ::ReadCompactSize(s);
|
|
|
|
|
|
|
|
unsigned char code[BIP32_EXTKEY_SIZE];
|
|
|
|
|
|
|
|
if (len != BIP32_EXTKEY_SIZE)
|
|
|
|
|
|
|
|
throw std::runtime_error("Invalid extended key size\n");
|
|
|
|
|
|
|
|
s.read((char *)&code[0], len);
|
|
|
|
|
|
|
|
Decode(code);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Users of this module must hold an ECCVerifyHandle. The constructor and
|
|
|
|
/** Users of this module must hold an ECCVerifyHandle. The constructor and
|
|
|
|