def encode_address(address: int) -> bytes:
    """Encodes an HDLC address as a one-terminated LSB varint."""
    result = bytearray()

    while True:
        result += bytes([(address & 0x7f) << 1])

        address >>= 7
        if address == 0:
            break

    result[-1] |= 0x1
    return result