Skip to content

Commit 5cea85f

Browse files
darosiorsipa
andcommitted
miniscript: split ValidSatisfactions from IsSane
This makes IsSane clearer. It is useful to differentiate between 'potential non-malleable satisfactions are valid' and 'such satisfactions exist' for testing. Co-authored-by: Pieter Wuille <[email protected]>
1 parent a0f064d commit 5cea85f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/script/miniscript.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,11 @@ struct Node {
779779
//! Check whether there is no satisfaction path that contains both timelocks and heightlocks
780780
bool CheckTimeLocksMix() const { return GetType() << "k"_mst; }
781781

782-
//! Do all sanity checks.
783-
bool IsSane() const { return IsValid() && IsNonMalleable() && CheckTimeLocksMix() && CheckOpsLimit() && CheckStackSize(); }
782+
//! Whether successful non-malleable satisfactions are guaranteed to be valid.
783+
bool ValidSatisfactions() const { return IsValid() && CheckOpsLimit() && CheckStackSize(); }
784+
785+
//! Whether the apparent policy of this node matches its script semantics.
786+
bool IsSane() const { return ValidSatisfactions() && IsNonMalleable() && CheckTimeLocksMix(); }
784787

785788
//! Check whether this node is safe as a script on its own.
786789
bool IsSaneTopLevel() const { return IsValidTopLevel() && IsSane() && NeedsSignature(); }

0 commit comments

Comments
 (0)