mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
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.
This commit is contained in:
parent
cac29f5cd6
commit
8a5dbe2879
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue