mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
[tests] fix flake8 warnings in script.py and bignum.py
This commit is contained in:
parent
6a97e8a060
commit
f31fc0e92e
2 changed files with 144 additions and 141 deletions
|
@ -4,19 +4,18 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Big number routines.
|
"""Big number routines.
|
||||||
|
|
||||||
|
Functions for converting numbers to MPI format and Bitcoin-specific little
|
||||||
|
endian format.
|
||||||
|
|
||||||
This file is copied from python-bitcoinlib.
|
This file is copied from python-bitcoinlib.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
# generic big endian MPI format
|
|
||||||
|
|
||||||
def bn_bytes(v, have_ext=False):
|
def bn_bytes(v, have_ext=False):
|
||||||
ext = 0
|
ext = 0
|
||||||
if have_ext:
|
if have_ext:
|
||||||
ext = 1
|
ext = 1
|
||||||
return ((v.bit_length()+7)//8) + ext
|
return (v.bit_length() + 7) // 8 + ext
|
||||||
|
|
||||||
def bn2bin(v):
|
def bn2bin(v):
|
||||||
s = bytearray()
|
s = bytearray()
|
||||||
|
|
|
@ -6,16 +6,21 @@
|
||||||
|
|
||||||
This file is modified from python-bitcoinlib.
|
This file is modified from python-bitcoinlib.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .messages import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from .bignum import bn2vch
|
from .bignum import bn2vch
|
||||||
|
from .messages import (
|
||||||
|
CTransaction,
|
||||||
|
CTxOut,
|
||||||
|
hash256,
|
||||||
|
ser_string,
|
||||||
|
ser_uint256,
|
||||||
|
sha256,
|
||||||
|
uint256_from_str,
|
||||||
|
)
|
||||||
|
|
||||||
MAX_SCRIPT_ELEMENT_SIZE = 520
|
MAX_SCRIPT_ELEMENT_SIZE = 520
|
||||||
|
|
||||||
OPCODE_NAMES = {}
|
OPCODE_NAMES = {}
|
||||||
|
|
||||||
def hash160(s):
|
def hash160(s):
|
||||||
|
@ -506,7 +511,6 @@ class CScript(bytes):
|
||||||
else:
|
else:
|
||||||
assert False # shouldn't happen
|
assert False # shouldn't happen
|
||||||
|
|
||||||
|
|
||||||
data = bytes(self[i:i + datasize])
|
data = bytes(self[i:i + datasize])
|
||||||
|
|
||||||
# Check for truncation
|
# Check for truncation
|
||||||
|
|
Loading…
Add table
Reference in a new issue