From c38c7c5817b7e73cf0f788855c4aba59c287b0ad Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 10 Dec 2021 14:50:02 +0100 Subject: miniscript: don't check for top level validity at parsing time Letting the caller perform the checks allows for finer-grained error reporting. --- src/script/miniscript.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/script') diff --git a/src/script/miniscript.h b/src/script/miniscript.h index 2c239c2678..0137293180 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -953,7 +953,11 @@ void BuildBack(const Ctx& ctx, Fragment nt, std::vector>& construct } } -//! Parse a miniscript from its textual descriptor form. +/** + * Parse a miniscript from its textual descriptor form. + * This does not check whether the script is valid, let alone sane. The caller is expected to use + * the `IsValidTopLevel()` and `IsSaneTopLevel()` to check for these properties on the node. + */ template inline NodeRef Parse(Span in, const Ctx& ctx) { @@ -1255,9 +1259,7 @@ inline NodeRef Parse(Span in, const Ctx& ctx) // Sanity checks on the produced miniscript assert(constructed.size() == 1); if (in.size() > 0) return {}; - const NodeRef tl_node = std::move(constructed.front()); - if (!tl_node->IsValidTopLevel()) return {}; - return tl_node; + return std::move(constructed.front()); } /** Decode a script into opcode/push pairs. -- cgit v1.2.3