aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2021-12-10 14:50:02 +0100
committerAntoine Poinsot <darosior@protonmail.com>2022-07-14 12:03:49 +0200
commitc38c7c5817b7e73cf0f788855c4aba59c287b0ad (patch)
tree8b02cb4ff30e9ec7d25221b19fc3940a93bca389 /src/script
parent327b7e9236e3b0cde750df72d5f75821e52e545c (diff)
downloadbitcoin-c38c7c5817b7e73cf0f788855c4aba59c287b0ad.tar.xz
miniscript: don't check for top level validity at parsing time
Letting the caller perform the checks allows for finer-grained error reporting.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/miniscript.h10
1 files changed, 6 insertions, 4 deletions
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<NodeRef<Key>>& 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<typename Key, typename Ctx>
inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
{
@@ -1255,9 +1259,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
// Sanity checks on the produced miniscript
assert(constructed.size() == 1);
if (in.size() > 0) return {};
- const NodeRef<Key> 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.