| 1823 | /** Parse a hex string fully contained within a fragment with the name given by 'func' */ |
| 1824 | template<typename Ctx> |
| 1825 | std::optional<std::vector<unsigned char>> ParseHexStr(const std::string& func, std::span<const char>& in, const size_t expected_size, |
| 1826 | const Ctx& ctx) |
| 1827 | { |
| 1828 | std::span<const char> expr = script::Expr(in); |
| 1829 | if (!script::Func(func, expr)) return {}; |
| 1830 | std::string val = std::string(expr.begin(), expr.end()); |
| 1831 | if (!IsHex(val)) return {}; |
| 1832 | auto hash = ParseHex(val); |
| 1833 | if (hash.size() != expected_size) return {}; |
| 1834 | return hash; |
| 1835 | } |
| 1836 | |
| 1837 | /** BuildBack pops the last two elements off `constructed` and wraps them in the specified Fragment */ |
| 1838 | template<typename Key> |