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)
| 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]. """ |
no test coverage detected