mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 08:13:52 +02:00
miniscript: don't check for top level validity at parsing time
Letting the caller perform the checks allows for finer-grained error reporting.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user