INNER CODE UNIT · Python

base58check_decode

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

def base58check_decode(text: str) -> Optional[bytes]:
    """The payload of Base58Check text, or None if its checksum is wrong."""
    try:
        decoded = base58_decode(text)
    except ValueError:
        return None
    if len(decoded) < 4:
        return None
    payload, checksum = decoded[:-4], decoded[-4:]
    if hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:4] != checksum:
        return None
    return payload


def bech32_polymod(values: Sequence[int]) -> int:
    """The checksum of Bech32 and Bech32m, a BCH code (BIP 173)."""
    checksum = 1
    for value in values:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…