def program_to_witness(version, program, main=False):
    if (type(program) is str):
        program = hex_str_to_bytes(program)
    assert (0 <= version <= 16)
    assert (2 <= len(program) <= 40)
    assert ((version > 0) or (len(program) in [20, 32]))
    return segwit_addr.encode(('xpc' if main else 'xpcrt'), version, program)
def program_to_witness(version, program, main=False):
    if (type(program) is str):
        program = hex_str_to_bytes(program)
    assert (0 <= version <= 16)
    assert (2 <= len(program) <= 40)
    assert ((version > 0) or (len(program) in [20, 32]))
    return segwit_addr.encode(('xpc' if main else 'xpcrt'), version, program)