import struct from typing import NamedTuple, List from chiabip158 import PyBIP158 # pylint: disable=no-name-in-module from lbry.crypto.hash import double_sha256 from lbry.blockchain.transaction import Transaction from lbry.blockchain.bcd_data_stream import BCDataStream ZERO_BLOCK = bytes((0,)*32) def create_address_filter(address_hashes: List[bytes]) -> bytes: return bytes(PyBIP158([bytearray(a) for a in address_hashes]).GetEncoded()) def get_address_filter(address_filter: bytes) -> PyBIP158: return PyBIP158(bytearray(address_filter)) class Block(NamedTuple): height: int version: int file_number: int block_hash: bytes prev_block_hash: bytes merkle_root: bytes claim_trie_root: bytes timestamp: int bits: int nonce: int txs: List[Transaction] @staticmethod def from_data_stream(stream: BCDataStream, height: int, file_number: int): header = stream.data.read(112) version, = struct.unpack('