We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
CScript
1 parent cac29f5 commit 8a5dbe2Copy full SHA for 8a5dbe2
test/functional/test_framework/script.py
@@ -597,6 +597,13 @@ def GetSigOpCount(self, fAccurate):
597
lastOpcode = opcode
598
return n
599
600
+ def IsWitnessProgram(self):
601
+ """A witness program is any valid CScript that consists of a 1-byte
602
+ push opcode followed by a data push between 2 and 40 bytes."""
603
+ return ((4 <= len(self) <= 42) and
604
+ (self[0] == OP_0 or (OP_1 <= self[0] <= OP_16)) and
605
+ (self[1] + 2 == len(self)))
606
+
607
608
SIGHASH_DEFAULT = 0 # Taproot-only default, semantics same as SIGHASH_ALL
609
SIGHASH_ALL = 1
0 commit comments