aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/script.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-12-04 03:04:39 +0100
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-12-04 03:07:42 +0100
commit8a5dbe28793d2e2ad85242f2191a6e1956b980dc (patch)
treec701dbe31c9758007f6c16d4f212b805df04facb /test/functional/test_framework/script.py
parentcac29f5cd66f005ce65edd697990d495a904a1f1 (diff)
downloadbitcoin-8a5dbe28793d2e2ad85242f2191a6e1956b980dc.tar.xz
test: add `CScript` method for checking for witness program
This is needed in the next commit to calculate the dust threshold for a given output script and min feerate for defining dust.
Diffstat (limited to 'test/functional/test_framework/script.py')
-rw-r--r--test/functional/test_framework/script.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index f531ccc030..897ebd694d 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -597,6 +597,13 @@ class CScript(bytes):
lastOpcode = opcode
return n
+ def IsWitnessProgram(self):
+ """A witness program is any valid CScript that consists of a 1-byte
+ push opcode followed by a data push between 2 and 40 bytes."""
+ return ((4 <= len(self) <= 42) and
+ (self[0] == OP_0 or (OP_1 <= self[0] <= OP_16)) and
+ (self[1] + 2 == len(self)))
+
SIGHASH_DEFAULT = 0 # Taproot-only default, semantics same as SIGHASH_ALL
SIGHASH_ALL = 1