Skip to content

Commit ef67458

Browse files
committed
key: Add constructor for CExtKey that takes CExtPubKey and CKey
We often need to construct a CExtKey given an CExtPubKey and CKey, so implement a constructor that does that for us.
1 parent 45b2a91 commit ef67458

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/key.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ struct CExtKey {
223223
a.key == b.key;
224224
}
225225

226+
CExtKey() = default;
227+
CExtKey(const CExtPubKey& xpub, const CKey& key_in) : nDepth(xpub.nDepth), nChild(xpub.nChild), chaincode(xpub.chaincode), key(key_in)
228+
{
229+
std::copy(xpub.vchFingerprint, xpub.vchFingerprint + sizeof(xpub.vchFingerprint), vchFingerprint);
230+
}
231+
226232
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const;
227233
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
228234
[[nodiscard]] bool Derive(CExtKey& out, unsigned int nChild) const;

0 commit comments

Comments
 (0)