test/functional/test_framework/cashaddr.py
def _convertbits(data, frombits, tobits, pad=True):
    """General power-of-2 base conversion."""
    acc = 0
    bits = 0
    ret = bytearray()
    maxv = (1 << tobits) - 1
    max_acc = (1 << (frombits + tobits - 1)) - 1
    for value in data:
        acc = ((acc << frombits) | value) & max_acc
        bits += frombits
        while bits >= tobits:
            bits -= tobits
            ret.append((acc >> bits) & maxv)

    if pad and bits:
        ret.append((acc << (tobits - bits)) & maxv)

    return ret
General power-of-2 base conversion.
General power-of-2 base conversion.
General power - of - 2 base conversion .
def _convertbits(data, frombits, tobits, pad=True):
    acc = 0
    bits = 0
    ret = bytearray()
    maxv = (1 << tobits) - 1
    max_acc = (1 << (frombits + tobits - 1)) - 1
    for value in data:
        acc = ((acc << frombits) | value) & max_acc
        bits += frombits
        while bits >= tobits:
            bits -= tobits
            ret.append((acc >> bits) & maxv)
    if pad and bits:
        ret.append((acc << (tobits - bits)) & maxv)
    return ret
def _convertbits ( data , frombits , tobits , pad = True ) : acc = 0 bits = 0 ret = bytearray ( ) maxv = ( 1 << tobits ) - 1 max_acc = ( 1 << ( frombits + tobits - 1 ) ) - 1 for value in data : acc = ( ( acc << frombits ) | value ) & max_acc bits += frombits while bits >= tobits : bits -= tobits ret . append ( ( acc >> bits ) & maxv ) if pad and bits : ret . append ( ( acc << ( tobits - bits ) ) & maxv ) return ret
General power-of-2 base conversion.
General power - of - 2 base conversion .
"""General power-of-2 base conversion."""
data
frombits
tobits
pad