# Path: electrumx/lib/hash.py
# def double_sha256(x):
#     '''SHA-256 of SHA-256, as used extensively in bitcoin.'''
#     return sha256(sha256(x))
# 
# def hash_to_hex_str(x):
#     '''Convert a big-endian binary hash to displayed hex string.
# 
#     Display form of a binary hash is reversed and converted to hex.
#     '''
#     return bytes(reversed(x)).hex()
# 
# Path: electrumx/lib/util.py
# class ConnectionLogger(logging.LoggerAdapter):
# class CompactFormatter(logging.Formatter):
# class cachedproperty(object):
# class LogicalFile(object):
#     def process(self, msg, kwargs):
#     def format(self, record):
# def make_logger(name, *, handler, level):
# def class_logger(path, classname):
#     def __init__(self, f):
#     def __get__(self, obj, type_):
# def formatted_time(t, sep=' '):
# def deep_getsizeof(obj):
#     def size(o):
# def subclasses(base_class, strict=True):
#     def select(obj):
# def chunks(items, size):
# def resolve_limit(limit):
# def bytes_to_int(be_bytes):
# def int_to_bytes(value):
# def increment_byte_string(bs):
#     def __init__(self, prefix, digits, file_size):
#     def read(self, start, size=-1):
#     def write(self, start, b):
#     def open_file(self, start, create):
# def open_file(filename, create=False):
# def open_truncate(filename):
# def address_string(address):
# def protocol_tuple(s):
# def version_string(ptuple):
# def protocol_version(client_req, min_tuple, max_tuple):
# def pack_varint(n):
# def pack_varbytes(data):


from collections import namedtuple
from electrumx.lib.hash import double_sha256, hash_to_hex_str
from electrumx.lib.util import (
    unpack_le_int32_from, unpack_le_int64_from, unpack_le_uint16_from,
    unpack_be_uint16_from,
    unpack_le_uint32_from, unpack_le_uint64_from, pack_le_int32, pack_varint,
    pack_le_uint32, pack_le_int64, pack_varbytes,
)
# Copyright (c) 2016-2021, Neil Booth
# Copyright (c) 2017, the ElectrumX authors
#
# All rights reserved.
#
# This file is licensed under the Open BSV License version 3, see LICENCE for details.

'''Transaction-related classes and functions.'''



ZERO = bytes(32)
MINUS_1 = 4294967295


class Tx(namedtuple("Tx", "version inputs outputs locktime")):
    '''Class representing a transaction.'''

    def serialize(self):
        return b''.join((
            pack_le_int32(self.version),
            pack_varint(len(self.inputs)),
            b''.join(tx_in.serialize() for tx_in in self.inputs),

# Path: electrumx/lib/hash.py
# def double_sha256(x):
#     '''SHA-256 of SHA-256, as used extensively in bitcoin.'''
#     return sha256(sha256(x))
# 
# def hash_to_hex_str(x):
#     '''Convert a big-endian binary hash to displayed hex string.
# 
#     Display form of a binary hash is reversed and converted to hex.
#     '''
#     return bytes(reversed(x)).hex()
# 
# Path: electrumx/lib/util.py
# class ConnectionLogger(logging.LoggerAdapter):
# class CompactFormatter(logging.Formatter):
# class cachedproperty(object):
# class LogicalFile(object):
#     def process(self, msg, kwargs):
#     def format(self, record):
# def make_logger(name, *, handler, level):
# def class_logger(path, classname):
#     def __init__(self, f):
#     def __get__(self, obj, type_):
# def formatted_time(t, sep=' '):
# def deep_getsizeof(obj):
#     def size(o):
# def subclasses(base_class, strict=True):
#     def select(obj):
# def chunks(items, size):
# def resolve_limit(limit):
# def bytes_to_int(be_bytes):
# def int_to_bytes(value):
# def increment_byte_string(bs):
#     def __init__(self, prefix, digits, file_size):
#     def read(self, start, size=-1):
#     def write(self, start, b):
#     def open_file(self, start, create):
# def open_file(filename, create=False):
# def open_truncate(filename):
# def address_string(address):
# def protocol_tuple(s):
# def version_string(ptuple):
# def protocol_version(client_req, min_tuple, max_tuple):
# def pack_varint(n):
# def pack_varbytes(data):


# Path: electrumx/lib/tx.py
from collections import namedtuple
from electrumx.lib.hash import double_sha256, hash_to_hex_str
from electrumx.lib.util import (
    unpack_le_int32_from, unpack_le_int64_from, unpack_le_uint16_from,
    unpack_be_uint16_from,
    unpack_le_uint32_from, unpack_le_uint64_from, pack_le_int32, pack_varint,
    pack_le_uint32, pack_le_int64, pack_varbytes,
)

# Copyright (c) 2016-2021, Neil Booth
# Copyright (c) 2017, the ElectrumX authors
#
# All rights reserved.
#
# This file is licensed under the Open BSV License version 3, see LICENCE for details.

'''Transaction-related classes and functions.'''



ZERO = bytes(32)
MINUS_1 = 4294967295


class Tx(namedtuple("Tx", "version inputs outputs locktime")):
    '''Class representing a transaction.'''

    def serialize(self):
        return b''.join((
            pack_le_int32(self.version),
            pack_varint(len(self.inputs)),
            b''.join(tx_in.serialize() for tx_in in self.inputs),

            pack_varint(len(self.outputs)),