INNER CODE UNIT · Python
max_value
bee-san/pyWhat · pywhat/bitcoin.py:83
max_value = (1 << to_bits) - 1
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).
"""