def encode_fallback(fallback: str, net: Type[AbstractNet]):
    ' Encode all supported fallback addresses.\n    '
    (wver, wprog_ints) = segwit_addr.decode_segwit_address(net.SEGWIT_HRP, fallback)
    if (wver is not None):
        wprog = bytes(wprog_ints)
    else:
        (addrtype, addr) = b58_address_to_hash160(fallback)
        if (addrtype == net.ADDRTYPE_P2PKH):
            wver = 17
        elif (addrtype == net.ADDRTYPE_P2SH):
            wver = 18
        else:
            raise LnEncodeException(f'Unknown address type {addrtype} for {net}')
        wprog = addr
    return tagged('f', (bitstring.pack('uint:5', wver) + wprog))
Encode all supported fallback addresses.
def encode_fallback(fallback: str, net: Type[AbstractNet]):
    ' \n    '
    (wver, wprog_ints) = segwit_addr.decode_segwit_address(net.SEGWIT_HRP, fallback)
    if (wver is not None):
        wprog = bytes(wprog_ints)
    else:
        (addrtype, addr) = b58_address_to_hash160(fallback)
        if (addrtype == net.ADDRTYPE_P2PKH):
            wver = 17
        elif (addrtype == net.ADDRTYPE_P2SH):
            wver = 18
        else:
            raise LnEncodeException(f'Unknown address type {addrtype} for {net}')
        wprog = addr
    return tagged('f', (bitstring.pack('uint:5', wver) + wprog))