MCPcopy Create free account
hub / github.com/ElementsProject/elements / DeserializeHDKeypaths

Function DeserializeHDKeypaths

src/psbt.h:183–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181// Deserialize HD keypaths into a map
182template<typename Stream>
183void DeserializeHDKeypaths(Stream& s, const std::vector<unsigned char>& key, std::map<CPubKey, KeyOriginInfo>& hd_keypaths)
184{
185 // Make sure that the key is the size of pubkey + 1
186 if (key.size() != CPubKey::SIZE + 1 && key.size() != CPubKey::COMPRESSED_SIZE + 1) {
187 throw std::ios_base::failure("Size of key was not the expected size for the type BIP32 keypath");
188 }
189 // Read in the pubkey from key
190 CPubKey pubkey(key.begin() + 1, key.end());
191 if (!pubkey.IsFullyValid()) {
192 throw std::ios_base::failure("Invalid pubkey");
193 }
194 if (hd_keypaths.count(pubkey) > 0) {
195 throw std::ios_base::failure("Duplicate Key, pubkey derivation path already provided");
196 }
197
198 KeyOriginInfo keypath;
199 DeserializeHDKeypath(s, keypath);
200
201 // Add to map
202 hd_keypaths.emplace(pubkey, std::move(keypath));
203}
204
205// Serialize an individual HD keypath to a stream
206template<typename Stream>

Callers 3

UnserializeMethod · 0.85
UnserializeMethod · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 6

DeserializeHDKeypathFunction · 0.85
IsFullyValidMethod · 0.80
countMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.68