Test if script only uses canonical pushes Not yet consensus critical; may be in the future.
(self)
| 728 | return True |
| 729 | |
| 730 | def has_canonical_pushes(self): |
| 731 | """Test if script only uses canonical pushes |
| 732 | |
| 733 | Not yet consensus critical; may be in the future. |
| 734 | """ |
| 735 | try: |
| 736 | for (op, data, idx) in self.raw_iter(): |
| 737 | if op > OP_16: |
| 738 | continue |
| 739 | |
| 740 | elif op < OP_PUSHDATA1 and op > OP_0 and len(data) == 1 and data[0] <= 16: |
| 741 | # Could have used an OP_n code, rather than a 1-byte push. |
| 742 | return False |
| 743 | |
| 744 | elif op == OP_PUSHDATA1 and len(data) < OP_PUSHDATA1: |
| 745 | # Could have used a normal n-byte push, rather than OP_PUSHDATA1. |
| 746 | return False |
| 747 | |
| 748 | elif op == OP_PUSHDATA2 and len(data) <= 0xFF: |
| 749 | # Could have used a OP_PUSHDATA1. |
| 750 | return False |
| 751 | |
| 752 | elif op == OP_PUSHDATA4 and len(data) <= 0xFFFF: |
| 753 | # Could have used a OP_PUSHDATA2. |
| 754 | return False |
| 755 | |
| 756 | except CScriptInvalidError: # Invalid pushdata |
| 757 | return False |
| 758 | return True |
| 759 | |
| 760 | def is_unspendable(self): |
| 761 | """Test if the script is provably unspendable""" |