INNER CODE UNIT · Python

max_accumulator

bee-san/pyWhat · pywhat/bitcoin.py:84

    max_accumulator = (1 << (from_bits + to_bits - 1)) - 1
    for value in data:
        accumulator = ((accumulator << from_bits) | value) & max_accumulator
        bits += from_bits
        while bits >= to_bits:
            bits -= to_bits
            result.append((accumulator >> bits) & max_value)
    if bits >= from_bits or (accumulator << (to_bits - bits)) & max_value:
        return None
    return result


def segwit_decode(address: str) -> Optional[Tuple[str, int, bytes]]:
    """
    The human-readable part, the witness version and the witness program of a
    SegWit address, or None if it is not one (BIP 173 and BIP 350).
    """
    if len(address) > 90 or any(not 33 <= ord(char) <= 126 for char in address):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…