mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 829d3e0e71 into merged_master (Bitcoin PR bitcoin/bitcoin#23199)
This commit is contained in:
commit
bedb85c8c6
3 changed files with 5 additions and 10 deletions
|
|
@ -361,8 +361,7 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
|
|||
void CExtPubKey::Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const {
|
||||
code[0] = nDepth;
|
||||
memcpy(code+1, vchFingerprint, 4);
|
||||
code[5] = (nChild >> 24) & 0xFF; code[6] = (nChild >> 16) & 0xFF;
|
||||
code[7] = (nChild >> 8) & 0xFF; code[8] = (nChild >> 0) & 0xFF;
|
||||
WriteBE32(code+5, nChild);
|
||||
memcpy(code+9, chaincode.begin(), 32);
|
||||
assert(pubkey.size() == CPubKey::COMPRESSED_SIZE);
|
||||
memcpy(code+41, pubkey.begin(), CPubKey::COMPRESSED_SIZE);
|
||||
|
|
@ -371,7 +370,7 @@ void CExtPubKey::Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const {
|
|||
void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) {
|
||||
nDepth = code[0];
|
||||
memcpy(vchFingerprint, code+1, 4);
|
||||
nChild = (code[5] << 24) | (code[6] << 16) | (code[7] << 8) | code[8];
|
||||
nChild = ReadBE32(code+5);
|
||||
memcpy(chaincode.begin(), code+9, 32);
|
||||
pubkey.Set(code+41, code+BIP32_EXTKEY_SIZE);
|
||||
if ((nDepth == 0 && (nChild != 0 || ReadLE32(vchFingerprint) != 0)) || !pubkey.IsFullyValid()) pubkey = CPubKey();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue