aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.cpp
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.cpp
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.cpp')
-rw-r--r--src/pubkey.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pubkey.cpp b/src/pubkey.cpp
index 956ff2b34a..b7dfb6d83f 100644
--- a/src/pubkey.cpp
+++ b/src/pubkey.cpp
@@ -352,6 +352,18 @@ void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) {
if ((nDepth == 0 && (nChild != 0 || ReadLE32(vchFingerprint) != 0)) || !pubkey.IsFullyValid()) pubkey = CPubKey();
}
+void CExtPubKey::EncodeWithVersion(unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE]) const
+{
+ memcpy(code, version, 4);
+ Encode(&code[4]);
+}
+
+void CExtPubKey::DecodeWithVersion(const unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE])
+{
+ memcpy(version, code, 4);
+ Decode(&code[4]);
+}
+
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
out.nDepth = nDepth + 1;
CKeyID id = pubkey.GetID();