Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/script.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Functionality to build scripts, as well as SignatureHash(). | """Functionality to build scripts, as well as SignatureHash(). | ||||
This file is modified from python-bitcoinlib. | This file is modified from python-bitcoinlib. | ||||
""" | """ | ||||
from .bignum import bn2vch | from .bignum import bn2vch | ||||
from binascii import hexlify | |||||
import hashlib | import hashlib | ||||
import struct | import struct | ||||
from .messages import ( | from .messages import ( | ||||
CTransaction, | CTransaction, | ||||
CTxOut, | CTxOut, | ||||
hash256, | hash256, | ||||
ser_string, | ser_string, | ||||
▲ Show 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | def __iter__(self): | ||||
if opcode.is_small_int(): | if opcode.is_small_int(): | ||||
yield opcode.decode_op_n() | yield opcode.decode_op_n() | ||||
else: | else: | ||||
yield CScriptOp(opcode) | yield CScriptOp(opcode) | ||||
def __repr__(self): | def __repr__(self): | ||||
def _repr(o): | def _repr(o): | ||||
if isinstance(o, bytes): | if isinstance(o, bytes): | ||||
return "x('{}')".format(hexlify(o).decode('ascii')) | return "x('{}')".format(o.hex()) | ||||
else: | else: | ||||
return repr(o) | return repr(o) | ||||
ops = [] | ops = [] | ||||
i = iter(self) | i = iter(self) | ||||
while True: | while True: | ||||
op = None | op = None | ||||
try: | try: | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |