MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / is_witness_scriptpubkey

Method is_witness_scriptpubkey

bitcoin/core/script.py:673–690  ·  view source on GitHub ↗

Returns true if this is a scriptpubkey signaling segregated witness data. 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.

(self)

Source from the content-addressed store, hash-verified

671 self[22] == OP_EQUAL)
672
673 def is_witness_scriptpubkey(self):
674 """Returns true if this is a scriptpubkey signaling segregated witness data.
675
676 A witness program is any valid CScript that consists of a 1-byte push opcode
677 followed by a data push between 2 and 40 bytes.
678 """
679 size = len(self)
680 if size < 4 or size > 42:
681 return False
682
683 head = struct.unpack('<bb', self[:2])
684 if not CScriptOp(head[0]).is_small_int():
685 return False
686
687 if head[1] + 2 != size:
688 return False
689
690 return True
691
692 def witness_version(self):
693 """Returns the witness version on [0,16]. """

Callers 1

SignatureHashFunction · 0.80

Calls 2

CScriptOpClass · 0.85
is_small_intMethod · 0.80

Tested by

no test coverage detected