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

Function ParseKeyPath

src/script/descriptor.cpp:909–929  ·  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

907
908/** Parse a key path, being passed a split list of elements (the first element is ignored). */
909[[nodiscard]] bool ParseKeyPath(const std::vector<Span<const char>>& split, KeyPath& out, std::string& error)
910{
911 for (size_t i = 1; i < split.size(); ++i) {
912 Span<const char> elem = split[i];
913 bool hardened = false;
914 if (elem.size() > 0 && (elem[elem.size() - 1] == '\'' || elem[elem.size() - 1] == 'h')) {
915 elem = elem.first(elem.size() - 1);
916 hardened = true;
917 }
918 uint32_t p;
919 if (!ParseUInt32(std::string(elem.begin(), elem.end()), &p)) {
920 error = strprintf("Key path value '%s' is not a valid uint32", std::string(elem.begin(), elem.end()));
921 return false;
922 } else if (p > 0x7FFFFFFFUL) {
923 error = strprintf("Key path value %u is out of range", p);
924 return false;
925 }
926 out.push_back(p | (((uint32_t)hardened) << 31));
927 }
928 return true;
929}
930
931/** Parse a public key that excludes origin information. */
932std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, std::string& error)

Callers 2

ParsePubkeyInnerFunction · 0.70
ParsePubkeyFunction · 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