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 .mininode import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string | from .mininode import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string | ||||
from .bignum import bn2vch | |||||
from binascii import hexlify | from binascii import hexlify | ||||
import hashlib | import hashlib | ||||
import struct | |||||
import sys | import sys | ||||
bchr = chr | bchr = chr | ||||
bord = ord | bord = ord | ||||
if sys.version > '3': | if sys.version > '3': | ||||
long = int | long = int | ||||
def bchr(x): return bytes([x]) | def bchr(x): return bytes([x]) | ||||
def bord(x): return x | def bord(x): return x | ||||
import struct | |||||
from .bignum import bn2vch | |||||
MAX_SCRIPT_ELEMENT_SIZE = 520 | MAX_SCRIPT_ELEMENT_SIZE = 520 | ||||
OPCODE_NAMES = {} | OPCODE_NAMES = {} | ||||
def hash160(s): | def hash160(s): | ||||
return hashlib.new('ripemd160', sha256(s)).digest() | return hashlib.new('ripemd160', sha256(s)).digest() | ||||
▲ Show 20 Lines • Show All 692 Lines • Show Last 20 Lines |