0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

[tests] fix flake8 warnings in script.py and bignum.py

This commit is contained in:
John Newbery 2019-10-30 10:13:17 -04:00
parent 6a97e8a060
commit f31fc0e92e
2 changed files with 144 additions and 141 deletions

View file

@ -4,19 +4,18 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Big number routines.
Functions for converting numbers to MPI format and Bitcoin-specific little
endian format.
This file is copied from python-bitcoinlib.
"""
import struct
# generic big endian MPI format
def bn_bytes(v, have_ext=False):
ext = 0
if have_ext:
ext = 1
return ((v.bit_length()+7)//8) + ext
return (v.bit_length() + 7) // 8 + ext
def bn2bin(v):
s = bytearray()

View file

@ -6,16 +6,21 @@
This file is modified from python-bitcoinlib.
"""
from .messages import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string
import hashlib
import struct
from .bignum import bn2vch
from .messages import (
CTransaction,
CTxOut,
hash256,
ser_string,
ser_uint256,
sha256,
uint256_from_str,
)
MAX_SCRIPT_ELEMENT_SIZE = 520
OPCODE_NAMES = {}
def hash160(s):
@ -506,7 +511,6 @@ class CScript(bytes):
else:
assert False # shouldn't happen
data = bytes(self[i:i + datasize])
# Check for truncation