aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-07-25 11:28:57 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-12-10 08:29:47 -0500
commita69332fd89a5c1e293113b641fbe6b23cf279741 (patch)
tree28aa497082a3fdb8733be10d3d97b80f0d716680 /src/pubkey.h
parent5fdaf6a2adbf99c4ab2c2863fba35a0baa559fb5 (diff)
downloadbitcoin-a69332fd89a5c1e293113b641fbe6b23cf279741.tar.xz
Store version bytes and be able to serialize them in CExtPubKey
CExtPubKey does not store the version bytes for the extended public key. We store these so that a CExtPubKey can be serialized and deserialized with the same version bytes.
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h
index 2453c92d92..f37e24bc47 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -17,6 +17,7 @@
#include <vector>
const unsigned int BIP32_EXTKEY_SIZE = 74;
+const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE = 78;
/** A reference to a CKey: the Hash160 of its serialized public key */
class CKeyID : public uint160
@@ -283,6 +284,7 @@ public:
};
struct CExtPubKey {
+ unsigned char version[4];
unsigned char nDepth;
unsigned char vchFingerprint[4];
unsigned int nChild;
@@ -305,6 +307,8 @@ struct CExtPubKey {
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const;
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
+ void EncodeWithVersion(unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE]) const;
+ void DecodeWithVersion(const unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE]);
bool Derive(CExtPubKey& out, unsigned int nChild) const;
};