MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / DeserializeHDKeypaths

Function DeserializeHDKeypaths

src/script/sign.h:159–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157// Deserialize HD keypaths into a map
158template<typename Stream>
159void DeserializeHDKeypaths(Stream& s, const std::vector<unsigned char>& key, std::map<CPubKey, std::vector<uint32_t>>& hd_keypaths)
160{
161 // Make sure that the key is the size of pubkey + 1
162 if (key.size() != CPubKey::PUBLIC_KEY_SIZE + 1 && key.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE + 1) {
163 throw std::ios_base::failure("Size of key was not the expected size for the type BIP32 keypath");
164 }
165 // Read in the pubkey from key
166 CPubKey pubkey(key.begin() + 1, key.end());
167 if (!pubkey.IsFullyValid()) {
168 throw std::ios_base::failure("Invalid pubkey");
169 }
170 if (hd_keypaths.count(pubkey) > 0) {
171 throw std::ios_base::failure("Duplicate Key, pubkey derivation path already provided");
172 }
173
174 // Read in key path
175 uint64_t value_len = ReadCompactSize(s);
176 std::vector<uint32_t> keypath;
177 for (unsigned int i = 0; i < value_len; i += sizeof(uint32_t)) {
178 uint32_t index;
179 s >> index;
180 keypath.push_back(index);
181 }
182
183 // Add to map
184 hd_keypaths.emplace(pubkey, keypath);
185}
186
187// Serialize HD keypaths to a stream from a map
188template<typename Stream>

Callers 2

UnserializeMethod · 0.85
UnserializeMethod · 0.85

Calls 7

ReadCompactSizeFunction · 0.85
IsFullyValidMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
countMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected