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

Function ParseKeyPath

src/wallet/rpc/elements.cpp:529–543  ·  view source on GitHub ↗

Parse a key path, being passed a split list of elements (the first element is ignored). */

Source from the content-addressed store, hash-verified

527
528/** Parse a key path, being passed a split list of elements (the first element is ignored). */
529bool ParseKeyPath(const std::vector<Span<const char>>& split, KeyPath& out)
530{
531 for (size_t i = 1; i < split.size(); ++i) {
532 Span<const char> elem = split[i];
533 bool hardened = false;
534 if (elem.size() > 0 && (elem[elem.size() - 1] == '\'' || elem[elem.size() - 1] == 'h')) {
535 elem = elem.first(elem.size() - 1);
536 hardened = true;
537 }
538 uint32_t p;
539 if (!ParseUInt32(std::string(elem.begin(), elem.end()), &p) || p > 0x7FFFFFFFUL) return false;
540 out.push_back(p | (((uint32_t)hardened) << 31));
541 }
542 return true;
543}
544
545////////////////////////////
546

Callers 1

sendtomainchain_pakFunction · 0.70

Calls 5

ParseUInt32Function · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected