Parse a key path, being passed a split list of elements (the first element is ignored). */
| 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. */ |
| 932 | std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, std::string& error) |
no test coverage detected