diff --git a/bitcoin/script/miniscript.cpp b/bitcoin/script/miniscript.cpp index 21bc0d6..4b52f38 100644 --- a/bitcoin/script/miniscript.cpp +++ b/bitcoin/script/miniscript.cpp @@ -335,4 +335,3 @@ bool ParseScriptNumber(const std::pair>& } // namespace internal } // namespace miniscript - diff --git a/bitcoin/script/miniscript.h b/bitcoin/script/miniscript.h index 073544d..ccdb113 100644 --- a/bitcoin/script/miniscript.h +++ b/bitcoin/script/miniscript.h @@ -768,8 +768,11 @@ public: //! Return the expression type. Type GetType() const { return typ; } + //! Check whether this node is valid at all. + bool IsValid() const { return !(GetType() == ""_mst); } + //! Check whether this node is valid as a script on its own. - bool ValidTopLevel() const { return GetType() << "B"_mst; } + bool IsValidTopLevel() const { return GetType() << "B"_mst; } //! Check whether this script can always be satisfied in a non-malleable way. bool IsNonMalleable() const { return GetType() << "m"_mst; } @@ -777,6 +780,9 @@ public: //! Check whether this script always needs a signature. bool NeedsSignature() const { return GetType() << "s"_mst; } + //! Do all sanity checks. + bool IsSafeTopLevel() const { return GetType() << "Bms"_mst && CheckOpsLimit() && CheckStackSize(); } + //! Construct the script for this miniscript (including subexpressions). template CScript ToScript(const Ctx& ctx) const { return MakeScript(ctx); } diff --git a/bitcoin/test/miniscript_tests.cpp b/bitcoin/test/miniscript_tests.cpp index 31d4cb3..5f89694 100644 --- a/bitcoin/test/miniscript_tests.cpp +++ b/bitcoin/test/miniscript_tests.cpp @@ -6,14 +6,15 @@ #include #include -#include -#include -#include - #include #include -#include +#include +#include +#include +#include +#include +#include #include