From: Matt Corallo Date: Tue, 20 Oct 2020 01:45:23 +0000 (+0000) Subject: Rewrite the world, with several interdependant changes (but several still WIP) X-Git-Tag: v0.0.1~99 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=110f2f104ba8fc34caa7e34e04737f36f064b050;p=ldk-java Rewrite the world, with several interdependant changes (but several still WIP) --- diff --git a/genbindings.py b/genbindings.py index cc03661a..e139af0c 100755 --- a/genbindings.py +++ b/genbindings.py @@ -6,8 +6,19 @@ if len(sys.argv) != 6: print("debug should be true or false and indicates whether to track allocations and ensure we don't leak") sys.exit(1) +hu_struct_file_prefix = """package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +""" + class TypeInfo: - def __init__(self, rust_obj, java_ty, java_fn_ty_arg, java_hu_ty, c_ty, passed_as_ptr, is_ptr, var_name, arr_len, arr_access): + def __init__(self, is_native_primitive, rust_obj, java_ty, java_fn_ty_arg, java_hu_ty, c_ty, passed_as_ptr, is_ptr, var_name, arr_len, arr_access, subty=None): + self.is_native_primitive = is_native_primitive self.rust_obj = rust_obj self.java_ty = java_ty self.java_hu_ty = java_hu_ty @@ -18,9 +29,11 @@ class TypeInfo: self.var_name = var_name self.arr_len = arr_len self.arr_access = arr_access + self.subty = subty + self.pass_by_ref = is_ptr class ConvInfo: - def __init__(self, ty_info, arg_name, arg_conv, arg_conv_name, arg_conv_cleanup, ret_conv, ret_conv_name, to_hu_conv, from_hu_conv): + def __init__(self, ty_info, arg_name, arg_conv, arg_conv_name, arg_conv_cleanup, ret_conv, ret_conv_name, to_hu_conv, to_hu_conv_name, from_hu_conv): assert(ty_info.c_ty is not None) assert(ty_info.java_ty is not None) assert(arg_name is not None) @@ -37,6 +50,7 @@ class ConvInfo: self.ret_conv = ret_conv self.ret_conv_name = ret_conv_name self.to_hu_conv = to_hu_conv + self.to_hu_conv_name = to_hu_conv_name self.from_hu_conv = from_hu_conv def print_ty(self): @@ -78,11 +92,14 @@ def camel_to_snake(s): return (ret + lastchar.lower()).strip("_") unitary_enums = set() +complex_enums = set() opaque_structs = set() trait_structs = set() +tuple_types = {} var_is_arr_regex = re.compile("\(\*([A-za-z0-9_]*)\)\[([a-z0-9]*)\]") var_ty_regex = re.compile("([A-za-z_0-9]*)(.*)") +java_c_types_none_allowed = True # Unset when we do the real pass that populates the above sets def java_c_types(fn_arg, ret_arr_len): fn_arg = fn_arg.strip() if fn_arg.startswith("MUST_USE_RES "): @@ -102,32 +119,47 @@ def java_c_types(fn_arg, ret_arr_len): assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKThirtyTwoBytes" arr_access = "data" - if fn_arg.startswith("LDKPublicKey"): + elif fn_arg.startswith("LDKPublicKey"): fn_arg = "uint8_t (*" + fn_arg[13:] + ")[33]" assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKPublicKey" arr_access = "compressed_form" - if fn_arg.startswith("LDKSecretKey"): + elif fn_arg.startswith("LDKSecretKey"): fn_arg = "uint8_t (*" + fn_arg[13:] + ")[32]" assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKSecretKey" arr_access = "bytes" - if fn_arg.startswith("LDKSignature"): + elif fn_arg.startswith("LDKSignature"): fn_arg = "uint8_t (*" + fn_arg[13:] + ")[64]" assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKSignature" arr_access = "compact_form" - if fn_arg.startswith("LDKThreeBytes"): + elif fn_arg.startswith("LDKThreeBytes"): fn_arg = "uint8_t (*" + fn_arg[14:] + ")[3]" assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKThreeBytes" arr_access = "data" - if fn_arg.startswith("LDKu8slice"): + elif fn_arg.startswith("LDKFourBytes"): + fn_arg = "uint8_t (*" + fn_arg[13:] + ")[4]" + assert var_is_arr_regex.match(fn_arg[8:]) + rust_obj = "LDKFourBytes" + arr_access = "data" + elif fn_arg.startswith("LDKSixteenBytes"): + fn_arg = "uint8_t (*" + fn_arg[16:] + ")[16]" + assert var_is_arr_regex.match(fn_arg[8:]) + rust_obj = "LDKSixteenBytes" + arr_access = "data" + elif fn_arg.startswith("LDKTenBytes"): + fn_arg = "uint8_t (*" + fn_arg[12:] + ")[10]" + assert var_is_arr_regex.match(fn_arg[8:]) + rust_obj = "LDKTenBytes" + arr_access = "data" + elif fn_arg.startswith("LDKu8slice"): fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]" assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKu8slice" arr_access = "data" - if fn_arg.startswith("LDKCVecTempl_u8") or fn_arg.startswith("LDKCVec_u8Z"): + elif fn_arg.startswith("LDKCVecTempl_u8") or fn_arg.startswith("LDKCVec_u8Z"): if fn_arg.startswith("LDKCVecTempl_u8"): fn_arg = "uint8_t (*" + fn_arg[16:] + ")[datalen]" rust_obj = "LDKCVecTempl_u8" @@ -137,32 +169,70 @@ def java_c_types(fn_arg, ret_arr_len): rust_obj = "LDKCVec_u8Z" assert var_is_arr_regex.match(fn_arg[8:]) arr_access = "data" + elif fn_arg.startswith("LDKCVecTempl_") or fn_arg.startswith("LDKCVec_"): + is_ptr = False + if "*" in fn_arg: + fn_arg = fn_arg.replace("*", "") + is_ptr = True + + if fn_arg.startswith("LDKCVec_"): + tyn = fn_arg[8:].split(" ") + assert tyn[0].endswith("Z") + if tyn[0] == "u64Z": + new_arg = "uint64_t" + else: + new_arg = "LDK" + tyn[0][:-1] + for a in tyn[1:]: + new_arg = new_arg + " " + a + res = java_c_types(new_arg, ret_arr_len) + else: + res = java_c_types("LDK" + fn_arg[13:], ret_arr_len) + if res is None: + assert java_c_types_none_allowed + return None + if is_ptr: + res.pass_by_ref = True + if res.is_native_primitive or res.passed_as_ptr: + return TypeInfo(rust_obj=fn_arg.split(" ")[0], java_ty=res.java_ty + "[]", java_hu_ty=res.java_hu_ty + "[]", + java_fn_ty_arg="[" + res.java_fn_ty_arg, c_ty=res.c_ty + "Array", passed_as_ptr=False, is_ptr=is_ptr, + var_name=res.var_name, arr_len="datalen", arr_access="data", subty=res, is_native_primitive=False) + else: + return TypeInfo(rust_obj=fn_arg.split(" ")[0], java_ty=res.java_ty + "[]", java_hu_ty=res.java_hu_ty + "[]", + java_fn_ty_arg="[" + res.java_fn_ty_arg, c_ty="jobjectArray", passed_as_ptr=False, is_ptr=is_ptr, + var_name=res.var_name, arr_len="datalen", arr_access="data", subty=res, is_native_primitive=False) + is_primitive = False + arr_len = None if fn_arg.startswith("void"): java_ty = "void" c_ty = "void" fn_ty_arg = "V" fn_arg = fn_arg[4:].strip() + is_primitive = True elif fn_arg.startswith("bool"): java_ty = "boolean" c_ty = "jboolean" fn_ty_arg = "Z" fn_arg = fn_arg[4:].strip() + is_primitive = True elif fn_arg.startswith("uint8_t"): java_ty = "byte" c_ty = "jbyte" fn_ty_arg = "B" fn_arg = fn_arg[7:].strip() + is_primitive = True elif fn_arg.startswith("uint16_t"): java_ty = "short" c_ty = "jshort" fn_ty_arg = "S" fn_arg = fn_arg[8:].strip() + is_primitive = True elif fn_arg.startswith("uint32_t"): java_ty = "int" c_ty = "jint" fn_ty_arg = "I" fn_arg = fn_arg[8:].strip() + is_primitive = True elif fn_arg.startswith("uint64_t") or fn_arg.startswith("uintptr_t"): java_ty = "long" c_ty = "jlong" @@ -171,11 +241,19 @@ def java_c_types(fn_arg, ret_arr_len): fn_arg = fn_arg[8:].strip() else: fn_arg = fn_arg[9:].strip() + is_primitive = True elif is_const and fn_arg.startswith("char *"): java_ty = "String" c_ty = "const char*" fn_ty_arg = "Ljava/lang/String;" fn_arg = fn_arg[6:].strip() + elif fn_arg.startswith("LDKStr"): + java_ty = "String" + c_ty = "jstring" + fn_ty_arg = "Ljava/lang/String;" + fn_arg = fn_arg[6:].strip() + arr_access = "chars" + arr_len = "len" else: ma = var_ty_regex.match(fn_arg) if ma.group(1).strip() in unitary_enums: @@ -185,6 +263,44 @@ def java_c_types(fn_arg, ret_arr_len): fn_arg = ma.group(2).strip() rust_obj = ma.group(1).strip() take_by_ptr = True + elif ma.group(1).strip().startswith("LDKC2Tuple"): + java_ty = "long" + java_hu_ty = "TwoTuple<" + if not ma.group(1).strip() in tuple_types: + assert java_c_types_none_allowed + return None + for idx, ty_info in enumerate(tuple_types[ma.group(1).strip()][0]): + if idx != 0: + java_hu_ty = java_hu_ty + ", " + if ty_info.is_native_primitive: + java_hu_ty = java_hu_ty + ty_info.java_hu_ty.title() # If we're a primitive, capitalize the first letter + else: + java_hu_ty = java_hu_ty + ty_info.java_hu_ty + java_hu_ty = java_hu_ty + ">" + c_ty = "jlong" + fn_ty_arg = "J" + fn_arg = ma.group(2).strip() + rust_obj = ma.group(1).strip() + take_by_ptr = True + elif ma.group(1).strip().startswith("LDKC3Tuple"): + java_ty = "long" + java_hu_ty = "ThreeTuple<" + if not ma.group(1).strip() in tuple_types: + assert java_c_types_none_allowed + return None + for idx, ty_info in enumerate(tuple_types[ma.group(1).strip()][0]): + if idx != 0: + java_hu_ty = java_hu_ty + ", " + if ty_info.is_native_primitive: + java_hu_ty = java_hu_ty + ty_info.java_hu_ty.title() # If we're a primitive, capitalize the first letter + else: + java_hu_ty = java_hu_ty + ty_info.java_hu_ty + java_hu_ty = java_hu_ty + ">" + c_ty = "jlong" + fn_ty_arg = "J" + fn_arg = ma.group(2).strip() + rust_obj = ma.group(1).strip() + take_by_ptr = True else: java_ty = "long" java_hu_ty = ma.group(1).strip().replace("LDK", "") @@ -200,6 +316,7 @@ def java_c_types(fn_arg, ret_arr_len): c_ty = "jlong" java_ty = "long" fn_ty_arg = "J" + is_primitive = False var_is_arr = var_is_arr_regex.match(fn_arg) if var_is_arr is not None or ret_arr_len is not None: @@ -210,14 +327,14 @@ def java_c_types(fn_arg, ret_arr_len): if var_is_arr is not None: if var_is_arr.group(1) == "": return TypeInfo(rust_obj=rust_obj, java_ty=java_ty, java_hu_ty=java_ty, java_fn_ty_arg="[" + fn_ty_arg, c_ty=c_ty, - passed_as_ptr=False, is_ptr=False, var_name="arg", arr_len=var_is_arr.group(2), arr_access=arr_access) + passed_as_ptr=False, is_ptr=False, var_name="arg", arr_len=var_is_arr.group(2), arr_access=arr_access, is_native_primitive=False) return TypeInfo(rust_obj=rust_obj, java_ty=java_ty, java_hu_ty=java_ty, java_fn_ty_arg="[" + fn_ty_arg, c_ty=c_ty, - passed_as_ptr=False, is_ptr=False, var_name=var_is_arr.group(1), arr_len=var_is_arr.group(2), arr_access=arr_access) + passed_as_ptr=False, is_ptr=False, var_name=var_is_arr.group(1), arr_len=var_is_arr.group(2), arr_access=arr_access, is_native_primitive=False) if java_hu_ty is None: java_hu_ty = java_ty return TypeInfo(rust_obj=rust_obj, java_ty=java_ty, java_hu_ty=java_hu_ty, java_fn_ty_arg=fn_ty_arg, c_ty=c_ty, passed_as_ptr=is_ptr or take_by_ptr, - is_ptr=is_ptr, var_name=fn_arg, arr_len=None, arr_access=None) + is_ptr=is_ptr, var_name=fn_arg, arr_len=arr_len, arr_access=arr_access, is_native_primitive=is_primitive) fn_ptr_regex = re.compile("^extern const ([A-Za-z_0-9\* ]*) \(\*(.*)\)\((.*)\);$") fn_ret_arr_regex = re.compile("(.*) \(\*(.*)\((.*)\)\)\[([0-9]*)\];$") @@ -232,7 +349,7 @@ with open(sys.argv[1]) as in_h: clone_fns.add(reg_fn.group(2)) else: rty = java_c_types(reg_fn.group(1), None) - if rty.rust_obj is not None and reg_fn.group(2) == rty.java_hu_ty + "_new": + if rty is not None and rty.rust_obj is not None and reg_fn.group(2) == rty.java_hu_ty + "_new": constructor_fns[rty.rust_obj] = reg_fn.group(3) continue arr_fn = fn_ret_arr_regex.match(line) @@ -241,16 +358,19 @@ with open(sys.argv[1]) as in_h: clone_fns.add(arr_fn.group(2)) # No object constructors return arrays, as then they wouldn't be an object constructor continue +java_c_types_none_allowed = False # C structs created by cbindgen are declared in dependency order with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.argv[4], "w") as out_c: def map_type(fn_arg, print_void, ret_arr_len, is_free): ty_info = java_c_types(fn_arg, ret_arr_len) + return map_type_with_info(ty_info, print_void, ret_arr_len, is_free) + def map_type_with_info(ty_info, print_void, ret_arr_len, is_free): if ty_info.c_ty == "void": if not print_void: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = None, from_hu_conv = None) + ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) if ty_info.c_ty.endswith("Array"): arr_len = ty_info.arr_len if arr_len is not None: @@ -258,31 +378,130 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg else: arr_name = "ret" arr_len = ret_arr_len - assert(ty_info.c_ty == "jbyteArray") - ret_conv = ("jbyteArray " + arr_name + "_arr = (*_env)->NewByteArray(_env, " + arr_len + ");\n" + "(*_env)->SetByteArrayRegion(_env, " + arr_name + "_arr, 0, " + arr_len + ", ", "") - arg_conv_cleanup = None - if not arr_len.isdigit(): - arg_conv = ty_info.rust_obj + " " + arr_name + "_ref;\n" - arg_conv = arg_conv + arr_name + "_ref." + ty_info.arr_access + " = (*_env)->GetByteArrayElements (_env, " + arr_name + ", NULL);\n" - arg_conv = arg_conv + arr_name + "_ref." + arr_len + " = (*_env)->GetArrayLength (_env, " + arr_name + ");" - arg_conv_cleanup = "(*_env)->ReleaseByteArrayElements(_env, " + arr_name + ", (int8_t*)" + arr_name + "_ref." + ty_info.arr_access + ", 0);" - arr_access = "." + ty_info.arr_access + if ty_info.c_ty == "jbyteArray": + ret_conv = ("jbyteArray " + arr_name + "_arr = (*_env)->NewByteArray(_env, " + arr_len + ");\n" + "(*_env)->SetByteArrayRegion(_env, " + arr_name + "_arr, 0, " + arr_len + ", ", "") + arg_conv_cleanup = None + if not arr_len.isdigit(): + arg_conv = ty_info.rust_obj + " " + arr_name + "_ref;\n" + arg_conv = arg_conv + arr_name + "_ref." + ty_info.arr_access + " = (*_env)->GetByteArrayElements (_env, " + arr_name + ", NULL);\n" + arg_conv = arg_conv + arr_name + "_ref." + arr_len + " = (*_env)->GetArrayLength (_env, " + arr_name + ");" + arg_conv_cleanup = "(*_env)->ReleaseByteArrayElements(_env, " + arr_name + ", (int8_t*)" + arr_name + "_ref." + ty_info.arr_access + ", 0);" + ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "") + ret_conv = (ret_conv[0], ";\njbyteArray " + arr_name + "_arr = (*_env)->NewByteArray(_env, " + arr_name + "_var." + arr_len + ");\n") + ret_conv = (ret_conv[0], ret_conv[1] + "(*_env)->SetByteArrayRegion(_env, " + arr_name + "_arr, 0, " + arr_name + "_var." + arr_len + ", " + arr_name + "_var." + ty_info.arr_access + ");") + elif ty_info.rust_obj is not None: + arg_conv = ty_info.rust_obj + " " + arr_name + "_ref;\n" + arg_conv = arg_conv + "CHECK((*_env)->GetArrayLength (_env, " + arr_name + ") == " + arr_len + ");\n" + arg_conv = arg_conv + "(*_env)->GetByteArrayRegion (_env, " + arr_name + ", 0, " + arr_len + ", " + arr_name + "_ref." + ty_info.arr_access + ");" + ret_conv = (ret_conv[0], "." + ty_info.arr_access + ");") + else: + arg_conv = "unsigned char " + arr_name + "_arr[" + arr_len + "];\n" + arg_conv = arg_conv + "CHECK((*_env)->GetArrayLength (_env, " + arr_name + ") == " + arr_len + ");\n" + arg_conv = arg_conv + "(*_env)->GetByteArrayRegion (_env, " + arr_name + ", 0, " + arr_len + ", " + arr_name + "_arr);\n" + "unsigned char (*" + arr_name + "_ref)[" + arr_len + "] = &" + arr_name + "_arr;" + ret_conv = (ret_conv[0] + "*", ");") + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = arg_conv, arg_conv_name = arr_name + "_ref", arg_conv_cleanup = arg_conv_cleanup, + ret_conv = ret_conv, ret_conv_name = arr_name + "_arr", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) + else: + assert not arr_len.isdigit() # not implemented + assert ty_info.java_ty[len(ty_info.java_ty) - 2:] == "[]" + conv_name = "arr_conv_" + str(len(ty_info.java_hu_ty)) + idxc = chr(ord('a') + (len(ty_info.java_hu_ty) % 26)) + ty_info.subty.var_name = conv_name + subty = map_type_with_info(ty_info.subty, False, None, is_free) + if arr_name == "": + arr_name = "arg" + arg_conv = ty_info.rust_obj + " " + arr_name + "_constr;\n" + arg_conv = arg_conv + arr_name + "_constr." + arr_len + " = (*_env)->GetArrayLength (_env, " + arr_name + ");\n" + arg_conv = arg_conv + "if (" + arr_name + "_constr." + arr_len + " > 0)\n" + if subty.rust_obj is None: + szof = subty.c_ty + else: + szof = subty.rust_obj + arg_conv = arg_conv + "\t" + arr_name + "_constr." + ty_info.arr_access + " = MALLOC(" + arr_name + "_constr." + arr_len + " * sizeof(" + szof + "), \"" + ty_info.rust_obj + " Elements\");\n" + arg_conv = arg_conv + "else\n" + arg_conv = arg_conv + "\t" + arr_name + "_constr." + ty_info.arr_access + " = NULL;\n" + if not ty_info.java_ty[:len(ty_info.java_ty) - 2].endswith("[]"): + arg_conv = arg_conv + ty_info.java_ty.strip("[]") + "* " + arr_name + "_vals = (*_env)->Get" + ty_info.subty.java_ty.title() + "ArrayElements (_env, " + arr_name + ", NULL);\n" + arg_conv = arg_conv + "for (size_t " + idxc + " = 0; " + idxc + " < " + arr_name + "_constr." + arr_len + "; " + idxc + "++) {\n" + if not ty_info.java_ty[:len(ty_info.java_ty) - 2].endswith("[]"): + arg_conv = arg_conv + "\t" + ty_info.java_ty.strip("[]") + " " + conv_name + " = " + arr_name + "_vals[" + idxc + "];" + if subty.arg_conv is not None: + arg_conv = arg_conv + "\n\t" + subty.arg_conv.replace("\n", "\n\t") + else: + arg_conv = arg_conv + "\tjobject " + conv_name + " = (*_env)->GetObjectArrayElement(_env, " + arr_name + ", " + idxc + ");\n" + arg_conv = arg_conv + "\t" + subty.arg_conv.replace("\n", "\n\t") + arg_conv = arg_conv + "\n\t" + arr_name + "_constr." + ty_info.arr_access + "[" + idxc + "] = " + subty.arg_conv_name + ";\n}" + if not ty_info.java_ty[:len(ty_info.java_ty) - 2].endswith("[]"): + arg_conv = arg_conv + "\n(*_env)->Release" + ty_info.java_ty.strip("[]").title() + "ArrayElements (_env, " + arr_name + ", " + arr_name + "_vals, 0);" + if ty_info.is_ptr: + arg_conv_name = "&" + arr_name + "_constr" + else: + arg_conv_name = arr_name + "_constr" + arg_conv_cleanup = None + if ty_info.is_ptr: + arg_conv_cleanup = "FREE(" + arr_name + "_constr." + ty_info.arr_access + ");" + + if arr_name == "arg": + arr_name = "ret" ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "") - ret_conv = (ret_conv[0], ";\njbyteArray " + arr_name + "_arr = (*_env)->NewByteArray(_env, " + arr_name + "_var." + arr_len + ");\n") - ret_conv = (ret_conv[0], ret_conv[1] + "(*_env)->SetByteArrayRegion(_env, " + arr_name + "_arr, 0, " + arr_name + "_var." + arr_len + ", " + arr_name + "_var." + ty_info.arr_access + ");") - elif ty_info.rust_obj is not None: - arg_conv = ty_info.rust_obj + " " + arr_name + "_ref;\n" - arg_conv = arg_conv + "CHECK((*_env)->GetArrayLength (_env, " + arr_name + ") == " + arr_len + ");\n" - arg_conv = arg_conv + "(*_env)->GetByteArrayRegion (_env, " + arr_name + ", 0, " + arr_len + ", " + arr_name + "_ref." + ty_info.arr_access + ");" - ret_conv = (ret_conv[0], "." + ty_info.arr_access + ");") + if subty.ret_conv is None: + ret_conv = ("DUMMY", "DUMMY") + elif not ty_info.java_ty[:len(ty_info.java_ty) - 2].endswith("[]"): + ret_conv = (ret_conv[0], ";\n" + ty_info.c_ty + " " + arr_name + "_arr = (*_env)->New" + ty_info.java_ty.strip("[]").title() + "Array(_env, " + arr_name + "_var." + arr_len + ");\n") + ret_conv = (ret_conv[0], ret_conv[1] + subty.c_ty + " *" + arr_name + "_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, " + arr_name + "_arr, NULL);\n") + ret_conv = (ret_conv[0], ret_conv[1] + "for (size_t " + idxc + " = 0; " + idxc + " < " + arr_name + "_var." + arr_len + "; " + idxc + "++) {\n") + ret_conv = (ret_conv[0], ret_conv[1] + "\t" + subty.ret_conv[0].replace("\n", "\n\t")) + ret_conv = (ret_conv[0], ret_conv[1] + arr_name + "_var." + ty_info.arr_access + "[" + idxc + "]" + subty.ret_conv[1].replace("\n", "\n\t")) + ret_conv = (ret_conv[0], ret_conv[1] + "\n\t" + arr_name + "_arr_ptr[" + idxc + "] = " + subty.ret_conv_name + ";\n") + ret_conv = (ret_conv[0], ret_conv[1] + "}\n(*_env)->ReleasePrimitiveArrayCritical(_env, " + arr_name + "_arr, " + arr_name + "_arr_ptr, 0);") + else: + ret_conv = (ret_conv[0], ";\n" + ty_info.c_ty + " " + arr_name + "_arr = (*_env)->NewObjectArray(_env, " + arr_name + "_var." + arr_len + ", NULL, NULL);\n") # XXX: second arg needs to be a clazz! + ret_conv = (ret_conv[0], ret_conv[1] + "for (size_t " + idxc + " = 0; " + idxc + " < " + arr_name + "_var." + arr_len + "; " + idxc + "++) {\n") + ret_conv = (ret_conv[0], ret_conv[1] + "\t" + subty.ret_conv[0].replace("\n", "\n\t")) + ret_conv = (ret_conv[0], ret_conv[1] + arr_name + "_var." + ty_info.arr_access + "[" + idxc + "]" + subty.ret_conv[1].replace("\n", "\n\t")) + ret_conv = (ret_conv[0], ret_conv[1] + "\n\t(*_env)->SetObjectArrayElement(_env, " + arr_name + "_arr, " + idxc + ", " + subty.ret_conv_name + ");") + ret_conv = (ret_conv[0], ret_conv[1] + "}") + if subty.rust_obj is not None and subty.rust_obj in opaque_structs: + ret_conv = (ret_conv[0], ret_conv[1] + "\nFREE(" + arr_name + "_var.data);") + + to_hu_conv = None + to_hu_conv_name = None + if subty.to_hu_conv is not None: + to_hu_conv = ty_info.java_hu_ty + " " + conv_name + "_arr = new " + ty_info.subty.java_hu_ty.split("<")[0] + "[" + arr_name + ".length];\n" + to_hu_conv = to_hu_conv + "for (int " + idxc + " = 0; " + idxc + " < " + arr_name + ".length; " + idxc + "++) {\n" + to_hu_conv = to_hu_conv + "\t" + subty.java_ty + " " + conv_name + " = " + arr_name + "[" + idxc + "];\n" + to_hu_conv = to_hu_conv + "\t" + subty.to_hu_conv.replace("\n", "\n\t") + "\n" + to_hu_conv = to_hu_conv + "\t" + conv_name + "_arr[" + idxc + "] = " + subty.to_hu_conv_name + ";\n}" + to_hu_conv_name = conv_name + "_arr" + from_hu_conv = None + if subty.from_hu_conv is not None: + if subty.java_ty == "long" and subty.java_hu_ty != "long": + from_hu_conv = ("Arrays.stream(" + arr_name + ").mapToLong(" + conv_name + " -> " + subty.from_hu_conv[0] + ").toArray()", "/* TODO 2 " + subty.java_hu_ty + " */") + elif subty.java_ty == "long": + from_hu_conv = ("Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + subty.from_hu_conv[0] + ").toArray()", "/* TODO 2 " + subty.java_hu_ty + " */") + else: + from_hu_conv = ("(" + ty_info.java_ty + ")Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + subty.from_hu_conv[0] + ").toArray()", "/* TODO 2 " + subty.java_hu_ty + " */") + + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = arg_conv_cleanup, + ret_conv = ret_conv, ret_conv_name = arr_name + "_arr", to_hu_conv = to_hu_conv, to_hu_conv_name = to_hu_conv_name, from_hu_conv = from_hu_conv) + elif ty_info.java_ty == "String": + if ty_info.arr_access is None: + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, + ret_conv = ("jstring " + ty_info.var_name + "_conv = (*_env)->NewStringUTF(_env, ", ");"), ret_conv_name = ty_info.var_name + "_conv", + to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) else: - arg_conv = "unsigned char " + arr_name + "_arr[" + arr_len + "];\n" - arg_conv = arg_conv + "CHECK((*_env)->GetArrayLength (_env, " + arr_name + ") == " + arr_len + ");\n" - arg_conv = arg_conv + "(*_env)->GetByteArrayRegion (_env, " + arr_name + ", 0, " + arr_len + ", " + arr_name + "_arr);\n" + "unsigned char (*" + arr_name + "_ref)[" + arr_len + "] = &" + arr_name + "_arr;" - ret_conv = (ret_conv[0] + "*", ");") - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = arg_conv, arg_conv_name = arr_name + "_ref", arg_conv_cleanup = arg_conv_cleanup, - ret_conv = ret_conv, ret_conv_name = arr_name + "_arr", to_hu_conv = None, from_hu_conv = None) + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, + ret_conv = ("LDKStr " + ty_info.var_name + "_str = ", + ";\nchar* " + ty_info.var_name + "_buf = MALLOC(" + ty_info.var_name + "_str." + ty_info.arr_len + " + 1, \"str conv buf\");\n" + + "memcpy(" + ty_info.var_name + "_buf, " + ty_info.var_name + "_str." + ty_info.arr_access + ", " + ty_info.var_name + "_str." + ty_info.arr_len + ");\n" + + ty_info.var_name + "_buf[" + ty_info.var_name + "_str." + ty_info.arr_len + "] = 0;\n" + + "jstring " + ty_info.var_name + "_conv = (*_env)->NewStringUTF(_env, " + ty_info.var_name + "_str." + ty_info.arr_access + ");\n" + + "FREE(" + ty_info.var_name + "_buf);"), + ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) elif ty_info.var_name != "": # If we have a parameter name, print it (noting that it may indicate its a pointer) if ty_info.rust_obj is not None: @@ -290,7 +509,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg opaque_arg_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv;\n" opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.inner = (void*)(" + ty_info.var_name + " & (~1));\n" opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.is_owned = (" + ty_info.var_name + " & 1) || (" + ty_info.var_name + " == 0);" - if not ty_info.is_ptr and not is_free: + if not ty_info.is_ptr and not is_free and not ty_info.pass_by_ref: if (ty_info.java_hu_ty + "_clone") in clone_fns: # TODO: This is a bit too naive, even with the checks above, we really need to know if rust wants a ref or not, not just if its pass as a ptr. opaque_arg_conv = opaque_arg_conv + "\nif (" + ty_info.var_name + "_conv.inner != NULL)\n" @@ -304,7 +523,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = ("jclass " + ty_info.var_name + "_conv = " + ty_info.rust_obj + "_to_java(_env, ", ");"), - ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, from_hu_conv = None) + ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) if ty_info.rust_obj in opaque_structs: ret_conv_suf = ";\nCHECK((((long)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n" ret_conv_suf = ret_conv_suf + "CHECK((((long)&" + ty_info.var_name + "_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.\n" @@ -317,7 +536,9 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = opaque_arg_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = (ty_info.rust_obj + " " + ty_info.var_name + "_var = ", ret_conv_suf), - ret_conv_name = ty_info.var_name + "_ref", to_hu_conv = ("new " + ty_info.java_hu_ty + "(null, ", ")"), + ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) base_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)" + ty_info.var_name + ";"; if ty_info.rust_obj in trait_structs: @@ -330,68 +551,91 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = ("CANT PASS TRAIT TO Java?", ""), ret_conv_name = "NO CONV POSSIBLE", - to_hu_conv = ("DUMMY", ""), from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) + to_hu_conv = "DUMMY", to_hu_conv_name = None, + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) if ty_info.rust_obj != "LDKu8slice": # Don't bother free'ing slices passed in - Rust doesn't auto-free the # underlying unlike Vecs, and it gives Java more freedom. base_conv = base_conv + "\nFREE((void*)" + ty_info.var_name + ");"; + if ty_info.rust_obj in complex_enums: + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + ".conv_to_c()", "")) + if ty_info.rust_obj in tuple_types: + to_hu_conv_pfx = "" + to_hu_conv_sfx = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " + ty_info.java_hu_ty + "(" + for idx, conv in enumerate(tuple_types[ty_info.rust_obj][0]): + if idx != 0: + to_hu_conv_sfx = to_hu_conv_sfx + ", " + conv.var_name = ty_info.var_name + "_" + chr(idx + ord("a")) + conv_map = map_type_with_info(conv, False, None, is_free) + to_hu_conv_pfx = to_hu_conv_pfx + conv.java_ty + " " + ty_info.var_name + "_" + chr(idx + ord("a")) + " = " + "bindings." + tuple_types[ty_info.rust_obj][1] + "_get_" + chr(idx + ord("a")) + "(" + ty_info.var_name + ");\n" + if conv_map.to_hu_conv is not None: + to_hu_conv_pfx = to_hu_conv_pfx + conv_map.to_hu_conv + ";\n" + to_hu_conv_sfx = to_hu_conv_sfx + conv_map.to_hu_conv_name; + else: + to_hu_conv_sfx = to_hu_conv_sfx + ty_info.var_name + "_" + chr(idx + ord("a")); + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");", to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = ("/*TODO b*/0", "")) + + # The manually-defined types - TxOut and Transaction return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = ("TODO 1", ""), from_hu_conv = None) + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " +ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = ("/*TODO 1*/0", "")) else: assert(not is_free) if ty_info.rust_obj in opaque_structs: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = opaque_arg_conv, arg_conv_name = "&" + ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 2", ""), + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 2", to_hu_conv_name = None, from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) # its a pointer, no conv needed elif ty_info.rust_obj in trait_structs: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 2.5", ""), + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 2.5", to_hu_conv_name = None, from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) # its a pointer, no conv needed return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 3", ""), from_hu_conv = None) # its a pointer, no conv needed + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 3", to_hu_conv_name = None, from_hu_conv = None) # its a pointer, no conv needed elif ty_info.is_ptr: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 4", ""), from_hu_conv = None) - elif ty_info.java_ty == "String": - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - ret_conv = ("jstring " + ty_info.var_name + "_conv = (*_env)->NewStringUTF(_env, ", ");"), ret_conv_name = ty_info.var_name + "_conv", - to_hu_conv = ("TODO 5", ""), from_hu_conv = None) + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 4", to_hu_conv_name = None, from_hu_conv = None) else: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 6", ""), from_hu_conv = None) + ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) elif not print_void: # We don't have a parameter name, and want one, just call it arg if ty_info.rust_obj is not None: - assert(not is_free or ty_info.rust_obj not in opaque_structs); + assert(not is_free or ty_info.rust_obj not in opaque_structs) return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = ty_info.rust_obj + " arg_conv = *(" + ty_info.rust_obj + "*)arg;\nFREE((void*)arg);", arg_conv_name = "arg_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 7", ""), from_hu_conv = None) + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 7", to_hu_conv_name = None, from_hu_conv = None) else: assert(not is_free) return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = "arg", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = ("TODO 8", ""), from_hu_conv = None) + ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 8", to_hu_conv_name = None, from_hu_conv = None) else: # We don't have a parameter name, and don't want one (cause we're returning) if ty_info.rust_obj is not None: if not ty_info.is_ptr: if ty_info.rust_obj in unitary_enums: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = ty_info.rust_obj + " ret = " + ty_info.rust_obj + "_from_java(_env, " + ty_info.var_name + ");", - arg_conv_name = "ret", arg_conv_cleanup = None, + arg_conv = ty_info.rust_obj + " ret_conv = " + ty_info.rust_obj + "_from_java(_env, ret);", + arg_conv_name = "ret_conv", arg_conv_cleanup = None, ret_conv = ("jclass ret = " + ty_info.rust_obj + "_to_java(_env, ", ");"), ret_conv_name = "ret", - to_hu_conv = ("TODO 9", ""), from_hu_conv = None) + to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) if ty_info.rust_obj in opaque_structs: # If we're returning a newly-allocated struct, we don't want Rust to ever # free, instead relying on the Java GC to lose the ref. We undo this in @@ -401,34 +645,38 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg ret_conv = (ty_info.rust_obj + " ret = ", ";"), ret_conv_name = "((long)ret.inner) | (ret.is_owned ? 1 : 0)", arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = ("new " + ty_info.java_hu_ty + "(null, ", ")"), from_hu_conv = None) + to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);", + to_hu_conv_name = "ret_hu_conv", from_hu_conv = None) elif ty_info.rust_obj in trait_structs: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, ret_conv = (ty_info.rust_obj + "* ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*ret = ", ";"), ret_conv_name = "(long)ret", arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = ("new " + ty_info.java_hu_ty + "(null, ", ");\nret.ptrs_to.add(this)"), from_hu_conv = None) + to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);\nret_hu_conv.ptrs_to.add(this);", + to_hu_conv_name = "ret_hu_conv", from_hu_conv = None) else: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, ret_conv = (ty_info.rust_obj + "* ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*ret = ", ";"), ret_conv_name = "(long)ret", arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = ("TODO b", ""), from_hu_conv = None) + to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);\nret_hu_conv.ptrs_to.add(this);", + to_hu_conv_name = "ret_hu_conv", from_hu_conv = None) elif ty_info.rust_obj in trait_structs: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, ret_conv = ("long ret = (long)", ";"), ret_conv_name = "ret", arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = ("new " + ty_info.java_hu_ty + "(null, ", ");\nret.ptrs_to.add(this)"), from_hu_conv = None) + to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);\nret_hu_conv.ptrs_to.add(this);", + to_hu_conv_name = "ret_hu_conv", from_hu_conv = None) else: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, ret_conv = ("long ret = (long)", ";"), ret_conv_name = "ret", arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = ("TODO c", ""), from_hu_conv = None) + to_hu_conv = "TODO c", to_hu_conv_name = None, from_hu_conv = None) else: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, ret_conv = None, ret_conv_name = None, - to_hu_conv = None, from_hu_conv = None) + to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) def map_fn(line, re_match, ret_arr_len, c_call_string): out_java.write("\t// " + line) @@ -460,7 +708,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg if arg_conv_info.c_ty != "void": arg_conv_info.print_ty() arg_conv_info.print_name() - if arg_conv_info.arg_name == "this_arg": + if arg_conv_info.arg_name == "this_ptr" or arg_conv_info.arg_name == "this_arg": takes_self = True if arg_conv_info.passed_as_ptr and not arg_conv_info.rust_obj in opaque_structs: if not arg_conv_info.rust_obj in trait_structs and not arg_conv_info.rust_obj in unitary_enums: @@ -474,6 +722,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg # We actually want to handle this case, but for now its only used in NetGraphMsgHandler::new() # which ends up resulting in a redundant constructor - both without arguments for the NetworkGraph. args_known = False + assert explode_arg_conv.arg_name != "this_ptr" assert explode_arg_conv.arg_name != "this_arg" if explode_arg_conv.passed_as_ptr and not explode_arg_conv.rust_obj in trait_structs: args_known = False @@ -492,17 +741,16 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_java_struct.close() out_java_struct = None else: - out_java_struct.write("\tpublic ") meth_n = re_match.group(2)[len(struct_meth) + 1:] if ret_info.rust_obj == "LDK" + struct_meth: - out_java_struct.write(struct_meth + "(") + out_java_struct.write("\tpublic static " + ret_info.java_hu_ty + " constructor_" + meth_n + "(") else: - out_java_struct.write(ret_info.java_hu_ty + " " + meth_n + "(") + out_java_struct.write("\tpublic " + ret_info.java_hu_ty + " " + meth_n + "(") for idx, arg in enumerate(arg_names): if idx != 0: if not takes_self or idx > 1: out_java_struct.write(", ") - if arg.java_ty != "void" and arg.arg_name != "this_arg": + if arg.java_ty != "void" and arg.arg_name != "this_ptr" and arg.arg_name != "this_arg": if arg.arg_name in default_constructor_args: for explode_idx, explode_arg in enumerate(default_constructor_args[arg.arg_name]): if explode_idx != 0: @@ -555,19 +803,13 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("\n}\n\n") if out_java_struct is not None: out_java_struct.write("\t\t") - if ret_info.rust_obj == "LDK" + struct_meth: - out_java_struct.write("super(") - elif ret_info.java_ty != "void" and not ret_info.passed_as_ptr: + if ret_info.java_ty != "void": out_java_struct.write(ret_info.java_ty + " ret = ") - elif ret_info.java_ty != "void": - out_java_struct.write(ret_info.java_hu_ty + " ret = ") - if ret_info.to_hu_conv is not None: - out_java_struct.write(ret_info.to_hu_conv[0]) out_java_struct.write("bindings." + re_match.group(2) + "(") for idx, info in enumerate(arg_names): if idx != 0: out_java_struct.write(", ") - if info.arg_name == "this_arg": + if info.arg_name == "this_ptr" or info.arg_name == "this_arg": out_java_struct.write("this.ptr") elif info.arg_name in default_constructor_args: out_java_struct.write("bindings." + info.java_hu_ty + "_new(") @@ -581,23 +823,26 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_java_struct.write(info.from_hu_conv[0]) else: out_java_struct.write(info.arg_name) - out_java_struct.write(")") + out_java_struct.write(");\n") if ret_info.to_hu_conv is not None: - out_java_struct.write(ret_info.to_hu_conv[1].replace("\n", "\n\t\t") + ";\n") - else: - out_java_struct.write(";\n") + out_java_struct.write("\t\t" + ret_info.to_hu_conv.replace("\n", "\n\t\t") + "\n") for info in arg_names: - if info.arg_name == "this_arg": + if info.arg_name == "this_ptr" or info.arg_name == "this_arg": pass elif info.arg_name in default_constructor_args: for explode_arg in default_constructor_args[info.arg_name]: expl_arg_name = info.arg_name + "_" + explode_arg.arg_name - out_java_struct.write("\t\t" + explode_arg.from_hu_conv[1].replace(explode_arg.arg_name, expl_arg_name) + ";\n") + out_java_struct.write("\t\t" + explode_arg.from_hu_conv[1].replace(explode_arg.arg_name, expl_arg_name).replace("this", ret_info.to_hu_conv_name) + ";\n") elif info.from_hu_conv is not None and info.from_hu_conv[1] != "": - out_java_struct.write("\t\t" + info.from_hu_conv[1] + ";\n") + if ret_info.rust_obj == "LDK" + struct_meth and ret_info.to_hu_conv_name is not None: + out_java_struct.write("\t\t" + info.from_hu_conv[1].replace("this", ret_info.to_hu_conv_name) + ";\n") + else: + out_java_struct.write("\t\t" + info.from_hu_conv[1] + ";\n") - if ret_info.java_ty != "void" and ret_info.rust_obj != "LDK" + struct_meth: + if ret_info.to_hu_conv_name is not None: + out_java_struct.write("\t\treturn " + ret_info.to_hu_conv_name + ";\n") + elif ret_info.java_ty != "void" and ret_info.rust_obj != "LDK" + struct_meth: out_java_struct.write("\t\treturn ret;\n") out_java_struct.write("\t}\n\n") out_java_struct.close() @@ -657,80 +902,102 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("}\n\n") def map_complex_enum(struct_name, union_enum_items): - tag_field_lines = union_enum_items["field_lines"] - init_meth_jty_strs = {} - for idx, struct_line in enumerate(tag_field_lines): - if idx == 0: - out_java.write("\tpublic static class " + struct_name + " {\n") - out_java.write("\t\tprivate " + struct_name + "() {}\n") - elif idx == len(tag_field_lines) - 3: - assert(struct_line.endswith("_Sentinel,")) - elif idx == len(tag_field_lines) - 2: - out_java.write("\t\tstatic native void init();\n") - out_java.write("\t}\n") - elif idx == len(tag_field_lines) - 1: - assert(struct_line == "") - else: - var_name = struct_line.strip(' ,')[len(struct_name) + 1:] - out_java.write("\t\tpublic final static class " + var_name + " extends " + struct_name + " {\n") - out_c.write("static jclass " + struct_name + "_" + var_name + "_class = NULL;\n") - out_c.write("static jmethodID " + struct_name + "_" + var_name + "_meth = NULL;\n") - init_meth_jty_str = "" - init_meth_params = "" - init_meth_body = "" - if "LDK" + var_name in union_enum_items: - enum_var_lines = union_enum_items["LDK" + var_name] - for idx, field in enumerate(enum_var_lines): - if idx != 0 and idx < len(enum_var_lines) - 2: - field_ty = java_c_types(field.strip(' ;'), None) - out_java.write("\t\t\tpublic " + field_ty.java_ty + " " + field_ty.var_name + ";\n") - init_meth_jty_str = init_meth_jty_str + field_ty.java_fn_ty_arg - if idx > 1: - init_meth_params = init_meth_params + ", " - init_meth_params = init_meth_params + field_ty.java_ty + " " + field_ty.var_name - init_meth_body = init_meth_body + "this." + field_ty.var_name + " = " + field_ty.var_name + "; " - out_java.write("\t\t\t" + var_name + "(" + init_meth_params + ") { ") - out_java.write(init_meth_body) - out_java.write("}\n") - out_java.write("\t\t}\n") - init_meth_jty_strs[var_name] = init_meth_jty_str - out_java.write("\tstatic { " + struct_name + ".init(); }\n") - out_java.write("\tpublic static native " + struct_name + " " + struct_name + "_ref_from_ptr(long ptr);\n"); - - out_c.write("JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024" + struct_name.replace("_", "_1") + "_init (JNIEnv * env, jclass _a) {\n") - for idx, struct_line in enumerate(tag_field_lines): - if idx != 0 and idx < len(tag_field_lines) - 3: - var_name = struct_line.strip(' ,')[len(struct_name) + 1:] - out_c.write("\t" + struct_name + "_" + var_name + "_class =\n") - out_c.write("\t\t(*env)->NewGlobalRef(env, (*env)->FindClass(env, \"Lorg/ldk/impl/bindings$" + struct_name + "$" + var_name + ";\"));\n") - out_c.write("\tCHECK(" + struct_name + "_" + var_name + "_class != NULL);\n") - out_c.write("\t" + struct_name + "_" + var_name + "_meth = (*env)->GetMethodID(env, " + struct_name + "_" + var_name + "_class, \"\", \"(" + init_meth_jty_strs[var_name] + ")V\");\n") - out_c.write("\tCHECK(" + struct_name + "_" + var_name + "_meth != NULL);\n") - out_c.write("}\n") - out_c.write("JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_" + struct_name.replace("_", "_1") + "_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {\n") - out_c.write("\t" + struct_name + " *obj = (" + struct_name + "*)ptr;\n") - out_c.write("\tswitch(obj->tag) {\n") - for idx, struct_line in enumerate(tag_field_lines): - if idx != 0 and idx < len(tag_field_lines) - 3: - var_name = struct_line.strip(' ,')[len(struct_name) + 1:] - out_c.write("\t\tcase " + struct_name + "_" + var_name + ": {\n") - c_params_text = "" - if "LDK" + var_name in union_enum_items: - enum_var_lines = union_enum_items["LDK" + var_name] - for idx, field in enumerate(enum_var_lines): - if idx != 0 and idx < len(enum_var_lines) - 2: - field_map = map_type(field.strip(' ;'), False, None, False) - if field_map.ret_conv is not None: - out_c.write("\t\t\t" + field_map.ret_conv[0].replace("\n", "\n\t\t\t")) - out_c.write("obj->" + camel_to_snake(var_name) + "." + field_map.arg_name) - out_c.write(field_map.ret_conv[1].replace("\n", "\n\t\t\t") + "\n") - c_params_text = c_params_text + ", " + field_map.ret_conv_name - else: - c_params_text = c_params_text + ", obj->" + camel_to_snake(var_name) + "." + field_map.arg_name - out_c.write("\t\t\treturn (*_env)->NewObject(_env, " + struct_name + "_" + var_name + "_class, " + struct_name + "_" + var_name + "_meth" + c_params_text + ");\n") - out_c.write("\t\t}\n") - out_c.write("\t\tdefault: abort();\n") - out_c.write("\t}\n}\n") + java_hu_type = struct_name.replace("LDK", "") + complex_enums.add(struct_name) + with open(sys.argv[3] + "/structs/" + java_hu_type + ".java", "w") as out_java_enum: + out_java_enum.write(hu_struct_file_prefix) + out_java_enum.write("public class " + java_hu_type + " extends CommonBase {\n") + out_java_enum.write("\tprivate " + java_hu_type + "(Object _dummy, long ptr) { super(ptr); }\n") + out_java_enum.write("\tlong conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ }\n") + out_java_enum.write("\tstatic " + java_hu_type + " constr_from_ptr(long ptr) {\n") + out_java_enum.write("\t\tbindings." + struct_name + " raw_val = bindings." + struct_name + "_ref_from_ptr(ptr);\n") + java_hu_subclasses = "" + + tag_field_lines = union_enum_items["field_lines"] + init_meth_jty_strs = {} + for idx, struct_line in enumerate(tag_field_lines): + if idx == 0: + out_java.write("\tpublic static class " + struct_name + " {\n") + out_java.write("\t\tprivate " + struct_name + "() {}\n") + elif idx == len(tag_field_lines) - 3: + assert(struct_line.endswith("_Sentinel,")) + elif idx == len(tag_field_lines) - 2: + out_java.write("\t\tstatic native void init();\n") + out_java.write("\t}\n") + elif idx == len(tag_field_lines) - 1: + assert(struct_line == "") + else: + var_name = struct_line.strip(' ,')[len(struct_name) + 1:] + out_java.write("\t\tpublic final static class " + var_name + " extends " + struct_name + " {\n") + java_hu_subclasses = java_hu_subclasses + "\tpublic final static class " + var_name + " extends " + java_hu_type + " {\n" + out_java_enum.write("\t\tif (raw_val.getClass() == bindings." + struct_name + "." + var_name + ".class) {\n") + out_java_enum.write("\t\t\treturn new " + var_name + "(null, ptr);\n") # TODO: Conv values! + out_c.write("static jclass " + struct_name + "_" + var_name + "_class = NULL;\n") + out_c.write("static jmethodID " + struct_name + "_" + var_name + "_meth = NULL;\n") + init_meth_jty_str = "" + init_meth_params = "" + init_meth_body = "" + if "LDK" + var_name in union_enum_items: + enum_var_lines = union_enum_items["LDK" + var_name] + for idx, field in enumerate(enum_var_lines): + if idx != 0 and idx < len(enum_var_lines) - 2: + field_ty = java_c_types(field.strip(' ;'), None) + out_java.write("\t\t\tpublic " + field_ty.java_ty + " " + field_ty.var_name + ";\n") + java_hu_subclasses = java_hu_subclasses + "\t\tpublic " + field_ty.java_hu_ty + " " + field_ty.var_name + ";\n" + init_meth_jty_str = init_meth_jty_str + field_ty.java_fn_ty_arg + if idx > 1: + init_meth_params = init_meth_params + ", " + init_meth_params = init_meth_params + field_ty.java_ty + " " + field_ty.var_name + init_meth_body = init_meth_body + "this." + field_ty.var_name + " = " + field_ty.var_name + "; " + out_java.write("\t\t\t" + var_name + "(" + init_meth_params + ") { ") + out_java.write(init_meth_body) + out_java.write("}\n") + out_java.write("\t\t}\n") + out_java_enum.write("\t\t}\n") + java_hu_subclasses = java_hu_subclasses + "\t\tprivate " + var_name + "(Object _dummy, long ptr) { super(null, ptr); }\n" + java_hu_subclasses = java_hu_subclasses + "\t\t@Override long conv_to_c() { return 0; /*XXX*/ }\n" + java_hu_subclasses = java_hu_subclasses + "\t}\n" + init_meth_jty_strs[var_name] = init_meth_jty_str + out_java_enum.write("\t\tassert false; return null; // Unreachable without extending the (internal) bindings interface\n\t}\n\n") + out_java_enum.write(java_hu_subclasses) + out_java.write("\tstatic { " + struct_name + ".init(); }\n") + out_java.write("\tpublic static native " + struct_name + " " + struct_name + "_ref_from_ptr(long ptr);\n"); + + out_c.write("JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024" + struct_name.replace("_", "_1") + "_init (JNIEnv * env, jclass _a) {\n") + for idx, struct_line in enumerate(tag_field_lines): + if idx != 0 and idx < len(tag_field_lines) - 3: + var_name = struct_line.strip(' ,')[len(struct_name) + 1:] + out_c.write("\t" + struct_name + "_" + var_name + "_class =\n") + out_c.write("\t\t(*env)->NewGlobalRef(env, (*env)->FindClass(env, \"Lorg/ldk/impl/bindings$" + struct_name + "$" + var_name + ";\"));\n") + out_c.write("\tCHECK(" + struct_name + "_" + var_name + "_class != NULL);\n") + out_c.write("\t" + struct_name + "_" + var_name + "_meth = (*env)->GetMethodID(env, " + struct_name + "_" + var_name + "_class, \"\", \"(" + init_meth_jty_strs[var_name] + ")V\");\n") + out_c.write("\tCHECK(" + struct_name + "_" + var_name + "_meth != NULL);\n") + out_c.write("}\n") + out_c.write("JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_" + struct_name.replace("_", "_1") + "_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) {\n") + out_c.write("\t" + struct_name + " *obj = (" + struct_name + "*)ptr;\n") + out_c.write("\tswitch(obj->tag) {\n") + for idx, struct_line in enumerate(tag_field_lines): + if idx != 0 and idx < len(tag_field_lines) - 3: + var_name = struct_line.strip(' ,')[len(struct_name) + 1:] + out_c.write("\t\tcase " + struct_name + "_" + var_name + ": {\n") + c_params_text = "" + if "LDK" + var_name in union_enum_items: + enum_var_lines = union_enum_items["LDK" + var_name] + for idx, field in enumerate(enum_var_lines): + if idx != 0 and idx < len(enum_var_lines) - 2: + field_map = map_type(field.strip(' ;'), False, None, False) + if field_map.ret_conv is not None: + out_c.write("\t\t\t" + field_map.ret_conv[0].replace("\n", "\n\t\t\t")) + out_c.write("obj->" + camel_to_snake(var_name) + "." + field_map.arg_name) + out_c.write(field_map.ret_conv[1].replace("\n", "\n\t\t\t") + "\n") + c_params_text = c_params_text + ", " + field_map.ret_conv_name + else: + c_params_text = c_params_text + ", obj->" + camel_to_snake(var_name) + "." + field_map.arg_name + out_c.write("\t\t\treturn (*_env)->NewObject(_env, " + struct_name + "_" + var_name + "_class, " + struct_name + "_" + var_name + "_meth" + c_params_text + ");\n") + out_c.write("\t\t}\n") + out_c.write("\t\tdefault: abort();\n") + out_c.write("\t}\n}\n") + out_java_enum.write("}\n") def map_trait(struct_name, field_var_lines, trait_fn_lines): with open(sys.argv[3] + "/structs/" + struct_name.replace("LDK","") + ".java", "w") as out_java_trait: @@ -746,12 +1013,10 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("\tjmethodID " + fn_line.group(2) + "_meth;\n") out_c.write("} " + struct_name + "_JCalls;\n") - out_java_trait.write("package org.ldk.structs;\n\n") - out_java_trait.write("import org.ldk.impl.bindings;\n\n") - out_java_trait.write("import org.ldk.enums.*;\n\n") + out_java_trait.write(hu_struct_file_prefix) out_java_trait.write("public class " + struct_name.replace("LDK","") + " extends CommonBase {\n") out_java_trait.write("\t" + struct_name.replace("LDK", "") + "(Object _dummy, long ptr) { super(ptr); }\n") - out_java_trait.write("\tpublic " + struct_name.replace("LDK", "") + "(bindings." + struct_name + " arg") # XXX: Should be priv + out_java_trait.write("\tpublic " + struct_name.replace("LDK", "") + "(bindings." + struct_name + " arg") # XXX: Should be priv ( but is currently used in tests for var_line in field_var_lines: if var_line.group(1) in trait_structs: out_java_trait.write(", bindings." + var_line.group(1) + " " + var_line.group(2)) @@ -768,6 +1033,9 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_java_trait.write("\t\tbindings." + struct_name.replace("LDK","") + "_free(ptr); super.finalize();\n") out_java_trait.write("\t}\n\n") + java_trait_constr = "\tpublic " + struct_name.replace("LDK", "") + "(" + struct_name.replace("LDK", "") + "Interface arg) {\n" + java_trait_constr = java_trait_constr + "\t\tthis(new bindings." + struct_name + "() {\n" + #out_java_trait.write("\tpublic static interface " + struct_name.replace("LDK", "") + "Interface {\n") out_java.write("\tpublic interface " + struct_name + " {\n") java_meths = [] for fn_line in trait_fn_lines: @@ -776,6 +1044,8 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg ret_ty_info = map_type(fn_line.group(1), True, None, False) out_java.write("\t\t " + ret_ty_info.java_ty + " " + fn_line.group(2) + "(") + java_trait_constr = java_trait_constr + "\t\t\t@Override public " + ret_ty_info.java_ty + " " + fn_line.group(2) + "(" + #out_java_trait.write("\t\t" + ret_ty_info.java_hu_ty + " " + fn_line.group(2) + "(") is_const = fn_line.group(3) is not None out_c.write(fn_line.group(1) + fn_line.group(2) + "_jcall(") if is_const: @@ -789,16 +1059,22 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg continue if idx >= 2: out_java.write(", ") + java_trait_constr = java_trait_constr + ", " + #out_java_trait.write(", ") out_c.write(", ") arg_conv_info = map_type(arg, True, None, False) out_c.write(arg.strip()) out_java.write(arg_conv_info.java_ty + " " + arg_conv_info.arg_name) + #out_java_trait.write(arg_conv_info.java_ty + " " + arg_conv_info.arg_name) + java_trait_constr = java_trait_constr + arg_conv_info.java_ty + " " + arg_conv_info.arg_name arg_names.append(arg_conv_info) java_meth_descr = java_meth_descr + arg_conv_info.java_fn_ty_arg java_meth_descr = java_meth_descr + ")" + ret_ty_info.java_fn_ty_arg java_meths.append(java_meth_descr) out_java.write(");\n") + #out_java_trait.write(");\n") + java_trait_constr = java_trait_constr + ") {\n" out_c.write(") {\n") out_c.write("\t" + struct_name + "_JCalls *j_calls = (" + struct_name + "_JCalls*) this_arg;\n") out_c.write("\tJNIEnv *_env;\n") @@ -812,12 +1088,15 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("\tjobject obj = (*_env)->NewLocalRef(_env, j_calls->o);\n\tCHECK(obj != NULL);\n") if ret_ty_info.c_ty.endswith("Array"): - assert(ret_ty_info.c_ty == "jbyteArray") - out_c.write("\tjbyteArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->" + fn_line.group(2) + "_meth") + out_c.write("\t" + ret_ty_info.c_ty + " ret = (*_env)->CallObjectMethod(_env, obj, j_calls->" + fn_line.group(2) + "_meth") elif not ret_ty_info.passed_as_ptr: out_c.write("\treturn (*_env)->Call" + ret_ty_info.java_ty.title() + "Method(_env, obj, j_calls->" + fn_line.group(2) + "_meth") else: out_c.write("\t" + fn_line.group(1).strip() + "* ret = (" + fn_line.group(1).strip() + "*)(*_env)->CallLongMethod(_env, obj, j_calls->" + fn_line.group(2) + "_meth"); + if ret_ty_info.java_ty != "void": + java_trait_constr = java_trait_constr + "\t\t\t\treturn arg." + fn_line.group(2) + "(" + else: + java_trait_constr = java_trait_constr + "\t\t\t\targ." + fn_line.group(2) + "(" for arg_info in arg_names: if arg_info.ret_conv is not None: @@ -833,6 +1112,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("\tFREE(ret);\n") out_c.write("\treturn res;\n") out_c.write("}\n") + java_trait_constr = java_trait_constr + ");\n\t\t\t}\n" elif fn_line.group(2) == "free": out_c.write("static void " + struct_name + "_JCalls_free(void* this_arg) {\n") out_c.write("\t" + struct_name + "_JCalls *j_calls = (" + struct_name + "_JCalls*) this_arg;\n") @@ -842,6 +1122,8 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg out_c.write("\t\t(*env)->DeleteWeakGlobalRef(env, j_calls->o);\n") out_c.write("\t\tFREE(j_calls);\n") out_c.write("\t}\n}\n") + #out_java_trait.write("\t}\n") + #out_java_trait.write(java_trait_constr + "\t\t});\n\t}\n") # Write out a clone function whether we need one or not, as we use them in moving to rust out_c.write("static void* " + struct_name + "_JCalls_clone(const void* this_arg) {\n") @@ -931,7 +1213,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg if sys.argv[4] == "false": out_c.write("#define MALLOC(a, _) malloc(a)\n") - out_c.write("#define FREE free\n") + out_c.write("#define FREE(p) if ((p) > 1024) { free(p); }\n") out_c.write("#define DO_ASSERT(a) (void)(a)\n") out_c.write("#define CHECK(a)\n") else: @@ -993,6 +1275,7 @@ static void alloc_freed(void* ptr) { __real_free(it); } static void FREE(void* ptr) { + if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); } @@ -1239,9 +1522,7 @@ class CommonBase { if is_opaque: opaque_structs.add(struct_name) with open(sys.argv[3] + "/structs/" + struct_name.replace("LDK","") + ".java", "w") as out_java_struct: - out_java_struct.write("package org.ldk.structs;\n\n") - out_java_struct.write("import org.ldk.impl.bindings;\n") - out_java_struct.write("import org.ldk.enums.*;\n\n") + out_java_struct.write(hu_struct_file_prefix) out_java_struct.write("public class " + struct_name.replace("LDK","") + " extends CommonBase") if struct_name.startswith("LDKLocked"): out_java_struct.write(" implements AutoCloseable") @@ -1268,6 +1549,7 @@ class CommonBase { elif is_tuple: out_java.write("\tpublic static native long " + struct_name + "_new(") out_c.write("JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_" + struct_name.replace("_", "_1") + "_1new(JNIEnv *_env, jclass _b") + ty_list = [] for idx, line in enumerate(field_lines): if idx != 0 and idx < len(field_lines) - 2: ty_info = java_c_types(line.strip(';'), None) @@ -1276,6 +1558,8 @@ class CommonBase { e = chr(ord('a') + idx - 1) out_java.write(ty_info.java_ty + " " + e) out_c.write(", " + ty_info.c_ty + " " + e) + ty_list.append(ty_info) + tuple_types[struct_name] = (ty_list, struct_name) out_java.write(");\n") out_c.write(") {\n") out_c.write("\t" + struct_name + "* ret = MALLOC(sizeof(" + struct_name + "), \"" + struct_name + "\");\n") @@ -1351,6 +1635,22 @@ class CommonBase { elif len(trait_fn_lines) > 0: trait_structs.add(struct_name) map_trait(struct_name, field_var_lines, trait_fn_lines) + elif struct_name == "LDKTxOut": + with open(sys.argv[3] + "/structs/TxOut.java", "w") as out_java_struct: + out_java_struct.write(hu_struct_file_prefix) + out_java_struct.write("public class TxOut extends CommonBase{\n") + out_java_struct.write("\tTxOut(java.lang.Object _dummy, long ptr) { super(ptr); }\n") + # TODO: TxOut body + out_java_struct.write("}") + elif struct_name == "LDKTransaction": + with open(sys.argv[3] + "/structs/Transaction.java", "w") as out_java_struct: + out_java_struct.write(hu_struct_file_prefix) + out_java_struct.write("public class Transaction extends CommonBase{\n") + out_java_struct.write("\tTransaction(java.lang.Object _dummy, long ptr) { super(ptr); }\n") + # TODO: Transaction body + out_java_struct.write("}") + else: + pass # Everything remaining is a byte[] or some form cur_block_obj = None else: fn_ptr = fn_ptr_regex.match(line) @@ -1372,37 +1672,78 @@ class CommonBase { cur_block_obj = line elif line.startswith("typedef "): alias_match = struct_alias_regex.match(line) - if alias_match.group(1) in result_templ_structs: - contents_ty = alias_match.group(1).replace("LDKCResultTempl", "LDKCResultPtr") - res_ty, err_ty = result_ptr_struct_items[contents_ty] - res_map = map_type(res_ty, True, None, False) - err_map = map_type(err_ty, True, None, False) - - out_java.write("\tpublic static native boolean " + alias_match.group(2) + "_result_ok(long arg);\n") - out_c.write("JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {\n") - out_c.write("\treturn ((" + alias_match.group(2) + "*)arg)->result_ok;\n") - out_c.write("}\n") + if alias_match.group(1) in tuple_types: + tuple_types[alias_match.group(2)] = (tuple_types[alias_match.group(1)][0], alias_match.group(2)) + tuple_types[alias_match.group(1)] = (tuple_types[alias_match.group(1)][0], alias_match.group(2)) + for idx, ty_info in enumerate(tuple_types[alias_match.group(1)][0]): + e = chr(ord('a') + idx) + out_java.write("\tpublic static native " + ty_info.java_ty + " " + alias_match.group(2) + "_get_" + e + "(long ptr);\n") + # XXX: Write C method! + elif alias_match.group(1) in result_templ_structs: + human_ty = alias_match.group(2).replace("LDKCResult", "Result_").replace("__", "_").replace("Templ", "") + with open(sys.argv[3] + "/structs/" + human_ty + ".java", "w") as out_java_struct: + out_java_struct.write(hu_struct_file_prefix) + out_java_struct.write("public class " + human_ty + " extends CommonBase {\n") + out_java_struct.write("\tprivate " + human_ty + "(Object _dummy, long ptr) { super(ptr); }\n") + out_java_struct.write("\tprotected void finalize() throws Throwable {\n") + out_java_struct.write("\t\tbindings." + alias_match.group(2).replace("LDK","") + "_free(ptr); super.finalize();\n") + out_java_struct.write("\t}\n\n") - out_java.write("\tpublic static native " + res_map.java_ty + " " + alias_match.group(2) + "_get_ok(long arg);\n") - out_c.write("JNIEXPORT " + res_map.c_ty + " JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {\n") - out_c.write("\t" + alias_match.group(2) + " *val = (" + alias_match.group(2) + "*)arg;\n") - out_c.write("\tCHECK(val->result_ok);\n\t") - if res_map.ret_conv is not None: - out_c.write(res_map.ret_conv[0].replace("\n", "\n\t") + "(*val->contents.result)") - out_c.write(res_map.ret_conv[1].replace("\n", "\n\t") + "\n\treturn " + res_map.ret_conv_name) - else: - out_c.write("return *val->contents.result") - out_c.write(";\n}\n") - - out_java.write("\tpublic static native " + err_map.java_ty + " " + alias_match.group(2) + "_get_err(long arg);\n") - out_c.write("JNIEXPORT " + err_map.c_ty + " JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {\n") - out_c.write("\t" + alias_match.group(2) + " *val = (" + alias_match.group(2) + "*)arg;\n") - out_c.write("\tCHECK(!val->result_ok);\n\t") - if err_map.ret_conv is not None: - out_c.write(err_map.ret_conv[0].replace("\n", "\n\t") + "(*val->contents.err)") - out_c.write(err_map.ret_conv[1].replace("\n", "\n\t") + "\n\treturn " + err_map.ret_conv_name) - else: - out_c.write("return *val->contents.err") + contents_ty = alias_match.group(1).replace("LDKCResultTempl", "LDKCResultPtr") + res_ty, err_ty = result_ptr_struct_items[contents_ty] + res_map = map_type(res_ty + " res", True, None, False) + err_map = map_type(err_ty + " err", True, None, False) + + out_java.write("\tpublic static native boolean " + alias_match.group(2) + "_result_ok(long arg);\n") + out_c.write("JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {\n") + out_c.write("\treturn ((" + alias_match.group(2) + "*)arg)->result_ok;\n") + out_c.write("}\n") + + out_java.write("\tpublic static native " + res_map.java_ty + " " + alias_match.group(2) + "_get_ok(long arg);\n") + out_c.write("JNIEXPORT " + res_map.c_ty + " JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) {\n") + out_c.write("\t" + alias_match.group(2) + " *val = (" + alias_match.group(2) + "*)arg;\n") + out_c.write("\tCHECK(val->result_ok);\n\t") + out_java_struct.write("\tpublic static final class " + human_ty + "_OK extends " + human_ty + " {\n") + if res_map.ret_conv is not None: + out_c.write(res_map.ret_conv[0].replace("\n", "\n\t") + "(*val->contents.result)") + out_c.write(res_map.ret_conv[1].replace("\n", "\n\t") + "\n\treturn " + res_map.ret_conv_name) + else: + out_c.write("return *val->contents.result") + out_c.write(";\n}\n") + + out_java_struct.write("\t\tpublic " + res_map.java_hu_ty + " res;\n") + out_java_struct.write("\t\tprivate " + human_ty + "_OK(Object _dummy, long ptr) {\n") + out_java_struct.write("\t\t\tsuper(_dummy, ptr);\n") + if res_map.to_hu_conv is not None: + out_java_struct.write("\t\t\t" + res_map.java_ty + " res = bindings." + alias_match.group(2) + "_get_ok(ptr);\n") + out_java_struct.write("\t\t\t" + res_map.to_hu_conv.replace("\n", "\n\t\t\t")) + out_java_struct.write("\n\t\t\tthis.res = " + res_map.to_hu_conv_name + ";\n") + else: + out_java_struct.write("\t\t\tthis.res = bindings." + alias_match.group(2) + "_get_ok(ptr);\n") + out_java_struct.write("\t\t}\n\n") + + out_java.write("\tpublic static native " + err_map.java_ty + " " + alias_match.group(2) + "_get_err(long arg);\n") + out_c.write("JNIEXPORT " + err_map.c_ty + " JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1get_1err (JNIEnv * _env, jclass _a, jlong arg) {\n") + out_c.write("\t" + alias_match.group(2) + " *val = (" + alias_match.group(2) + "*)arg;\n") + out_c.write("\tCHECK(!val->result_ok);\n\t") + out_java_struct.write("\t}\n\tpublic static final class " + human_ty + "_Err extends " + human_ty + " {\n") + if err_map.ret_conv is not None: + out_c.write(err_map.ret_conv[0].replace("\n", "\n\t") + "(*val->contents.err)") + out_c.write(err_map.ret_conv[1].replace("\n", "\n\t") + "\n\treturn " + err_map.ret_conv_name) + else: + out_c.write("return *val->contents.err") + out_c.write(";\n}\n") + + out_java_struct.write("\t\tpublic " + err_map.java_hu_ty + " err;\n") + out_java_struct.write("\t\tprivate " + human_ty + "_Err(Object _dummy, long ptr) {\n") + out_java_struct.write("\t\t\tsuper(_dummy, ptr);\n") + if err_map.to_hu_conv is not None: + out_java_struct.write("\t\t\t" + err_map.java_ty + " err = bindings." + alias_match.group(2) + "_get_err(ptr);\n") + out_java_struct.write("\t\t\t" + err_map.to_hu_conv.replace("\n", "\n\t\t\t")) + out_java_struct.write("\n\t\t\tthis.err = " + err_map.to_hu_conv_name + ";\n") + else: + out_java_struct.write("\t\t\tthis.err = bindings." + alias_match.group(2) + "_get_err(ptr);\n") + out_java_struct.write("\t\t}\n\t}\n}\n") elif fn_ptr is not None: map_fn(line, fn_ptr, None, None) elif fn_ret_arr is not None: diff --git a/src/main/java/org/ldk/impl/bindings.java b/src/main/java/org/ldk/impl/bindings.java index 8309b71c..f79ade37 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -35,6 +35,8 @@ public class bindings { public static native VecOrSliceDef LDKCVecTempl_u8_arr_info(long vec_ptr); public static native long LDKCVecTempl_u8_new(byte[] elems); public static native long LDKC2TupleTempl_usize__Transaction_new(long a, long b); + public static native long LDKC2Tuple_usizeTransactionZ_get_a(long ptr); + public static native long LDKC2Tuple_usizeTransactionZ_get_b(long ptr); public static native boolean LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(long arg); public static native byte LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(long arg); public static native LDKChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(long arg); @@ -42,12 +44,20 @@ public class bindings { public static native byte LDKCResult_NoneMonitorUpdateErrorZ_get_ok(long arg); public static native long LDKCResult_NoneMonitorUpdateErrorZ_get_err(long arg); public static native long LDKC2TupleTempl_OutPoint__CVec_u8Z_new(long a, byte[] b); + public static native long LDKC2Tuple_OutPointScriptZ_get_a(long ptr); + public static native byte[] LDKC2Tuple_OutPointScriptZ_get_b(long ptr); public static native VecOrSliceDef LDKCVecTempl_TxOut_arr_info(long vec_ptr); public static native long LDKCVecTempl_TxOut_new(long[] elems); - public static native long LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut_new(byte[] a, long b); + public static native long LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut_new(byte[] a, long[] b); + public static native byte[] LDKC2Tuple_TxidCVec_TxOutZZ_get_a(long ptr); + public static native long[] LDKC2Tuple_TxidCVec_TxOutZZ_get_b(long ptr); public static native long LDKC2TupleTempl_u64__u64_new(long a, long b); + public static native long LDKC2Tuple_u64u64Z_get_a(long ptr); + public static native long LDKC2Tuple_u64u64Z_get_b(long ptr); public static native VecOrSliceDef LDKCVecTempl_Signature_arr_info(long vec_ptr); - public static native long LDKC2TupleTempl_Signature__CVecTempl_Signature_new(byte[] a, long b); + public static native long LDKC2TupleTempl_Signature__CVecTempl_Signature_new(byte[] a, byte[][] b); + public static native byte[] LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(long ptr); + public static native byte[][] LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(long ptr); public static native boolean LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(long arg); public static native long LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(long arg); public static native byte LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(long arg); @@ -55,7 +65,7 @@ public class bindings { public static native byte[] LDKCResult_SignatureNoneZ_get_ok(long arg); public static native byte LDKCResult_SignatureNoneZ_get_err(long arg); public static native boolean LDKCResult_CVec_SignatureZNoneZ_result_ok(long arg); - public static native long LDKCResult_CVec_SignatureZNoneZ_get_ok(long arg); + public static native byte[][] LDKCResult_CVec_SignatureZNoneZ_get_ok(long arg); public static native byte LDKCResult_CVec_SignatureZNoneZ_get_err(long arg); public static class LDKAPIError { private LDKAPIError() {} @@ -69,8 +79,8 @@ public class bindings { FeeRateTooHigh(byte[] err, int feerate) { this.err = err; this.feerate = feerate; } } public final static class RouteError extends LDKAPIError { - public long err; - RouteError(long err) { this.err = err; } + public String err; + RouteError(String err) { this.err = err; } } public final static class ChannelUnavailable extends LDKAPIError { public byte[] err; @@ -89,10 +99,15 @@ public class bindings { public static native byte LDKCResult_NonePaymentSendFailureZ_get_ok(long arg); public static native long LDKCResult_NonePaymentSendFailureZ_get_err(long arg); public static native long LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate_new(long a, long b, long c); + public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(long ptr); + public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(long ptr); + public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(long ptr); public static native boolean LDKCResult_NonePeerHandleErrorZ_result_ok(long arg); public static native byte LDKCResult_NonePeerHandleErrorZ_get_ok(long arg); public static native long LDKCResult_NonePeerHandleErrorZ_get_err(long arg); public static native long LDKC2TupleTempl_HTLCOutputInCommitment__Signature_new(long a, byte[] b); + public static native long LDKC2Tuple_HTLCOutputInCommitmentSignatureZ_get_a(long ptr); + public static native byte[] LDKC2Tuple_HTLCOutputInCommitmentSignatureZ_get_b(long ptr); public static class LDKSpendableOutputDescriptor { private LDKSpendableOutputDescriptor() {} public final static class StaticOutput extends LDKSpendableOutputDescriptor { @@ -155,8 +170,8 @@ public class bindings { PendingHTLCsForwardable(long time_forwardable) { this.time_forwardable = time_forwardable; } } public final static class SpendableOutputs extends LDKEvent { - public long outputs; - SpendableOutputs(long outputs) { this.outputs = outputs; } + public long[] outputs; + SpendableOutputs(long[] outputs) { this.outputs = outputs; } } static native void init(); } @@ -284,21 +299,21 @@ public class bindings { public static native VecOrSliceDef LDKCVecTempl_MessageSendEvent_arr_info(long vec_ptr); public static native long LDKCVecTempl_MessageSendEvent_new(long[] elems); public interface LDKMessageSendEventsProvider { - long get_and_clear_pending_msg_events(); + long[] get_and_clear_pending_msg_events(); } public static native long LDKMessageSendEventsProvider_new(LDKMessageSendEventsProvider impl); public static native LDKMessageSendEventsProvider LDKMessageSendEventsProvider_get_obj_from_jcalls(long val); // LDKCVec_MessageSendEventZ MessageSendEventsProvider_get_and_clear_pending_msg_events LDKMessageSendEventsProvider* this_arg - public static native long MessageSendEventsProvider_get_and_clear_pending_msg_events(long this_arg); + public static native long[] MessageSendEventsProvider_get_and_clear_pending_msg_events(long this_arg); public static native VecOrSliceDef LDKCVecTempl_Event_arr_info(long vec_ptr); public static native long LDKCVecTempl_Event_new(long[] elems); public interface LDKEventsProvider { - long get_and_clear_pending_events(); + long[] get_and_clear_pending_events(); } public static native long LDKEventsProvider_new(LDKEventsProvider impl); public static native LDKEventsProvider LDKEventsProvider_get_obj_from_jcalls(long val); // LDKCVec_EventZ EventsProvider_get_and_clear_pending_events LDKEventsProvider* this_arg - public static native long EventsProvider_get_and_clear_pending_events(long this_arg); + public static native long[] EventsProvider_get_and_clear_pending_events(long this_arg); public interface LDKLogger { void log(String record); } @@ -320,7 +335,7 @@ public class bindings { byte[] get_per_commitment_point(long idx); byte[] release_commitment_secret(long idx); long key_derivation_params(); - long sign_counterparty_commitment(int feerate_per_kw, long commitment_tx, long keys, long htlcs); + long sign_counterparty_commitment(int feerate_per_kw, long commitment_tx, long keys, long[] htlcs); long sign_holder_commitment(long holder_commitment_tx); long sign_holder_commitment_htlc_transactions(long holder_commitment_tx); long sign_justice_transaction(long justice_tx, long input, long amount, byte[] per_commitment_key, long htlc); @@ -338,7 +353,7 @@ public class bindings { // LDKC2Tuple_u64u64Z ChannelKeys_key_derivation_params LDKChannelKeys* this_arg public static native long ChannelKeys_key_derivation_params(long this_arg); // LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ChannelKeys_sign_counterparty_commitment LDKChannelKeys* this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs - public static native long ChannelKeys_sign_counterparty_commitment(long this_arg, int feerate_per_kw, long commitment_tx, long keys, long htlcs); + public static native long ChannelKeys_sign_counterparty_commitment(long this_arg, int feerate_per_kw, long commitment_tx, long keys, long[] htlcs); // LDKCResult_SignatureNoneZ ChannelKeys_sign_holder_commitment LDKChannelKeys* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx public static native long ChannelKeys_sign_holder_commitment(long this_arg, long holder_commitment_tx); // LDKCResult_CVec_SignatureZNoneZ ChannelKeys_sign_holder_commitment_htlc_transactions LDKChannelKeys* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx @@ -358,7 +373,7 @@ public class bindings { public interface LDKWatch { long watch_channel(long funding_txo, long monitor); long update_channel(long funding_txo, long update); - long release_pending_monitor_events(); + long[] release_pending_monitor_events(); } public static native long LDKWatch_new(LDKWatch impl); public static native LDKWatch LDKWatch_get_obj_from_jcalls(long val); @@ -367,7 +382,7 @@ public class bindings { // LDKCResult_NoneChannelMonitorUpdateErrZ Watch_update_channel LDKWatch* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update public static native long Watch_update_channel(long this_arg, long funding_txo, long update); // LDKCVec_MonitorEventZ Watch_release_pending_monitor_events LDKWatch* this_arg - public static native long Watch_release_pending_monitor_events(long this_arg); + public static native long[] Watch_release_pending_monitor_events(long this_arg); public interface LDKFilter { void register_tx(byte[] txid, byte[] script_pubkey); void register_output(long outpoint, byte[] script_pubkey); @@ -422,19 +437,19 @@ public class bindings { public static class LDKNetAddress { private LDKNetAddress() {} public final static class IPv4 extends LDKNetAddress { - public long addr; + public byte[] addr; public short port; - IPv4(long addr, short port) { this.addr = addr; this.port = port; } + IPv4(byte[] addr, short port) { this.addr = addr; this.port = port; } } public final static class IPv6 extends LDKNetAddress { - public long addr; + public byte[] addr; public short port; - IPv6(long addr, short port) { this.addr = addr; this.port = port; } + IPv6(byte[] addr, short port) { this.addr = addr; this.port = port; } } public final static class OnionV2 extends LDKNetAddress { - public long addr; + public byte[] addr; public short port; - OnionV2(long addr, short port) { this.addr = addr; this.port = port; } + OnionV2(byte[] addr, short port) { this.addr = addr; this.port = port; } } public final static class OnionV3 extends LDKNetAddress { public byte[] ed25519_pubkey; @@ -534,8 +549,8 @@ public class bindings { long handle_channel_announcement(long msg); long handle_channel_update(long msg); void handle_htlc_fail_channel_update(long update); - long get_next_channel_announcements(long starting_point, byte batch_amount); - long get_next_node_announcements(byte[] starting_point, byte batch_amount); + long[] get_next_channel_announcements(long starting_point, byte batch_amount); + long[] get_next_node_announcements(byte[] starting_point, byte batch_amount); boolean should_request_full_sync(byte[] node_id); } public static native long LDKRoutingMessageHandler_new(LDKRoutingMessageHandler impl); @@ -549,9 +564,9 @@ public class bindings { // void RoutingMessageHandler_handle_htlc_fail_channel_update LDKRoutingMessageHandler* this_arg, const LDKHTLCFailChannelUpdate *update public static native void RoutingMessageHandler_handle_htlc_fail_channel_update(long this_arg, long update); // LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler_get_next_channel_announcements LDKRoutingMessageHandler* this_arg, uint64_t starting_point, uint8_t batch_amount - public static native long RoutingMessageHandler_get_next_channel_announcements(long this_arg, long starting_point, byte batch_amount); + public static native long[] RoutingMessageHandler_get_next_channel_announcements(long this_arg, long starting_point, byte batch_amount); // LDKCVec_NodeAnnouncementZ RoutingMessageHandler_get_next_node_announcements LDKRoutingMessageHandler* this_arg, LDKPublicKey starting_point, uint8_t batch_amount - public static native long RoutingMessageHandler_get_next_node_announcements(long this_arg, byte[] starting_point, byte batch_amount); + public static native long[] RoutingMessageHandler_get_next_node_announcements(long this_arg, byte[] starting_point, byte batch_amount); // bool RoutingMessageHandler_should_request_full_sync LDKRoutingMessageHandler* this_arg, LDKPublicKey node_id public static native boolean RoutingMessageHandler_should_request_full_sync(long this_arg, byte[] node_id); public interface LDKSocketDescriptor { @@ -589,7 +604,6 @@ public class bindings { public static native long[] LDKCVecTempl_RouteHop_arr_info(long vec_ptr); public static native long LDKCVecTempl_RouteHop_new(long[] elems); public static native VecOrSliceDef LDKCVecTempl_CVecTempl_RouteHop_arr_info(long vec_ptr); - public static native long LDKCVecTempl_CVecTempl_RouteHop_new(long[] elems); public static native boolean LDKCResult_RouteLightningErrorZ_result_ok(long arg); public static native long LDKCResult_RouteLightningErrorZ_get_ok(long arg); public static native long LDKCResult_RouteLightningErrorZ_get_err(long arg); @@ -616,7 +630,7 @@ public class bindings { // extern const void (*CResult_CVec_SignatureZNoneZ_free)(LDKCResult_CVec_SignatureZNoneZ); public static native void CResult_CVec_SignatureZNoneZ_free(long arg); // extern const LDKCResult_CVec_SignatureZNoneZ (*CResult_CVec_SignatureZNoneZ_ok)(LDKCVec_SignatureZ); - public static native long CResult_CVec_SignatureZNoneZ_ok(long arg); + public static native long CResult_CVec_SignatureZNoneZ_ok(byte[][] arg); // extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_err)(LDKPeerHandleError); public static native long CResult_CVec_u8ZPeerHandleErrorZ_err(long arg); // extern const void (*CResult_CVec_u8ZPeerHandleErrorZ_free)(LDKCResult_CVec_u8ZPeerHandleErrorZ); @@ -690,55 +704,55 @@ public class bindings { // extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_ok)(bool); public static native long CResult_boolPeerHandleErrorZ_ok(boolean arg); // extern const void (*CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free)(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ); - public static native void CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(long arg); + public static native void CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(long[] arg); // extern const void (*CVec_C2Tuple_TxidCVec_TxOutZZZ_free)(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ); - public static native void CVec_C2Tuple_TxidCVec_TxOutZZZ_free(long arg); + public static native void CVec_C2Tuple_TxidCVec_TxOutZZZ_free(long[] arg); // extern const void (*CVec_C2Tuple_usizeTransactionZZ_free)(LDKCVec_C2Tuple_usizeTransactionZZ); - public static native void CVec_C2Tuple_usizeTransactionZZ_free(long arg); + public static native void CVec_C2Tuple_usizeTransactionZZ_free(long[] arg); // extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ); - public static native void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(long arg); + public static native void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(long[] arg); // extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ); - public static native void CVec_CVec_RouteHopZZ_free(long arg); + public static native void CVec_CVec_RouteHopZZ_free(long[][] arg); // extern const void (*CVec_ChannelDetailsZ_free)(LDKCVec_ChannelDetailsZ); - public static native void CVec_ChannelDetailsZ_free(long arg); + public static native void CVec_ChannelDetailsZ_free(long[] arg); // extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ); - public static native void CVec_ChannelMonitorZ_free(long arg); + public static native void CVec_ChannelMonitorZ_free(long[] arg); // extern const void (*CVec_EventZ_free)(LDKCVec_EventZ); - public static native void CVec_EventZ_free(long arg); + public static native void CVec_EventZ_free(long[] arg); // extern const void (*CVec_HTLCOutputInCommitmentZ_free)(LDKCVec_HTLCOutputInCommitmentZ); - public static native void CVec_HTLCOutputInCommitmentZ_free(long arg); + public static native void CVec_HTLCOutputInCommitmentZ_free(long[] arg); // extern const void (*CVec_MessageSendEventZ_free)(LDKCVec_MessageSendEventZ); - public static native void CVec_MessageSendEventZ_free(long arg); + public static native void CVec_MessageSendEventZ_free(long[] arg); // extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ); - public static native void CVec_MonitorEventZ_free(long arg); + public static native void CVec_MonitorEventZ_free(long[] arg); // extern const void (*CVec_NetAddressZ_free)(LDKCVec_NetAddressZ); - public static native void CVec_NetAddressZ_free(long arg); + public static native void CVec_NetAddressZ_free(long[] arg); // extern const void (*CVec_NodeAnnouncementZ_free)(LDKCVec_NodeAnnouncementZ); - public static native void CVec_NodeAnnouncementZ_free(long arg); + public static native void CVec_NodeAnnouncementZ_free(long[] arg); // extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ); - public static native void CVec_PublicKeyZ_free(long arg); + public static native void CVec_PublicKeyZ_free(byte[][] arg); // extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ); - public static native void CVec_RouteHintZ_free(long arg); + public static native void CVec_RouteHintZ_free(long[] arg); // extern const void (*CVec_RouteHopZ_free)(LDKCVec_RouteHopZ); - public static native void CVec_RouteHopZ_free(long arg); + public static native void CVec_RouteHopZ_free(long[] arg); // extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ); - public static native void CVec_SignatureZ_free(long arg); + public static native void CVec_SignatureZ_free(byte[][] arg); // extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ); - public static native void CVec_SpendableOutputDescriptorZ_free(long arg); + public static native void CVec_SpendableOutputDescriptorZ_free(long[] arg); // extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ); - public static native void CVec_TransactionZ_free(long arg); + public static native void CVec_TransactionZ_free(long[] arg); // extern const void (*CVec_TxOutZ_free)(LDKCVec_TxOutZ); - public static native void CVec_TxOutZ_free(long arg); + public static native void CVec_TxOutZ_free(long[] arg); // extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ); - public static native void CVec_UpdateAddHTLCZ_free(long arg); + public static native void CVec_UpdateAddHTLCZ_free(long[] arg); // extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ); - public static native void CVec_UpdateFailHTLCZ_free(long arg); + public static native void CVec_UpdateFailHTLCZ_free(long[] arg); // extern const void (*CVec_UpdateFailMalformedHTLCZ_free)(LDKCVec_UpdateFailMalformedHTLCZ); - public static native void CVec_UpdateFailMalformedHTLCZ_free(long arg); + public static native void CVec_UpdateFailMalformedHTLCZ_free(long[] arg); // extern const void (*CVec_UpdateFulfillHTLCZ_free)(LDKCVec_UpdateFulfillHTLCZ); - public static native void CVec_UpdateFulfillHTLCZ_free(long arg); + public static native void CVec_UpdateFulfillHTLCZ_free(long[] arg); // extern const void (*CVec_u64Z_free)(LDKCVec_u64Z); - public static native void CVec_u64Z_free(long arg); + public static native void CVec_u64Z_free(long[] arg); // extern const void (*CVec_u8Z_free)(LDKCVec_u8Z); public static native void CVec_u8Z_free(byte[] arg); // void Transaction_free(LDKTransaction _res); @@ -754,11 +768,11 @@ public class bindings { // LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b); public static native long C2Tuple_OutPointScriptZ_new(long a, byte[] b); // LDKC2Tuple_TxidCVec_TxOutZZ C2Tuple_TxidCVec_TxOutZZ_new(LDKThirtyTwoBytes a, LDKCVec_TxOutZ b); - public static native long C2Tuple_TxidCVec_TxOutZZ_new(byte[] a, long b); + public static native long C2Tuple_TxidCVec_TxOutZZ_new(byte[] a, long[] b); // LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b); public static native long C2Tuple_u64u64Z_new(long a, long b); // LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(LDKSignature a, LDKCVec_SignatureZ b); - public static native long C2Tuple_SignatureCVec_SignatureZZ_new(byte[] a, long b); + public static native long C2Tuple_SignatureCVec_SignatureZZ_new(byte[] a, byte[][] b); // LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); public static native long CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(); // LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); @@ -914,7 +928,7 @@ public class bindings { // void ChainMonitor_free(LDKChainMonitor this_ptr); public static native void ChainMonitor_free(long this_ptr); // void ChainMonitor_block_connected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - public static native void ChainMonitor_block_connected(long this_arg, byte[] header, long txdata, int height); + public static native void ChainMonitor_block_connected(long this_arg, byte[] header, long[] txdata, int height); // void ChainMonitor_block_disconnected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height); public static native void ChainMonitor_block_disconnected(long this_arg, byte[] header, int disconnected_height); // MUST_USE_RES LDKChainMonitor ChainMonitor_new(LDKFilter *chain_source, LDKBroadcasterInterface broadcaster, LDKLogger logger, LDKFeeEstimator feeest); @@ -956,13 +970,13 @@ public class bindings { // MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg); public static native long ChannelMonitor_get_funding_txo(long this_arg); // MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg); - public static native long ChannelMonitor_get_and_clear_pending_monitor_events(long this_arg); + public static native long[] ChannelMonitor_get_and_clear_pending_monitor_events(long this_arg); // MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg); - public static native long ChannelMonitor_get_and_clear_pending_events(long this_arg); + public static native long[] ChannelMonitor_get_and_clear_pending_events(long this_arg); // MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger); - public static native long ChannelMonitor_get_latest_holder_commitment_txn(long this_arg, long logger); + public static native long[] ChannelMonitor_get_latest_holder_commitment_txn(long this_arg, long logger); // MUST_USE_RES LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ChannelMonitor_block_connected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger); - public static native long ChannelMonitor_block_connected(long this_arg, byte[] header, long txdata, int height, long broadcaster, long fee_estimator, long logger); + public static native long[] ChannelMonitor_block_connected(long this_arg, byte[] header, long[] txdata, int height, long broadcaster, long fee_estimator, long logger); // void ChannelMonitor_block_disconnected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger); public static native void ChannelMonitor_block_disconnected(long this_arg, byte[] header, int height, long broadcaster, long fee_estimator, long logger); // void OutPoint_free(LDKOutPoint this_ptr); @@ -1086,9 +1100,9 @@ public class bindings { // MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const LDKChannelManager *this_arg, LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, LDKUserConfig override_config); public static native long ChannelManager_create_channel(long this_arg, byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_id, long override_config); // MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const LDKChannelManager *this_arg); - public static native long ChannelManager_list_channels(long this_arg); + public static native long[] ChannelManager_list_channels(long this_arg); // MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const LDKChannelManager *this_arg); - public static native long ChannelManager_list_usable_channels(long this_arg); + public static native long[] ChannelManager_list_usable_channels(long this_arg); // MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); public static native long ChannelManager_close_channel(long this_arg, byte[] channel_id); // void ChannelManager_force_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); @@ -1100,7 +1114,7 @@ public class bindings { // void ChannelManager_funding_transaction_generated(const LDKChannelManager *this_arg, const uint8_t (*temporary_channel_id)[32], LDKOutPoint funding_txo); public static native void ChannelManager_funding_transaction_generated(long this_arg, byte[] temporary_channel_id, long funding_txo); // void ChannelManager_broadcast_node_announcement(const LDKChannelManager *this_arg, LDKThreeBytes rgb, LDKThirtyTwoBytes alias, LDKCVec_NetAddressZ addresses); - public static native void ChannelManager_broadcast_node_announcement(long this_arg, byte[] rgb, byte[] alias, long addresses); + public static native void ChannelManager_broadcast_node_announcement(long this_arg, byte[] rgb, byte[] alias, long[] addresses); // void ChannelManager_process_pending_htlc_forwards(const LDKChannelManager *this_arg); public static native void ChannelManager_process_pending_htlc_forwards(long this_arg); // void ChannelManager_timer_chan_freshness_every_min(const LDKChannelManager *this_arg); @@ -1118,7 +1132,7 @@ public class bindings { // LDKEventsProvider ChannelManager_as_EventsProvider(const LDKChannelManager *this_arg); public static native long ChannelManager_as_EventsProvider(long this_arg); // void ChannelManager_block_connected(const LDKChannelManager *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - public static native void ChannelManager_block_connected(long this_arg, byte[] header, long txdata, int height); + public static native void ChannelManager_block_connected(long this_arg, byte[] header, long[] txdata, int height); // void ChannelManager_block_disconnected(const LDKChannelManager *this_arg, const uint8_t (*header)[80]); public static native void ChannelManager_block_disconnected(long this_arg, byte[] header); // LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const LDKChannelManager *this_arg); @@ -1150,7 +1164,7 @@ public class bindings { // void ChannelManagerReadArgs_set_default_config(LDKChannelManagerReadArgs *this_ptr, LDKUserConfig val); public static native void ChannelManagerReadArgs_set_default_config(long this_ptr, long val); // MUST_USE_RES LDKChannelManagerReadArgs ChannelManagerReadArgs_new(LDKKeysInterface keys_manager, LDKFeeEstimator fee_estimator, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors); - public static native long ChannelManagerReadArgs_new(long keys_manager, long fee_estimator, long chain_monitor, long tx_broadcaster, long logger, long default_config, long channel_monitors); + public static native long ChannelManagerReadArgs_new(long keys_manager, long fee_estimator, long chain_monitor, long tx_broadcaster, long logger, long default_config, long[] channel_monitors); // void DecodeError_free(LDKDecodeError this_ptr); public static native void DecodeError_free(long this_ptr); // void Init_free(LDKInit this_ptr); @@ -1166,7 +1180,7 @@ public class bindings { // void ErrorMessage_set_channel_id(LDKErrorMessage *this_ptr, LDKThirtyTwoBytes val); public static native void ErrorMessage_set_channel_id(long this_ptr, byte[] val); // LDKStr ErrorMessage_get_data(const LDKErrorMessage *this_ptr); - public static native long ErrorMessage_get_data(long this_ptr); + public static native String ErrorMessage_get_data(long this_ptr); // void ErrorMessage_set_data(LDKErrorMessage *this_ptr, LDKCVec_u8Z val); public static native void ErrorMessage_set_data(long this_ptr, byte[] val); // MUST_USE_RES LDKErrorMessage ErrorMessage_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z data_arg); @@ -1496,9 +1510,9 @@ public class bindings { // void CommitmentSigned_set_signature(LDKCommitmentSigned *this_ptr, LDKSignature val); public static native void CommitmentSigned_set_signature(long this_ptr, byte[] val); // void CommitmentSigned_set_htlc_signatures(LDKCommitmentSigned *this_ptr, LDKCVec_SignatureZ val); - public static native void CommitmentSigned_set_htlc_signatures(long this_ptr, long val); + public static native void CommitmentSigned_set_htlc_signatures(long this_ptr, byte[][] val); // MUST_USE_RES LDKCommitmentSigned CommitmentSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg, LDKCVec_SignatureZ htlc_signatures_arg); - public static native long CommitmentSigned_new(byte[] channel_id_arg, byte[] signature_arg, long htlc_signatures_arg); + public static native long CommitmentSigned_new(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg); // void RevokeAndACK_free(LDKRevokeAndACK this_ptr); public static native void RevokeAndACK_free(long this_ptr); // LDKRevokeAndACK RevokeAndACK_clone(const LDKRevokeAndACK *orig); @@ -1610,7 +1624,7 @@ public class bindings { // void UnsignedNodeAnnouncement_set_alias(LDKUnsignedNodeAnnouncement *this_ptr, LDKThirtyTwoBytes val); public static native void UnsignedNodeAnnouncement_set_alias(long this_ptr, byte[] val); // void UnsignedNodeAnnouncement_set_addresses(LDKUnsignedNodeAnnouncement *this_ptr, LDKCVec_NetAddressZ val); - public static native void UnsignedNodeAnnouncement_set_addresses(long this_ptr, long val); + public static native void UnsignedNodeAnnouncement_set_addresses(long this_ptr, long[] val); // void NodeAnnouncement_free(LDKNodeAnnouncement this_ptr); public static native void NodeAnnouncement_free(long this_ptr); // LDKNodeAnnouncement NodeAnnouncement_clone(const LDKNodeAnnouncement *orig); @@ -1772,9 +1786,9 @@ public class bindings { // void ReplyChannelRange_set_full_information(LDKReplyChannelRange *this_ptr, bool val); public static native void ReplyChannelRange_set_full_information(long this_ptr, boolean val); // void ReplyChannelRange_set_short_channel_ids(LDKReplyChannelRange *this_ptr, LDKCVec_u64Z val); - public static native void ReplyChannelRange_set_short_channel_ids(long this_ptr, long val); + public static native void ReplyChannelRange_set_short_channel_ids(long this_ptr, long[] val); // MUST_USE_RES LDKReplyChannelRange ReplyChannelRange_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool full_information_arg, LDKCVec_u64Z short_channel_ids_arg); - public static native long ReplyChannelRange_new(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, boolean full_information_arg, long short_channel_ids_arg); + public static native long ReplyChannelRange_new(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, boolean full_information_arg, long[] short_channel_ids_arg); // void QueryShortChannelIds_free(LDKQueryShortChannelIds this_ptr); public static native void QueryShortChannelIds_free(long this_ptr); // LDKQueryShortChannelIds QueryShortChannelIds_clone(const LDKQueryShortChannelIds *orig); @@ -1784,9 +1798,9 @@ public class bindings { // void QueryShortChannelIds_set_chain_hash(LDKQueryShortChannelIds *this_ptr, LDKThirtyTwoBytes val); public static native void QueryShortChannelIds_set_chain_hash(long this_ptr, byte[] val); // void QueryShortChannelIds_set_short_channel_ids(LDKQueryShortChannelIds *this_ptr, LDKCVec_u64Z val); - public static native void QueryShortChannelIds_set_short_channel_ids(long this_ptr, long val); + public static native void QueryShortChannelIds_set_short_channel_ids(long this_ptr, long[] val); // MUST_USE_RES LDKQueryShortChannelIds QueryShortChannelIds_new(LDKThirtyTwoBytes chain_hash_arg, LDKCVec_u64Z short_channel_ids_arg); - public static native long QueryShortChannelIds_new(byte[] chain_hash_arg, long short_channel_ids_arg); + public static native long QueryShortChannelIds_new(byte[] chain_hash_arg, long[] short_channel_ids_arg); // void ReplyShortChannelIdsEnd_free(LDKReplyShortChannelIdsEnd this_ptr); public static native void ReplyShortChannelIdsEnd_free(long this_ptr); // LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const LDKReplyShortChannelIdsEnd *orig); @@ -1824,7 +1838,7 @@ public class bindings { // void LightningError_free(LDKLightningError this_ptr); public static native void LightningError_free(long this_ptr); // LDKStr LightningError_get_err(const LDKLightningError *this_ptr); - public static native long LightningError_get_err(long this_ptr); + public static native String LightningError_get_err(long this_ptr); // void LightningError_set_err(LDKLightningError *this_ptr, LDKCVec_u8Z val); public static native void LightningError_set_err(long this_ptr, byte[] val); // LDKErrorAction LightningError_get_action(const LDKLightningError *this_ptr); @@ -1838,13 +1852,13 @@ public class bindings { // LDKCommitmentUpdate CommitmentUpdate_clone(const LDKCommitmentUpdate *orig); public static native long CommitmentUpdate_clone(long orig); // void CommitmentUpdate_set_update_add_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateAddHTLCZ val); - public static native void CommitmentUpdate_set_update_add_htlcs(long this_ptr, long val); + public static native void CommitmentUpdate_set_update_add_htlcs(long this_ptr, long[] val); // void CommitmentUpdate_set_update_fulfill_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFulfillHTLCZ val); - public static native void CommitmentUpdate_set_update_fulfill_htlcs(long this_ptr, long val); + public static native void CommitmentUpdate_set_update_fulfill_htlcs(long this_ptr, long[] val); // void CommitmentUpdate_set_update_fail_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailHTLCZ val); - public static native void CommitmentUpdate_set_update_fail_htlcs(long this_ptr, long val); + public static native void CommitmentUpdate_set_update_fail_htlcs(long this_ptr, long[] val); // void CommitmentUpdate_set_update_fail_malformed_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailMalformedHTLCZ val); - public static native void CommitmentUpdate_set_update_fail_malformed_htlcs(long this_ptr, long val); + public static native void CommitmentUpdate_set_update_fail_malformed_htlcs(long this_ptr, long[] val); // LDKUpdateFee CommitmentUpdate_get_update_fee(const LDKCommitmentUpdate *this_ptr); public static native long CommitmentUpdate_get_update_fee(long this_ptr); // void CommitmentUpdate_set_update_fee(LDKCommitmentUpdate *this_ptr, LDKUpdateFee val); @@ -1854,7 +1868,7 @@ public class bindings { // void CommitmentUpdate_set_commitment_signed(LDKCommitmentUpdate *this_ptr, LDKCommitmentSigned val); public static native void CommitmentUpdate_set_commitment_signed(long this_ptr, long val); // MUST_USE_RES LDKCommitmentUpdate CommitmentUpdate_new(LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, LDKUpdateFee update_fee_arg, LDKCommitmentSigned commitment_signed_arg); - public static native long CommitmentUpdate_new(long update_add_htlcs_arg, long update_fulfill_htlcs_arg, long update_fail_htlcs_arg, long update_fail_malformed_htlcs_arg, long update_fee_arg, long commitment_signed_arg); + public static native long CommitmentUpdate_new(long[] update_add_htlcs_arg, long[] update_fulfill_htlcs_arg, long[] update_fail_htlcs_arg, long[] update_fail_malformed_htlcs_arg, long update_fee_arg, long commitment_signed_arg); // void HTLCFailChannelUpdate_free(LDKHTLCFailChannelUpdate this_ptr); public static native void HTLCFailChannelUpdate_free(long this_ptr); // void ChannelMessageHandler_free(LDKChannelMessageHandler this_ptr); @@ -2012,7 +2026,7 @@ public class bindings { // MUST_USE_RES LDKPeerManager PeerManager_new(LDKMessageHandler message_handler, LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], LDKLogger logger); public static native long PeerManager_new(long message_handler, byte[] our_node_secret, byte[] ephemeral_random_data, long logger); // MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const LDKPeerManager *this_arg); - public static native long PeerManager_get_peer_node_ids(long this_arg); + public static native byte[][] PeerManager_get_peer_node_ids(long this_arg); // MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const LDKPeerManager *this_arg, LDKPublicKey their_node_id, LDKSocketDescriptor descriptor); public static native long PeerManager_new_outbound_connection(long this_arg, byte[] their_node_id, long descriptor); // MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const LDKPeerManager *this_arg, LDKSocketDescriptor descriptor); @@ -2156,9 +2170,9 @@ public class bindings { // void HolderCommitmentTransaction_set_feerate_per_kw(LDKHolderCommitmentTransaction *this_ptr, uint32_t val); public static native void HolderCommitmentTransaction_set_feerate_per_kw(long this_ptr, int val); // void HolderCommitmentTransaction_set_per_htlc(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val); - public static native void HolderCommitmentTransaction_set_per_htlc(long this_ptr, long val); + public static native void HolderCommitmentTransaction_set_per_htlc(long this_ptr, long[] val); // MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKTransaction unsigned_tx, LDKSignature counterparty_sig, LDKPublicKey holder_funding_key, LDKPublicKey counterparty_funding_key, LDKTxCreationKeys keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data); - public static native long HolderCommitmentTransaction_new_missing_holder_sig(long unsigned_tx, byte[] counterparty_sig, byte[] holder_funding_key, byte[] counterparty_funding_key, long keys, int feerate_per_kw, long htlc_data); + public static native long HolderCommitmentTransaction_new_missing_holder_sig(long unsigned_tx, byte[] counterparty_sig, byte[] holder_funding_key, byte[] counterparty_funding_key, long keys, int feerate_per_kw, long[] htlc_data); // MUST_USE_RES LDKTxCreationKeys HolderCommitmentTransaction_trust_key_derivation(const LDKHolderCommitmentTransaction *this_arg); public static native long HolderCommitmentTransaction_trust_key_derivation(long this_arg); // MUST_USE_RES LDKThirtyTwoBytes HolderCommitmentTransaction_txid(const LDKHolderCommitmentTransaction *this_arg); @@ -2212,9 +2226,9 @@ public class bindings { // LDKRoute Route_clone(const LDKRoute *orig); public static native long Route_clone(long orig); // void Route_set_paths(LDKRoute *this_ptr, LDKCVec_CVec_RouteHopZZ val); - public static native void Route_set_paths(long this_ptr, long val); + public static native void Route_set_paths(long this_ptr, long[][] val); // MUST_USE_RES LDKRoute Route_new(LDKCVec_CVec_RouteHopZZ paths_arg); - public static native long Route_new(long paths_arg); + public static native long Route_new(long[][] paths_arg); // LDKCVec_u8Z Route_write(const LDKRoute *obj); public static native byte[] Route_write(long obj); // LDKRoute Route_read(LDKu8slice ser); @@ -2246,7 +2260,7 @@ public class bindings { // MUST_USE_RES LDKRouteHint RouteHint_new(LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg); public static native long RouteHint_new(byte[] src_node_id_arg, long short_channel_id_arg, long fees_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg); // LDKCResult_RouteLightningErrorZ get_route(LDKPublicKey our_node_id, const LDKNetworkGraph *network, LDKPublicKey target, LDKCVec_ChannelDetailsZ *first_hops, LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, LDKLogger logger); - public static native long get_route(byte[] our_node_id, long network, byte[] target, long first_hops, long last_hops, long final_value_msat, int final_cltv, long logger); + public static native long get_route(byte[] our_node_id, long network, byte[] target, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger); // void NetworkGraph_free(LDKNetworkGraph this_ptr); public static native void NetworkGraph_free(long this_ptr); // void LockedNetworkGraph_free(LDKLockedNetworkGraph this_ptr); @@ -2356,13 +2370,13 @@ public class bindings { // void NodeAnnouncementInfo_set_alias(LDKNodeAnnouncementInfo *this_ptr, LDKThirtyTwoBytes val); public static native void NodeAnnouncementInfo_set_alias(long this_ptr, byte[] val); // void NodeAnnouncementInfo_set_addresses(LDKNodeAnnouncementInfo *this_ptr, LDKCVec_NetAddressZ val); - public static native void NodeAnnouncementInfo_set_addresses(long this_ptr, long val); + public static native void NodeAnnouncementInfo_set_addresses(long this_ptr, long[] val); // LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeAnnouncementInfo *this_ptr); public static native long NodeAnnouncementInfo_get_announcement_message(long this_ptr); // void NodeAnnouncementInfo_set_announcement_message(LDKNodeAnnouncementInfo *this_ptr, LDKNodeAnnouncement val); public static native void NodeAnnouncementInfo_set_announcement_message(long this_ptr, long val); // MUST_USE_RES LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(LDKNodeFeatures features_arg, uint32_t last_update_arg, LDKThreeBytes rgb_arg, LDKThirtyTwoBytes alias_arg, LDKCVec_NetAddressZ addresses_arg, LDKNodeAnnouncement announcement_message_arg); - public static native long NodeAnnouncementInfo_new(long features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, long addresses_arg, long announcement_message_arg); + public static native long NodeAnnouncementInfo_new(long features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, long[] addresses_arg, long announcement_message_arg); // LDKCVec_u8Z NodeAnnouncementInfo_write(const LDKNodeAnnouncementInfo *obj); public static native byte[] NodeAnnouncementInfo_write(long obj); // LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(LDKu8slice ser); @@ -2370,7 +2384,7 @@ public class bindings { // void NodeInfo_free(LDKNodeInfo this_ptr); public static native void NodeInfo_free(long this_ptr); // void NodeInfo_set_channels(LDKNodeInfo *this_ptr, LDKCVec_u64Z val); - public static native void NodeInfo_set_channels(long this_ptr, long val); + public static native void NodeInfo_set_channels(long this_ptr, long[] val); // LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const LDKNodeInfo *this_ptr); public static native long NodeInfo_get_lowest_inbound_channel_fees(long this_ptr); // void NodeInfo_set_lowest_inbound_channel_fees(LDKNodeInfo *this_ptr, LDKRoutingFees val); @@ -2380,7 +2394,7 @@ public class bindings { // void NodeInfo_set_announcement_info(LDKNodeInfo *this_ptr, LDKNodeAnnouncementInfo val); public static native void NodeInfo_set_announcement_info(long this_ptr, long val); // MUST_USE_RES LDKNodeInfo NodeInfo_new(LDKCVec_u64Z channels_arg, LDKRoutingFees lowest_inbound_channel_fees_arg, LDKNodeAnnouncementInfo announcement_info_arg); - public static native long NodeInfo_new(long channels_arg, long lowest_inbound_channel_fees_arg, long announcement_info_arg); + public static native long NodeInfo_new(long[] channels_arg, long lowest_inbound_channel_fees_arg, long announcement_info_arg); // LDKCVec_u8Z NodeInfo_write(const LDKNodeInfo *obj); public static native byte[] NodeInfo_write(long obj); // LDKNodeInfo NodeInfo_read(LDKu8slice ser); diff --git a/src/main/java/org/ldk/structs/APIError.java b/src/main/java/org/ldk/structs/APIError.java new file mode 100644 index 00000000..61a7a4a5 --- /dev/null +++ b/src/main/java/org/ldk/structs/APIError.java @@ -0,0 +1,57 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class APIError extends CommonBase { + private APIError(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static APIError constr_from_ptr(long ptr) { + bindings.LDKAPIError raw_val = bindings.LDKAPIError_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKAPIError.APIMisuseError.class) { + return new APIMisuseError(null, ptr); + } + if (raw_val.getClass() == bindings.LDKAPIError.FeeRateTooHigh.class) { + return new FeeRateTooHigh(null, ptr); + } + if (raw_val.getClass() == bindings.LDKAPIError.RouteError.class) { + return new RouteError(null, ptr); + } + if (raw_val.getClass() == bindings.LDKAPIError.ChannelUnavailable.class) { + return new ChannelUnavailable(null, ptr); + } + if (raw_val.getClass() == bindings.LDKAPIError.MonitorUpdateFailed.class) { + return new MonitorUpdateFailed(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class APIMisuseError extends APIError { + public byte[] err; + private APIMisuseError(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class FeeRateTooHigh extends APIError { + public byte[] err; + public int feerate; + private FeeRateTooHigh(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class RouteError extends APIError { + public String err; + private RouteError(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class ChannelUnavailable extends APIError { + public byte[] err; + private ChannelUnavailable(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class MonitorUpdateFailed extends APIError { + private MonitorUpdateFailed(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/AcceptChannel.java b/src/main/java/org/ldk/structs/AcceptChannel.java index 5397d48e..e53d364d 100644 --- a/src/main/java/org/ldk/structs/AcceptChannel.java +++ b/src/main/java/org/ldk/structs/AcceptChannel.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class AcceptChannel extends CommonBase { AcceptChannel(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,163 +14,137 @@ public class AcceptChannel extends CommonBase { bindings.AcceptChannel_free(ptr); } - public AcceptChannel(AcceptChannel orig) { - super(bindings.AcceptChannel_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static AcceptChannel constructor_clone(AcceptChannel orig) { + long ret = bindings.AcceptChannel_clone(orig == null ? 0 : orig.ptr & ~1); + AcceptChannel ret_hu_conv = new AcceptChannel(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_temporary_channel_id(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_temporary_channel_id() { + byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr); return ret; } - public void set_temporary_channel_id(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_temporary_channel_id(byte[] val) { + bindings.AcceptChannel_set_temporary_channel_id(this.ptr, val); } - public long get_dust_limit_satoshis(AcceptChannel this_ptr) { - long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_dust_limit_satoshis() { + long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr); return ret; } - public void set_dust_limit_satoshis(AcceptChannel this_ptr, long val) { - bindings.AcceptChannel_set_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_dust_limit_satoshis(long val) { + bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val); } - public long get_max_htlc_value_in_flight_msat(AcceptChannel this_ptr) { - long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_max_htlc_value_in_flight_msat() { + long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr); return ret; } - public void set_max_htlc_value_in_flight_msat(AcceptChannel this_ptr, long val) { - bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_htlc_value_in_flight_msat(long val) { + bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val); } - public long get_channel_reserve_satoshis(AcceptChannel this_ptr) { - long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_channel_reserve_satoshis() { + long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr); return ret; } - public void set_channel_reserve_satoshis(AcceptChannel this_ptr, long val) { - bindings.AcceptChannel_set_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_reserve_satoshis(long val) { + bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val); } - public long get_htlc_minimum_msat(AcceptChannel this_ptr) { - long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_minimum_msat() { + long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(AcceptChannel this_ptr, long val) { - bindings.AcceptChannel_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_minimum_msat(long val) { + bindings.AcceptChannel_set_htlc_minimum_msat(this.ptr, val); } - public int get_minimum_depth(AcceptChannel this_ptr) { - int ret = bindings.AcceptChannel_get_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_minimum_depth() { + int ret = bindings.AcceptChannel_get_minimum_depth(this.ptr); return ret; } - public void set_minimum_depth(AcceptChannel this_ptr, int val) { - bindings.AcceptChannel_set_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_minimum_depth(int val) { + bindings.AcceptChannel_set_minimum_depth(this.ptr, val); } - public short get_to_self_delay(AcceptChannel this_ptr) { - short ret = bindings.AcceptChannel_get_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_to_self_delay() { + short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr); return ret; } - public void set_to_self_delay(AcceptChannel this_ptr, short val) { - bindings.AcceptChannel_set_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_to_self_delay(short val) { + bindings.AcceptChannel_set_to_self_delay(this.ptr, val); } - public short get_max_accepted_htlcs(AcceptChannel this_ptr) { - short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_max_accepted_htlcs() { + short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr); return ret; } - public void set_max_accepted_htlcs(AcceptChannel this_ptr, short val) { - bindings.AcceptChannel_set_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_accepted_htlcs(short val) { + bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val); } - public byte[] get_funding_pubkey(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_funding_pubkey() { + byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr); return ret; } - public void set_funding_pubkey(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_pubkey(byte[] val) { + bindings.AcceptChannel_set_funding_pubkey(this.ptr, val); } - public byte[] get_revocation_basepoint(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_revocation_basepoint() { + byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr); return ret; } - public void set_revocation_basepoint(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_revocation_basepoint(byte[] val) { + bindings.AcceptChannel_set_revocation_basepoint(this.ptr, val); } - public byte[] get_payment_point(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_point() { + byte[] ret = bindings.AcceptChannel_get_payment_point(this.ptr); return ret; } - public void set_payment_point(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_point(byte[] val) { + bindings.AcceptChannel_set_payment_point(this.ptr, val); } - public byte[] get_delayed_payment_basepoint(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_delayed_payment_basepoint() { + byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr); return ret; } - public void set_delayed_payment_basepoint(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_delayed_payment_basepoint(byte[] val) { + bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, val); } - public byte[] get_htlc_basepoint(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_htlc_basepoint() { + byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr); return ret; } - public void set_htlc_basepoint(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_basepoint(byte[] val) { + bindings.AcceptChannel_set_htlc_basepoint(this.ptr, val); } - public byte[] get_first_per_commitment_point(AcceptChannel this_ptr) { - byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_first_per_commitment_point() { + byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr); return ret; } - public void set_first_per_commitment_point(AcceptChannel this_ptr, byte[] val) { - bindings.AcceptChannel_set_first_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_first_per_commitment_point(byte[] val) { + bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, val); } public byte[] write(AcceptChannel obj) { @@ -176,8 +153,10 @@ public class AcceptChannel extends CommonBase { return ret; } - public AcceptChannel(byte[] ser) { - super(bindings.AcceptChannel_read(ser)); + public static AcceptChannel constructor_read(byte[] ser) { + long ret = bindings.AcceptChannel_read(ser); + AcceptChannel ret_hu_conv = new AcceptChannel(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Access.java b/src/main/java/org/ldk/structs/Access.java index 36fc3626..febbd35e 100644 --- a/src/main/java/org/ldk/structs/Access.java +++ b/src/main/java/org/ldk/structs/Access.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Access extends CommonBase { Access(Object _dummy, long ptr) { super(ptr); } public Access(bindings.LDKAccess arg) { diff --git a/src/main/java/org/ldk/structs/AnnouncementSignatures.java b/src/main/java/org/ldk/structs/AnnouncementSignatures.java index 80845344..f28ff8ad 100644 --- a/src/main/java/org/ldk/structs/AnnouncementSignatures.java +++ b/src/main/java/org/ldk/structs/AnnouncementSignatures.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class AnnouncementSignatures extends CommonBase { AnnouncementSignatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,57 +14,53 @@ public class AnnouncementSignatures extends CommonBase { bindings.AnnouncementSignatures_free(ptr); } - public AnnouncementSignatures(AnnouncementSignatures orig) { - super(bindings.AnnouncementSignatures_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static AnnouncementSignatures constructor_clone(AnnouncementSignatures orig) { + long ret = bindings.AnnouncementSignatures_clone(orig == null ? 0 : orig.ptr & ~1); + AnnouncementSignatures ret_hu_conv = new AnnouncementSignatures(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(AnnouncementSignatures this_ptr) { - byte[] ret = bindings.AnnouncementSignatures_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.AnnouncementSignatures_get_channel_id(this.ptr); return ret; } - public void set_channel_id(AnnouncementSignatures this_ptr, byte[] val) { - bindings.AnnouncementSignatures_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.AnnouncementSignatures_set_channel_id(this.ptr, val); } - public long get_short_channel_id(AnnouncementSignatures this_ptr) { - long ret = bindings.AnnouncementSignatures_get_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_short_channel_id() { + long ret = bindings.AnnouncementSignatures_get_short_channel_id(this.ptr); return ret; } - public void set_short_channel_id(AnnouncementSignatures this_ptr, long val) { - bindings.AnnouncementSignatures_set_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_short_channel_id(long val) { + bindings.AnnouncementSignatures_set_short_channel_id(this.ptr, val); } - public byte[] get_node_signature(AnnouncementSignatures this_ptr) { - byte[] ret = bindings.AnnouncementSignatures_get_node_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_signature() { + byte[] ret = bindings.AnnouncementSignatures_get_node_signature(this.ptr); return ret; } - public void set_node_signature(AnnouncementSignatures this_ptr, byte[] val) { - bindings.AnnouncementSignatures_set_node_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_signature(byte[] val) { + bindings.AnnouncementSignatures_set_node_signature(this.ptr, val); } - public byte[] get_bitcoin_signature(AnnouncementSignatures this_ptr) { - byte[] ret = bindings.AnnouncementSignatures_get_bitcoin_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_bitcoin_signature() { + byte[] ret = bindings.AnnouncementSignatures_get_bitcoin_signature(this.ptr); return ret; } - public void set_bitcoin_signature(AnnouncementSignatures this_ptr, byte[] val) { - bindings.AnnouncementSignatures_set_bitcoin_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_bitcoin_signature(byte[] val) { + bindings.AnnouncementSignatures_set_bitcoin_signature(this.ptr, val); } - public AnnouncementSignatures(byte[] channel_id_arg, long short_channel_id_arg, byte[] node_signature_arg, byte[] bitcoin_signature_arg) { - super(bindings.AnnouncementSignatures_new(channel_id_arg, short_channel_id_arg, node_signature_arg, bitcoin_signature_arg)); + public static AnnouncementSignatures constructor_new(byte[] channel_id_arg, long short_channel_id_arg, byte[] node_signature_arg, byte[] bitcoin_signature_arg) { + long ret = bindings.AnnouncementSignatures_new(channel_id_arg, short_channel_id_arg, node_signature_arg, bitcoin_signature_arg); + AnnouncementSignatures ret_hu_conv = new AnnouncementSignatures(null, ret); + return ret_hu_conv; } public byte[] write(AnnouncementSignatures obj) { @@ -70,8 +69,10 @@ public class AnnouncementSignatures extends CommonBase { return ret; } - public AnnouncementSignatures(byte[] ser) { - super(bindings.AnnouncementSignatures_read(ser)); + public static AnnouncementSignatures constructor_read(byte[] ser) { + long ret = bindings.AnnouncementSignatures_read(ser); + AnnouncementSignatures ret_hu_conv = new AnnouncementSignatures(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/BroadcasterInterface.java b/src/main/java/org/ldk/structs/BroadcasterInterface.java index ca3e82a7..8ba7bf4c 100644 --- a/src/main/java/org/ldk/structs/BroadcasterInterface.java +++ b/src/main/java/org/ldk/structs/BroadcasterInterface.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class BroadcasterInterface extends CommonBase { BroadcasterInterface(Object _dummy, long ptr) { super(ptr); } public BroadcasterInterface(bindings.LDKBroadcasterInterface arg) { diff --git a/src/main/java/org/ldk/structs/ChainMonitor.java b/src/main/java/org/ldk/structs/ChainMonitor.java index 94e0f36e..90a3aa75 100644 --- a/src/main/java/org/ldk/structs/ChainMonitor.java +++ b/src/main/java/org/ldk/structs/ChainMonitor.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChainMonitor extends CommonBase { ChainMonitor(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,29 +14,37 @@ public class ChainMonitor extends CommonBase { bindings.ChainMonitor_free(ptr); } - // Skipped ChainMonitor_block_connected + public void block_connected(byte[] header, TwoTuple[] txdata, int height) { + bindings.ChainMonitor_block_connected(this.ptr, header, Arrays.stream(txdata).mapToLong(arr_conv_29 -> /*TODO b*/0).toArray(), height); + /* TODO 2 TwoTuple */; + } + public void block_disconnected(byte[] header, int disconnected_height) { bindings.ChainMonitor_block_disconnected(this.ptr, header, disconnected_height); } - public ChainMonitor(Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest) { - super(bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr)); - this.ptrs_to.add(chain_source); - this.ptrs_to.add(broadcaster); - this.ptrs_to.add(logger); - this.ptrs_to.add(feeest); + public static ChainMonitor constructor_new(Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest) { + long ret = bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr); + ChainMonitor ret_hu_conv = new ChainMonitor(null, ret); + ret_hu_conv.ptrs_to.add(chain_source); + ret_hu_conv.ptrs_to.add(broadcaster); + ret_hu_conv.ptrs_to.add(logger); + ret_hu_conv.ptrs_to.add(feeest); + return ret_hu_conv; } public Watch as_Watch() { - Watch ret = new Watch(null, bindings.ChainMonitor_as_Watch(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.ChainMonitor_as_Watch(this.ptr); + Watch ret_hu_conv = new Watch(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } public EventsProvider as_EventsProvider() { - EventsProvider ret = new EventsProvider(null, bindings.ChainMonitor_as_EventsProvider(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.ChainMonitor_as_EventsProvider(this.ptr); + EventsProvider ret_hu_conv = new EventsProvider(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelAnnouncement.java b/src/main/java/org/ldk/structs/ChannelAnnouncement.java index 9d36fcdf..a15f3619 100644 --- a/src/main/java/org/ldk/structs/ChannelAnnouncement.java +++ b/src/main/java/org/ldk/structs/ChannelAnnouncement.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelAnnouncement extends CommonBase { ChannelAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,70 +14,65 @@ public class ChannelAnnouncement extends CommonBase { bindings.ChannelAnnouncement_free(ptr); } - public ChannelAnnouncement(ChannelAnnouncement orig) { - super(bindings.ChannelAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelAnnouncement constructor_clone(ChannelAnnouncement orig) { + long ret = bindings.ChannelAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_node_signature_1(ChannelAnnouncement this_ptr) { - byte[] ret = bindings.ChannelAnnouncement_get_node_signature_1(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_signature_1() { + byte[] ret = bindings.ChannelAnnouncement_get_node_signature_1(this.ptr); return ret; } - public void set_node_signature_1(ChannelAnnouncement this_ptr, byte[] val) { - bindings.ChannelAnnouncement_set_node_signature_1(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_signature_1(byte[] val) { + bindings.ChannelAnnouncement_set_node_signature_1(this.ptr, val); } - public byte[] get_node_signature_2(ChannelAnnouncement this_ptr) { - byte[] ret = bindings.ChannelAnnouncement_get_node_signature_2(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_signature_2() { + byte[] ret = bindings.ChannelAnnouncement_get_node_signature_2(this.ptr); return ret; } - public void set_node_signature_2(ChannelAnnouncement this_ptr, byte[] val) { - bindings.ChannelAnnouncement_set_node_signature_2(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_signature_2(byte[] val) { + bindings.ChannelAnnouncement_set_node_signature_2(this.ptr, val); } - public byte[] get_bitcoin_signature_1(ChannelAnnouncement this_ptr) { - byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_1(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_bitcoin_signature_1() { + byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_1(this.ptr); return ret; } - public void set_bitcoin_signature_1(ChannelAnnouncement this_ptr, byte[] val) { - bindings.ChannelAnnouncement_set_bitcoin_signature_1(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_bitcoin_signature_1(byte[] val) { + bindings.ChannelAnnouncement_set_bitcoin_signature_1(this.ptr, val); } - public byte[] get_bitcoin_signature_2(ChannelAnnouncement this_ptr) { - byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_2(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_bitcoin_signature_2() { + byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_2(this.ptr); return ret; } - public void set_bitcoin_signature_2(ChannelAnnouncement this_ptr, byte[] val) { - bindings.ChannelAnnouncement_set_bitcoin_signature_2(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_bitcoin_signature_2(byte[] val) { + bindings.ChannelAnnouncement_set_bitcoin_signature_2(this.ptr, val); } - public UnsignedChannelAnnouncement get_contents(ChannelAnnouncement this_ptr) { - UnsignedChannelAnnouncement ret = new UnsignedChannelAnnouncement(null, bindings.ChannelAnnouncement_get_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public UnsignedChannelAnnouncement get_contents() { + long ret = bindings.ChannelAnnouncement_get_contents(this.ptr); + UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); + return ret_hu_conv; } - public void set_contents(ChannelAnnouncement this_ptr, UnsignedChannelAnnouncement val) { - bindings.ChannelAnnouncement_set_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_contents(UnsignedChannelAnnouncement val) { + bindings.ChannelAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public ChannelAnnouncement(byte[] node_signature_1_arg, byte[] node_signature_2_arg, byte[] bitcoin_signature_1_arg, byte[] bitcoin_signature_2_arg, UnsignedChannelAnnouncement contents_arg) { - super(bindings.ChannelAnnouncement_new(node_signature_1_arg, node_signature_2_arg, bitcoin_signature_1_arg, bitcoin_signature_2_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1)); - this.ptrs_to.add(contents_arg); + public static ChannelAnnouncement constructor_new(byte[] node_signature_1_arg, byte[] node_signature_2_arg, byte[] bitcoin_signature_1_arg, byte[] bitcoin_signature_2_arg, UnsignedChannelAnnouncement contents_arg) { + long ret = bindings.ChannelAnnouncement_new(node_signature_1_arg, node_signature_2_arg, bitcoin_signature_1_arg, bitcoin_signature_2_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1); + ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(contents_arg); + return ret_hu_conv; } public byte[] write(ChannelAnnouncement obj) { @@ -83,8 +81,10 @@ public class ChannelAnnouncement extends CommonBase { return ret; } - public ChannelAnnouncement(byte[] ser) { - super(bindings.ChannelAnnouncement_read(ser)); + public static ChannelAnnouncement constructor_read(byte[] ser) { + long ret = bindings.ChannelAnnouncement_read(ser); + ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelConfig.java b/src/main/java/org/ldk/structs/ChannelConfig.java index e91b4c2a..6ac3d712 100644 --- a/src/main/java/org/ldk/structs/ChannelConfig.java +++ b/src/main/java/org/ldk/structs/ChannelConfig.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelConfig extends CommonBase { ChannelConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,50 +14,50 @@ public class ChannelConfig extends CommonBase { bindings.ChannelConfig_free(ptr); } - public ChannelConfig(ChannelConfig orig) { - super(bindings.ChannelConfig_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelConfig constructor_clone(ChannelConfig orig) { + long ret = bindings.ChannelConfig_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public int get_fee_proportional_millionths(ChannelConfig this_ptr) { - int ret = bindings.ChannelConfig_get_fee_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_fee_proportional_millionths() { + int ret = bindings.ChannelConfig_get_fee_proportional_millionths(this.ptr); return ret; } - public void set_fee_proportional_millionths(ChannelConfig this_ptr, int val) { - bindings.ChannelConfig_set_fee_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_fee_proportional_millionths(int val) { + bindings.ChannelConfig_set_fee_proportional_millionths(this.ptr, val); } - public boolean get_announced_channel(ChannelConfig this_ptr) { - boolean ret = bindings.ChannelConfig_get_announced_channel(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_announced_channel() { + boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr); return ret; } - public void set_announced_channel(ChannelConfig this_ptr, boolean val) { - bindings.ChannelConfig_set_announced_channel(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_announced_channel(boolean val) { + bindings.ChannelConfig_set_announced_channel(this.ptr, val); } - public boolean get_commit_upfront_shutdown_pubkey(ChannelConfig this_ptr) { - boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_commit_upfront_shutdown_pubkey() { + boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr); return ret; } - public void set_commit_upfront_shutdown_pubkey(ChannelConfig this_ptr, boolean val) { - bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_commit_upfront_shutdown_pubkey(boolean val) { + bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val); } - public ChannelConfig(int fee_proportional_millionths_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { - super(bindings.ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg)); + public static ChannelConfig constructor_new(int fee_proportional_millionths_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { + long ret = bindings.ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); + ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); + return ret_hu_conv; } - public ChannelConfig() { - super(bindings.ChannelConfig_default()); + public static ChannelConfig constructor_default() { + long ret = bindings.ChannelConfig_default(); + ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); + return ret_hu_conv; } public byte[] write(ChannelConfig obj) { @@ -63,8 +66,10 @@ public class ChannelConfig extends CommonBase { return ret; } - public ChannelConfig(byte[] ser) { - super(bindings.ChannelConfig_read(ser)); + public static ChannelConfig constructor_read(byte[] ser) { + long ret = bindings.ChannelConfig_read(ser); + ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelDetails.java b/src/main/java/org/ldk/structs/ChannelDetails.java index 677ec972..6e4f5bb8 100644 --- a/src/main/java/org/ldk/structs/ChannelDetails.java +++ b/src/main/java/org/ldk/structs/ChannelDetails.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelDetails extends CommonBase { ChannelDetails(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,93 +14,81 @@ public class ChannelDetails extends CommonBase { bindings.ChannelDetails_free(ptr); } - public ChannelDetails(ChannelDetails orig) { - super(bindings.ChannelDetails_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelDetails constructor_clone(ChannelDetails orig) { + long ret = bindings.ChannelDetails_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelDetails ret_hu_conv = new ChannelDetails(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(ChannelDetails this_ptr) { - byte[] ret = bindings.ChannelDetails_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.ChannelDetails_get_channel_id(this.ptr); return ret; } - public void set_channel_id(ChannelDetails this_ptr, byte[] val) { - bindings.ChannelDetails_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.ChannelDetails_set_channel_id(this.ptr, val); } - public byte[] get_remote_network_id(ChannelDetails this_ptr) { - byte[] ret = bindings.ChannelDetails_get_remote_network_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_remote_network_id() { + byte[] ret = bindings.ChannelDetails_get_remote_network_id(this.ptr); return ret; } - public void set_remote_network_id(ChannelDetails this_ptr, byte[] val) { - bindings.ChannelDetails_set_remote_network_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_remote_network_id(byte[] val) { + bindings.ChannelDetails_set_remote_network_id(this.ptr, val); } - public InitFeatures get_counterparty_features(ChannelDetails this_ptr) { - InitFeatures ret = new InitFeatures(null, bindings.ChannelDetails_get_counterparty_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public InitFeatures get_counterparty_features() { + long ret = bindings.ChannelDetails_get_counterparty_features(this.ptr); + InitFeatures ret_hu_conv = new InitFeatures(null, ret); + return ret_hu_conv; } // Skipped ChannelDetails_set_counterparty_features - public long get_channel_value_satoshis(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_channel_value_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_channel_value_satoshis() { + long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); return ret; } - public void set_channel_value_satoshis(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_channel_value_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_value_satoshis(long val) { + bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); } - public long get_user_id(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_user_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_user_id() { + long ret = bindings.ChannelDetails_get_user_id(this.ptr); return ret; } - public void set_user_id(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_user_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_user_id(long val) { + bindings.ChannelDetails_set_user_id(this.ptr, val); } - public long get_outbound_capacity_msat(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_outbound_capacity_msat() { + long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr); return ret; } - public void set_outbound_capacity_msat(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_outbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_outbound_capacity_msat(long val) { + bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val); } - public long get_inbound_capacity_msat(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_inbound_capacity_msat() { + long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr); return ret; } - public void set_inbound_capacity_msat(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_inbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_inbound_capacity_msat(long val) { + bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val); } - public boolean get_is_live(ChannelDetails this_ptr) { - boolean ret = bindings.ChannelDetails_get_is_live(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_is_live() { + boolean ret = bindings.ChannelDetails_get_is_live(this.ptr); return ret; } - public void set_is_live(ChannelDetails this_ptr, boolean val) { - bindings.ChannelDetails_set_is_live(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_is_live(boolean val) { + bindings.ChannelDetails_set_is_live(this.ptr, val); } } diff --git a/src/main/java/org/ldk/structs/ChannelFeatures.java b/src/main/java/org/ldk/structs/ChannelFeatures.java index 2a21c80d..97bba12d 100644 --- a/src/main/java/org/ldk/structs/ChannelFeatures.java +++ b/src/main/java/org/ldk/structs/ChannelFeatures.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelFeatures extends CommonBase { ChannelFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java index a543225a..33cf8e71 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelHandshakeConfig extends CommonBase { ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,50 +14,50 @@ public class ChannelHandshakeConfig extends CommonBase { bindings.ChannelHandshakeConfig_free(ptr); } - public ChannelHandshakeConfig(ChannelHandshakeConfig orig) { - super(bindings.ChannelHandshakeConfig_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelHandshakeConfig constructor_clone(ChannelHandshakeConfig orig) { + long ret = bindings.ChannelHandshakeConfig_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public int get_minimum_depth(ChannelHandshakeConfig this_ptr) { - int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_minimum_depth() { + int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr); return ret; } - public void set_minimum_depth(ChannelHandshakeConfig this_ptr, int val) { - bindings.ChannelHandshakeConfig_set_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_minimum_depth(int val) { + bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val); } - public short get_our_to_self_delay(ChannelHandshakeConfig this_ptr) { - short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_our_to_self_delay() { + short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr); return ret; } - public void set_our_to_self_delay(ChannelHandshakeConfig this_ptr, short val) { - bindings.ChannelHandshakeConfig_set_our_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_our_to_self_delay(short val) { + bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val); } - public long get_our_htlc_minimum_msat(ChannelHandshakeConfig this_ptr) { - long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_our_htlc_minimum_msat() { + long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr); return ret; } - public void set_our_htlc_minimum_msat(ChannelHandshakeConfig this_ptr, long val) { - bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_our_htlc_minimum_msat(long val) { + bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val); } - public ChannelHandshakeConfig(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg) { - super(bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg)); + public static ChannelHandshakeConfig constructor_new(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg) { + long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg); + ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret); + return ret_hu_conv; } - public ChannelHandshakeConfig() { - super(bindings.ChannelHandshakeConfig_default()); + public static ChannelHandshakeConfig constructor_default() { + long ret = bindings.ChannelHandshakeConfig_default(); + ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java index 1df3f8cb..bc99da64 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelHandshakeLimits extends CommonBase { ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,127 +14,113 @@ public class ChannelHandshakeLimits extends CommonBase { bindings.ChannelHandshakeLimits_free(ptr); } - public ChannelHandshakeLimits(ChannelHandshakeLimits orig) { - super(bindings.ChannelHandshakeLimits_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelHandshakeLimits constructor_clone(ChannelHandshakeLimits orig) { + long ret = bindings.ChannelHandshakeLimits_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public long get_min_funding_satoshis(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_min_funding_satoshis() { + long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr); return ret; } - public void set_min_funding_satoshis(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_min_funding_satoshis(long val) { + bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val); } - public long get_max_htlc_minimum_msat(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_max_htlc_minimum_msat() { + long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr); return ret; } - public void set_max_htlc_minimum_msat(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_htlc_minimum_msat(long val) { + bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val); } - public long get_min_max_htlc_value_in_flight_msat(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_min_max_htlc_value_in_flight_msat() { + long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr); return ret; } - public void set_min_max_htlc_value_in_flight_msat(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_min_max_htlc_value_in_flight_msat(long val) { + bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val); } - public long get_max_channel_reserve_satoshis(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_max_channel_reserve_satoshis() { + long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr); return ret; } - public void set_max_channel_reserve_satoshis(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_channel_reserve_satoshis(long val) { + bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val); } - public short get_min_max_accepted_htlcs(ChannelHandshakeLimits this_ptr) { - short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_min_max_accepted_htlcs() { + short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr); return ret; } - public void set_min_max_accepted_htlcs(ChannelHandshakeLimits this_ptr, short val) { - bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_min_max_accepted_htlcs(short val) { + bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val); } - public long get_min_dust_limit_satoshis(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_min_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_min_dust_limit_satoshis() { + long ret = bindings.ChannelHandshakeLimits_get_min_dust_limit_satoshis(this.ptr); return ret; } - public void set_min_dust_limit_satoshis(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_min_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_min_dust_limit_satoshis(long val) { + bindings.ChannelHandshakeLimits_set_min_dust_limit_satoshis(this.ptr, val); } - public long get_max_dust_limit_satoshis(ChannelHandshakeLimits this_ptr) { - long ret = bindings.ChannelHandshakeLimits_get_max_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_max_dust_limit_satoshis() { + long ret = bindings.ChannelHandshakeLimits_get_max_dust_limit_satoshis(this.ptr); return ret; } - public void set_max_dust_limit_satoshis(ChannelHandshakeLimits this_ptr, long val) { - bindings.ChannelHandshakeLimits_set_max_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_dust_limit_satoshis(long val) { + bindings.ChannelHandshakeLimits_set_max_dust_limit_satoshis(this.ptr, val); } - public int get_max_minimum_depth(ChannelHandshakeLimits this_ptr) { - int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_max_minimum_depth() { + int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr); return ret; } - public void set_max_minimum_depth(ChannelHandshakeLimits this_ptr, int val) { - bindings.ChannelHandshakeLimits_set_max_minimum_depth(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_minimum_depth(int val) { + bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val); } - public boolean get_force_announced_channel_preference(ChannelHandshakeLimits this_ptr) { - boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_force_announced_channel_preference() { + boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr); return ret; } - public void set_force_announced_channel_preference(ChannelHandshakeLimits this_ptr, boolean val) { - bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_force_announced_channel_preference(boolean val) { + bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val); } - public short get_their_to_self_delay(ChannelHandshakeLimits this_ptr) { - short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_their_to_self_delay() { + short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr); return ret; } - public void set_their_to_self_delay(ChannelHandshakeLimits this_ptr, short val) { - bindings.ChannelHandshakeLimits_set_their_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_their_to_self_delay(short val) { + bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val); } - public ChannelHandshakeLimits(long min_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, long min_dust_limit_satoshis_arg, long max_dust_limit_satoshis_arg, int max_minimum_depth_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) { - super(bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg)); + public static ChannelHandshakeLimits constructor_new(long min_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, long min_dust_limit_satoshis_arg, long max_dust_limit_satoshis_arg, int max_minimum_depth_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) { + long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg); + ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); + return ret_hu_conv; } - public ChannelHandshakeLimits() { - super(bindings.ChannelHandshakeLimits_default()); + public static ChannelHandshakeLimits constructor_default() { + long ret = bindings.ChannelHandshakeLimits_default(); + ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelInfo.java b/src/main/java/org/ldk/structs/ChannelInfo.java index 9cdbd75f..412f646e 100644 --- a/src/main/java/org/ldk/structs/ChannelInfo.java +++ b/src/main/java/org/ldk/structs/ChannelInfo.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelInfo extends CommonBase { ChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,58 +14,53 @@ public class ChannelInfo extends CommonBase { bindings.ChannelInfo_free(ptr); } - public ChannelFeatures get_features(ChannelInfo this_ptr) { - ChannelFeatures ret = new ChannelFeatures(null, bindings.ChannelInfo_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelFeatures get_features() { + long ret = bindings.ChannelInfo_get_features(this.ptr); + ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret); + return ret_hu_conv; } // Skipped ChannelInfo_set_features - public byte[] get_node_one(ChannelInfo this_ptr) { - byte[] ret = bindings.ChannelInfo_get_node_one(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_one() { + byte[] ret = bindings.ChannelInfo_get_node_one(this.ptr); return ret; } - public void set_node_one(ChannelInfo this_ptr, byte[] val) { - bindings.ChannelInfo_set_node_one(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_one(byte[] val) { + bindings.ChannelInfo_set_node_one(this.ptr, val); } - public DirectionalChannelInfo get_one_to_two(ChannelInfo this_ptr) { - DirectionalChannelInfo ret = new DirectionalChannelInfo(null, bindings.ChannelInfo_get_one_to_two(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public DirectionalChannelInfo get_one_to_two() { + long ret = bindings.ChannelInfo_get_one_to_two(this.ptr); + DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); + return ret_hu_conv; } // Skipped ChannelInfo_set_one_to_two - public byte[] get_node_two(ChannelInfo this_ptr) { - byte[] ret = bindings.ChannelInfo_get_node_two(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_two() { + byte[] ret = bindings.ChannelInfo_get_node_two(this.ptr); return ret; } - public void set_node_two(ChannelInfo this_ptr, byte[] val) { - bindings.ChannelInfo_set_node_two(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_two(byte[] val) { + bindings.ChannelInfo_set_node_two(this.ptr, val); } - public DirectionalChannelInfo get_two_to_one(ChannelInfo this_ptr) { - DirectionalChannelInfo ret = new DirectionalChannelInfo(null, bindings.ChannelInfo_get_two_to_one(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public DirectionalChannelInfo get_two_to_one() { + long ret = bindings.ChannelInfo_get_two_to_one(this.ptr); + DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); + return ret_hu_conv; } // Skipped ChannelInfo_set_two_to_one - public ChannelAnnouncement get_announcement_message(ChannelInfo this_ptr) { - ChannelAnnouncement ret = new ChannelAnnouncement(null, bindings.ChannelInfo_get_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelAnnouncement get_announcement_message() { + long ret = bindings.ChannelInfo_get_announcement_message(this.ptr); + ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); + return ret_hu_conv; } - public void set_announcement_message(ChannelInfo this_ptr, ChannelAnnouncement val) { - bindings.ChannelInfo_set_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_announcement_message(ChannelAnnouncement val) { + bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } @@ -72,8 +70,10 @@ public class ChannelInfo extends CommonBase { return ret; } - public ChannelInfo(byte[] ser) { - super(bindings.ChannelInfo_read(ser)); + public static ChannelInfo constructor_read(byte[] ser) { + long ret = bindings.ChannelInfo_read(ser); + ChannelInfo ret_hu_conv = new ChannelInfo(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelKeys.java b/src/main/java/org/ldk/structs/ChannelKeys.java index 3034bfd9..5b952032 100644 --- a/src/main/java/org/ldk/structs/ChannelKeys.java +++ b/src/main/java/org/ldk/structs/ChannelKeys.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelKeys extends CommonBase { ChannelKeys(Object _dummy, long ptr) { super(ptr); } public ChannelKeys(bindings.LDKChannelKeys arg) { diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index ec82ff9e..beadcad7 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelManager extends CommonBase { ChannelManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,19 +14,41 @@ public class ChannelManager extends CommonBase { bindings.ChannelManager_free(ptr); } - public ChannelManager(LDKNetwork network, FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, long current_blockchain_height) { - super(bindings.ChannelManager_new(network, fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr & ~1, current_blockchain_height)); - this.ptrs_to.add(fee_est); - this.ptrs_to.add(chain_monitor); - this.ptrs_to.add(tx_broadcaster); - this.ptrs_to.add(logger); - this.ptrs_to.add(keys_manager); - this.ptrs_to.add(config); + public static ChannelManager constructor_new(LDKNetwork network, FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, long current_blockchain_height) { + long ret = bindings.ChannelManager_new(network, fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr & ~1, current_blockchain_height); + ChannelManager ret_hu_conv = new ChannelManager(null, ret); + ret_hu_conv.ptrs_to.add(fee_est); + ret_hu_conv.ptrs_to.add(chain_monitor); + ret_hu_conv.ptrs_to.add(tx_broadcaster); + ret_hu_conv.ptrs_to.add(logger); + ret_hu_conv.ptrs_to.add(keys_manager); + ret_hu_conv.ptrs_to.add(config); + return ret_hu_conv; } // Skipped ChannelManager_create_channel - // Skipped ChannelManager_list_channels - // Skipped ChannelManager_list_usable_channels + public ChannelDetails[] list_channels() { + long[] ret = bindings.ChannelManager_list_channels(this.ptr); + ChannelDetails[] arr_conv_16_arr = new ChannelDetails[ret.length]; + for (int q = 0; q < ret.length; q++) { + long arr_conv_16 = ret[q]; + ChannelDetails arr_conv_16_hu_conv = new ChannelDetails(null, arr_conv_16); + arr_conv_16_arr[q] = arr_conv_16_hu_conv; + } + return arr_conv_16_arr; + } + + public ChannelDetails[] list_usable_channels() { + long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr); + ChannelDetails[] arr_conv_16_arr = new ChannelDetails[ret.length]; + for (int q = 0; q < ret.length; q++) { + long arr_conv_16 = ret[q]; + ChannelDetails arr_conv_16_hu_conv = new ChannelDetails(null, arr_conv_16); + arr_conv_16_arr[q] = arr_conv_16_hu_conv; + } + return arr_conv_16_arr; + } + // Skipped ChannelManager_close_channel public void force_close_channel(byte[] channel_id) { bindings.ChannelManager_force_close_channel(this.ptr, channel_id); @@ -39,7 +64,11 @@ public class ChannelManager extends CommonBase { this.ptrs_to.add(funding_txo); } - // Skipped ChannelManager_broadcast_node_announcement + public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) { + bindings.ChannelManager_broadcast_node_announcement(this.ptr, rgb, alias, Arrays.stream(addresses).mapToLong(arr_conv_12 -> arr_conv_12.conv_to_c()).toArray()); + /* TODO 2 NetAddress */; + } + public void process_pending_htlc_forwards() { bindings.ChannelManager_process_pending_htlc_forwards(this.ptr); } @@ -69,26 +98,33 @@ public class ChannelManager extends CommonBase { } public MessageSendEventsProvider as_MessageSendEventsProvider() { - MessageSendEventsProvider ret = new MessageSendEventsProvider(null, bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr); + MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } public EventsProvider as_EventsProvider() { - EventsProvider ret = new EventsProvider(null, bindings.ChannelManager_as_EventsProvider(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.ChannelManager_as_EventsProvider(this.ptr); + EventsProvider ret_hu_conv = new EventsProvider(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void block_connected(byte[] header, TwoTuple[] txdata, int height) { + bindings.ChannelManager_block_connected(this.ptr, header, Arrays.stream(txdata).mapToLong(arr_conv_29 -> /*TODO b*/0).toArray(), height); + /* TODO 2 TwoTuple */; } - // Skipped ChannelManager_block_connected public void block_disconnected(byte[] header) { bindings.ChannelManager_block_disconnected(this.ptr, header); } public ChannelMessageHandler as_ChannelMessageHandler() { - ChannelMessageHandler ret = new ChannelMessageHandler(null, bindings.ChannelManager_as_ChannelMessageHandler(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr); + ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java index a7a90e6f..26dc48ae 100644 --- a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java +++ b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelManagerReadArgs extends CommonBase { ChannelManagerReadArgs(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,80 +14,74 @@ public class ChannelManagerReadArgs extends CommonBase { bindings.ChannelManagerReadArgs_free(ptr); } - public KeysInterface get_keys_manager(ChannelManagerReadArgs this_ptr) { - KeysInterface ret = new KeysInterface(null, bindings.ChannelManagerReadArgs_get_keys_manager(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public KeysInterface get_keys_manager() { + long ret = bindings.ChannelManagerReadArgs_get_keys_manager(this.ptr); + KeysInterface ret_hu_conv = new KeysInterface(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_keys_manager(ChannelManagerReadArgs this_ptr, KeysInterface val) { - bindings.ChannelManagerReadArgs_set_keys_manager(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_keys_manager(KeysInterface val) { + bindings.ChannelManagerReadArgs_set_keys_manager(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public FeeEstimator get_fee_estimator(ChannelManagerReadArgs this_ptr) { - FeeEstimator ret = new FeeEstimator(null, bindings.ChannelManagerReadArgs_get_fee_estimator(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public FeeEstimator get_fee_estimator() { + long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr); + FeeEstimator ret_hu_conv = new FeeEstimator(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_fee_estimator(ChannelManagerReadArgs this_ptr, FeeEstimator val) { - bindings.ChannelManagerReadArgs_set_fee_estimator(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_fee_estimator(FeeEstimator val) { + bindings.ChannelManagerReadArgs_set_fee_estimator(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public Watch get_chain_monitor(ChannelManagerReadArgs this_ptr) { - Watch ret = new Watch(null, bindings.ChannelManagerReadArgs_get_chain_monitor(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public Watch get_chain_monitor() { + long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr); + Watch ret_hu_conv = new Watch(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_chain_monitor(ChannelManagerReadArgs this_ptr, Watch val) { - bindings.ChannelManagerReadArgs_set_chain_monitor(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_chain_monitor(Watch val) { + bindings.ChannelManagerReadArgs_set_chain_monitor(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public BroadcasterInterface get_tx_broadcaster(ChannelManagerReadArgs this_ptr) { - BroadcasterInterface ret = new BroadcasterInterface(null, bindings.ChannelManagerReadArgs_get_tx_broadcaster(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public BroadcasterInterface get_tx_broadcaster() { + long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr); + BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_tx_broadcaster(ChannelManagerReadArgs this_ptr, BroadcasterInterface val) { - bindings.ChannelManagerReadArgs_set_tx_broadcaster(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_tx_broadcaster(BroadcasterInterface val) { + bindings.ChannelManagerReadArgs_set_tx_broadcaster(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public Logger get_logger(ChannelManagerReadArgs this_ptr) { - Logger ret = new Logger(null, bindings.ChannelManagerReadArgs_get_logger(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public Logger get_logger() { + long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr); + Logger ret_hu_conv = new Logger(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_logger(ChannelManagerReadArgs this_ptr, Logger val) { - bindings.ChannelManagerReadArgs_set_logger(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_logger(Logger val) { + bindings.ChannelManagerReadArgs_set_logger(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public UserConfig get_default_config(ChannelManagerReadArgs this_ptr) { - UserConfig ret = new UserConfig(null, bindings.ChannelManagerReadArgs_get_default_config(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public UserConfig get_default_config() { + long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr); + UserConfig ret_hu_conv = new UserConfig(null, ret); + return ret_hu_conv; } - public void set_default_config(ChannelManagerReadArgs this_ptr, UserConfig val) { - bindings.ChannelManagerReadArgs_set_default_config(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_default_config(UserConfig val) { + bindings.ChannelManagerReadArgs_set_default_config(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } diff --git a/src/main/java/org/ldk/structs/ChannelMessageHandler.java b/src/main/java/org/ldk/structs/ChannelMessageHandler.java index b2c0a122..4ad07c9a 100644 --- a/src/main/java/org/ldk/structs/ChannelMessageHandler.java +++ b/src/main/java/org/ldk/structs/ChannelMessageHandler.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelMessageHandler extends CommonBase { ChannelMessageHandler(Object _dummy, long ptr) { super(ptr); } public ChannelMessageHandler(bindings.LDKChannelMessageHandler arg, bindings.LDKMessageSendEventsProvider MessageSendEventsProvider) { diff --git a/src/main/java/org/ldk/structs/ChannelMonitor.java b/src/main/java/org/ldk/structs/ChannelMonitor.java index 6fe90d57..ce25311f 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitor.java +++ b/src/main/java/org/ldk/structs/ChannelMonitor.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelMonitor extends CommonBase { ChannelMonitor(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -18,10 +21,63 @@ public class ChannelMonitor extends CommonBase { } // Skipped ChannelMonitor_get_funding_txo - // Skipped ChannelMonitor_get_and_clear_pending_monitor_events - // Skipped ChannelMonitor_get_and_clear_pending_events - // Skipped ChannelMonitor_get_latest_holder_commitment_txn - // Skipped ChannelMonitor_block_connected + public MonitorEvent[] get_and_clear_pending_monitor_events() { + long[] ret = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(this.ptr); + MonitorEvent[] arr_conv_14_arr = new MonitorEvent[ret.length]; + for (int o = 0; o < ret.length; o++) { + long arr_conv_14 = ret[o]; + MonitorEvent arr_conv_14_hu_conv = new MonitorEvent(null, arr_conv_14); + arr_conv_14_arr[o] = arr_conv_14_hu_conv; + } + return arr_conv_14_arr; + } + + public Event[] get_and_clear_pending_events() { + long[] ret = bindings.ChannelMonitor_get_and_clear_pending_events(this.ptr); + Event[] arr_conv_7_arr = new Event[ret.length]; + for (int h = 0; h < ret.length; h++) { + long arr_conv_7 = ret[h]; + Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7); + arr_conv_7_arr[h] = arr_conv_7_hu_conv; + } + return arr_conv_7_arr; + } + + public Transaction[] get_latest_holder_commitment_txn(Logger logger) { + long[] ret = bindings.ChannelMonitor_get_latest_holder_commitment_txn(this.ptr, logger == null ? 0 : logger.ptr); + Transaction[] arr_conv_13_arr = new Transaction[ret.length]; + for (int n = 0; n < ret.length; n++) { + long arr_conv_13 = ret[n]; + Transaction arr_conv_13_conv = new Transaction(null, arr_conv_13); + arr_conv_13_arr[n] = arr_conv_13_conv; + } + this.ptrs_to.add(logger); + return arr_conv_13_arr; + } + + public TwoTuple[] block_connected(byte[] header, TwoTuple[] txdata, int height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) { + long[] ret = bindings.ChannelMonitor_block_connected(this.ptr, header, Arrays.stream(txdata).mapToLong(arr_conv_29 -> /*TODO b*/0).toArray(), height, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr); + TwoTuple[] arr_conv_27_arr = new TwoTuple[ret.length]; + for (int b = 0; b < ret.length; b++) { + long arr_conv_27 = ret[b]; + byte[] arr_conv_27_a = bindings.LDKC2Tuple_TxidCVec_TxOutZZ_get_a(arr_conv_27); + long[] arr_conv_27_b = bindings.LDKC2Tuple_TxidCVec_TxOutZZ_get_b(arr_conv_27); + TxOut[] arr_conv_7_arr = new TxOut[arr_conv_27_b.length]; + for (int h = 0; h < arr_conv_27_b.length; h++) { + long arr_conv_7 = arr_conv_27_b[h]; + TxOut arr_conv_7_conv = new TxOut(null, arr_conv_7); + arr_conv_7_arr[h] = arr_conv_7_conv; + }; + TwoTuple arr_conv_27_conv = new TwoTuple(arr_conv_27_a, arr_conv_7_arr); + arr_conv_27_arr[b] = arr_conv_27_conv; + } + /* TODO 2 TwoTuple */; + this.ptrs_to.add(broadcaster); + this.ptrs_to.add(fee_estimator); + this.ptrs_to.add(logger); + return arr_conv_27_arr; + } + public void block_disconnected(byte[] header, int height, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) { bindings.ChannelMonitor_block_disconnected(this.ptr, header, height, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr); this.ptrs_to.add(broadcaster); diff --git a/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java b/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java index 16789254..9cc36c1a 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java +++ b/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelMonitorUpdate extends CommonBase { ChannelMonitorUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,20 +14,20 @@ public class ChannelMonitorUpdate extends CommonBase { bindings.ChannelMonitorUpdate_free(ptr); } - public ChannelMonitorUpdate(ChannelMonitorUpdate orig) { - super(bindings.ChannelMonitorUpdate_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelMonitorUpdate constructor_clone(ChannelMonitorUpdate orig) { + long ret = bindings.ChannelMonitorUpdate_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelMonitorUpdate ret_hu_conv = new ChannelMonitorUpdate(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public long get_update_id(ChannelMonitorUpdate this_ptr) { - long ret = bindings.ChannelMonitorUpdate_get_update_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_update_id() { + long ret = bindings.ChannelMonitorUpdate_get_update_id(this.ptr); return ret; } - public void set_update_id(ChannelMonitorUpdate this_ptr, long val) { - bindings.ChannelMonitorUpdate_set_update_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_update_id(long val) { + bindings.ChannelMonitorUpdate_set_update_id(this.ptr, val); } public byte[] write(ChannelMonitorUpdate obj) { @@ -33,8 +36,10 @@ public class ChannelMonitorUpdate extends CommonBase { return ret; } - public ChannelMonitorUpdate(byte[] ser) { - super(bindings.ChannelMonitorUpdate_read(ser)); + public static ChannelMonitorUpdate constructor_read(byte[] ser) { + long ret = bindings.ChannelMonitorUpdate_read(ser); + ChannelMonitorUpdate ret_hu_conv = new ChannelMonitorUpdate(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelPublicKeys.java b/src/main/java/org/ldk/structs/ChannelPublicKeys.java index 8b059bf1..882bdd08 100644 --- a/src/main/java/org/ldk/structs/ChannelPublicKeys.java +++ b/src/main/java/org/ldk/structs/ChannelPublicKeys.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelPublicKeys extends CommonBase { ChannelPublicKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,68 +14,62 @@ public class ChannelPublicKeys extends CommonBase { bindings.ChannelPublicKeys_free(ptr); } - public ChannelPublicKeys(ChannelPublicKeys orig) { - super(bindings.ChannelPublicKeys_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelPublicKeys constructor_clone(ChannelPublicKeys orig) { + long ret = bindings.ChannelPublicKeys_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_funding_pubkey(ChannelPublicKeys this_ptr) { - byte[] ret = bindings.ChannelPublicKeys_get_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_funding_pubkey() { + byte[] ret = bindings.ChannelPublicKeys_get_funding_pubkey(this.ptr); return ret; } - public void set_funding_pubkey(ChannelPublicKeys this_ptr, byte[] val) { - bindings.ChannelPublicKeys_set_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_pubkey(byte[] val) { + bindings.ChannelPublicKeys_set_funding_pubkey(this.ptr, val); } - public byte[] get_revocation_basepoint(ChannelPublicKeys this_ptr) { - byte[] ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_revocation_basepoint() { + byte[] ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr); return ret; } - public void set_revocation_basepoint(ChannelPublicKeys this_ptr, byte[] val) { - bindings.ChannelPublicKeys_set_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_revocation_basepoint(byte[] val) { + bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, val); } - public byte[] get_payment_point(ChannelPublicKeys this_ptr) { - byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_point() { + byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr); return ret; } - public void set_payment_point(ChannelPublicKeys this_ptr, byte[] val) { - bindings.ChannelPublicKeys_set_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_point(byte[] val) { + bindings.ChannelPublicKeys_set_payment_point(this.ptr, val); } - public byte[] get_delayed_payment_basepoint(ChannelPublicKeys this_ptr) { - byte[] ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_delayed_payment_basepoint() { + byte[] ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr); return ret; } - public void set_delayed_payment_basepoint(ChannelPublicKeys this_ptr, byte[] val) { - bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_delayed_payment_basepoint(byte[] val) { + bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this.ptr, val); } - public byte[] get_htlc_basepoint(ChannelPublicKeys this_ptr) { - byte[] ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_htlc_basepoint() { + byte[] ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr); return ret; } - public void set_htlc_basepoint(ChannelPublicKeys this_ptr, byte[] val) { - bindings.ChannelPublicKeys_set_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_basepoint(byte[] val) { + bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, val); } - public ChannelPublicKeys(byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg) { - super(bindings.ChannelPublicKeys_new(funding_pubkey_arg, revocation_basepoint_arg, payment_point_arg, delayed_payment_basepoint_arg, htlc_basepoint_arg)); + public static ChannelPublicKeys constructor_new(byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg) { + long ret = bindings.ChannelPublicKeys_new(funding_pubkey_arg, revocation_basepoint_arg, payment_point_arg, delayed_payment_basepoint_arg, htlc_basepoint_arg); + ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret); + return ret_hu_conv; } public byte[] write(ChannelPublicKeys obj) { @@ -81,8 +78,10 @@ public class ChannelPublicKeys extends CommonBase { return ret; } - public ChannelPublicKeys(byte[] ser) { - super(bindings.ChannelPublicKeys_read(ser)); + public static ChannelPublicKeys constructor_read(byte[] ser) { + long ret = bindings.ChannelPublicKeys_read(ser); + ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelReestablish.java b/src/main/java/org/ldk/structs/ChannelReestablish.java index 3d47cc18..ceb78ed4 100644 --- a/src/main/java/org/ldk/structs/ChannelReestablish.java +++ b/src/main/java/org/ldk/structs/ChannelReestablish.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelReestablish extends CommonBase { ChannelReestablish(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,42 +14,38 @@ public class ChannelReestablish extends CommonBase { bindings.ChannelReestablish_free(ptr); } - public ChannelReestablish(ChannelReestablish orig) { - super(bindings.ChannelReestablish_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelReestablish constructor_clone(ChannelReestablish orig) { + long ret = bindings.ChannelReestablish_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelReestablish ret_hu_conv = new ChannelReestablish(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(ChannelReestablish this_ptr) { - byte[] ret = bindings.ChannelReestablish_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.ChannelReestablish_get_channel_id(this.ptr); return ret; } - public void set_channel_id(ChannelReestablish this_ptr, byte[] val) { - bindings.ChannelReestablish_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.ChannelReestablish_set_channel_id(this.ptr, val); } - public long get_next_local_commitment_number(ChannelReestablish this_ptr) { - long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_next_local_commitment_number() { + long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr); return ret; } - public void set_next_local_commitment_number(ChannelReestablish this_ptr, long val) { - bindings.ChannelReestablish_set_next_local_commitment_number(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_next_local_commitment_number(long val) { + bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val); } - public long get_next_remote_commitment_number(ChannelReestablish this_ptr) { - long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_next_remote_commitment_number() { + long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr); return ret; } - public void set_next_remote_commitment_number(ChannelReestablish this_ptr, long val) { - bindings.ChannelReestablish_set_next_remote_commitment_number(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_next_remote_commitment_number(long val) { + bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val); } public byte[] write(ChannelReestablish obj) { @@ -55,8 +54,10 @@ public class ChannelReestablish extends CommonBase { return ret; } - public ChannelReestablish(byte[] ser) { - super(bindings.ChannelReestablish_read(ser)); + public static ChannelReestablish constructor_read(byte[] ser) { + long ret = bindings.ChannelReestablish_read(ser); + ChannelReestablish ret_hu_conv = new ChannelReestablish(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ChannelUpdate.java b/src/main/java/org/ldk/structs/ChannelUpdate.java index b6a3f8d5..3fe97d5a 100644 --- a/src/main/java/org/ldk/structs/ChannelUpdate.java +++ b/src/main/java/org/ldk/structs/ChannelUpdate.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelUpdate extends CommonBase { ChannelUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,37 +14,38 @@ public class ChannelUpdate extends CommonBase { bindings.ChannelUpdate_free(ptr); } - public ChannelUpdate(ChannelUpdate orig) { - super(bindings.ChannelUpdate_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ChannelUpdate constructor_clone(ChannelUpdate orig) { + long ret = bindings.ChannelUpdate_clone(orig == null ? 0 : orig.ptr & ~1); + ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_signature(ChannelUpdate this_ptr) { - byte[] ret = bindings.ChannelUpdate_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.ChannelUpdate_get_signature(this.ptr); return ret; } - public void set_signature(ChannelUpdate this_ptr, byte[] val) { - bindings.ChannelUpdate_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.ChannelUpdate_set_signature(this.ptr, val); } - public UnsignedChannelUpdate get_contents(ChannelUpdate this_ptr) { - UnsignedChannelUpdate ret = new UnsignedChannelUpdate(null, bindings.ChannelUpdate_get_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public UnsignedChannelUpdate get_contents() { + long ret = bindings.ChannelUpdate_get_contents(this.ptr); + UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret); + return ret_hu_conv; } - public void set_contents(ChannelUpdate this_ptr, UnsignedChannelUpdate val) { - bindings.ChannelUpdate_set_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_contents(UnsignedChannelUpdate val) { + bindings.ChannelUpdate_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public ChannelUpdate(byte[] signature_arg, UnsignedChannelUpdate contents_arg) { - super(bindings.ChannelUpdate_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1)); - this.ptrs_to.add(contents_arg); + public static ChannelUpdate constructor_new(byte[] signature_arg, UnsignedChannelUpdate contents_arg) { + long ret = bindings.ChannelUpdate_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1); + ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret); + ret_hu_conv.ptrs_to.add(contents_arg); + return ret_hu_conv; } public byte[] write(ChannelUpdate obj) { @@ -50,8 +54,10 @@ public class ChannelUpdate extends CommonBase { return ret; } - public ChannelUpdate(byte[] ser) { - super(bindings.ChannelUpdate_read(ser)); + public static ChannelUpdate constructor_read(byte[] ser) { + long ret = bindings.ChannelUpdate_read(ser); + ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ClosingSigned.java b/src/main/java/org/ldk/structs/ClosingSigned.java index b9cea8b9..a8a0063e 100644 --- a/src/main/java/org/ldk/structs/ClosingSigned.java +++ b/src/main/java/org/ldk/structs/ClosingSigned.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ClosingSigned extends CommonBase { ClosingSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,46 +14,44 @@ public class ClosingSigned extends CommonBase { bindings.ClosingSigned_free(ptr); } - public ClosingSigned(ClosingSigned orig) { - super(bindings.ClosingSigned_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ClosingSigned constructor_clone(ClosingSigned orig) { + long ret = bindings.ClosingSigned_clone(orig == null ? 0 : orig.ptr & ~1); + ClosingSigned ret_hu_conv = new ClosingSigned(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(ClosingSigned this_ptr) { - byte[] ret = bindings.ClosingSigned_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr); return ret; } - public void set_channel_id(ClosingSigned this_ptr, byte[] val) { - bindings.ClosingSigned_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.ClosingSigned_set_channel_id(this.ptr, val); } - public long get_fee_satoshis(ClosingSigned this_ptr) { - long ret = bindings.ClosingSigned_get_fee_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_fee_satoshis() { + long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr); return ret; } - public void set_fee_satoshis(ClosingSigned this_ptr, long val) { - bindings.ClosingSigned_set_fee_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_fee_satoshis(long val) { + bindings.ClosingSigned_set_fee_satoshis(this.ptr, val); } - public byte[] get_signature(ClosingSigned this_ptr) { - byte[] ret = bindings.ClosingSigned_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.ClosingSigned_get_signature(this.ptr); return ret; } - public void set_signature(ClosingSigned this_ptr, byte[] val) { - bindings.ClosingSigned_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.ClosingSigned_set_signature(this.ptr, val); } - public ClosingSigned(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg) { - super(bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg)); + public static ClosingSigned constructor_new(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg) { + long ret = bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg); + ClosingSigned ret_hu_conv = new ClosingSigned(null, ret); + return ret_hu_conv; } public byte[] write(ClosingSigned obj) { @@ -59,8 +60,10 @@ public class ClosingSigned extends CommonBase { return ret; } - public ClosingSigned(byte[] ser) { - super(bindings.ClosingSigned_read(ser)); + public static ClosingSigned constructor_read(byte[] ser) { + long ret = bindings.ClosingSigned_read(ser); + ClosingSigned ret_hu_conv = new ClosingSigned(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/CommitmentSigned.java b/src/main/java/org/ldk/structs/CommitmentSigned.java index 12f35522..bffa91b7 100644 --- a/src/main/java/org/ldk/structs/CommitmentSigned.java +++ b/src/main/java/org/ldk/structs/CommitmentSigned.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class CommitmentSigned extends CommonBase { CommitmentSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,43 +14,51 @@ public class CommitmentSigned extends CommonBase { bindings.CommitmentSigned_free(ptr); } - public CommitmentSigned(CommitmentSigned orig) { - super(bindings.CommitmentSigned_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static CommitmentSigned constructor_clone(CommitmentSigned orig) { + long ret = bindings.CommitmentSigned_clone(orig == null ? 0 : orig.ptr & ~1); + CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(CommitmentSigned this_ptr) { - byte[] ret = bindings.CommitmentSigned_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.CommitmentSigned_get_channel_id(this.ptr); return ret; } - public void set_channel_id(CommitmentSigned this_ptr, byte[] val) { - bindings.CommitmentSigned_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.CommitmentSigned_set_channel_id(this.ptr, val); } - public byte[] get_signature(CommitmentSigned this_ptr) { - byte[] ret = bindings.CommitmentSigned_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.CommitmentSigned_get_signature(this.ptr); return ret; } - public void set_signature(CommitmentSigned this_ptr, byte[] val) { - bindings.CommitmentSigned_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.CommitmentSigned_set_signature(this.ptr, val); + } + + public void set_htlc_signatures(byte[][] val) { + bindings.CommitmentSigned_set_htlc_signatures(this.ptr, val); + } + + public static CommitmentSigned constructor_new(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) { + long ret = bindings.CommitmentSigned_new(channel_id_arg, signature_arg, htlc_signatures_arg); + CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + return ret_hu_conv; } - // Skipped CommitmentSigned_set_htlc_signatures - // Skipped CommitmentSigned_new public byte[] write(CommitmentSigned obj) { byte[] ret = bindings.CommitmentSigned_write(obj == null ? 0 : obj.ptr & ~1); this.ptrs_to.add(obj); return ret; } - public CommitmentSigned(byte[] ser) { - super(bindings.CommitmentSigned_read(ser)); + public static CommitmentSigned constructor_read(byte[] ser) { + long ret = bindings.CommitmentSigned_read(ser); + CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/CommitmentUpdate.java b/src/main/java/org/ldk/structs/CommitmentUpdate.java index 9f8c7a7a..b78bf907 100644 --- a/src/main/java/org/ldk/structs/CommitmentUpdate.java +++ b/src/main/java/org/ldk/structs/CommitmentUpdate.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class CommitmentUpdate extends CommonBase { CommitmentUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,38 +14,65 @@ public class CommitmentUpdate extends CommonBase { bindings.CommitmentUpdate_free(ptr); } - public CommitmentUpdate(CommitmentUpdate orig) { - super(bindings.CommitmentUpdate_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static CommitmentUpdate constructor_clone(CommitmentUpdate orig) { + long ret = bindings.CommitmentUpdate_clone(orig == null ? 0 : orig.ptr & ~1); + CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - // Skipped CommitmentUpdate_set_update_add_htlcs - // Skipped CommitmentUpdate_set_update_fulfill_htlcs - // Skipped CommitmentUpdate_set_update_fail_htlcs - // Skipped CommitmentUpdate_set_update_fail_malformed_htlcs - public UpdateFee get_update_fee(CommitmentUpdate this_ptr) { - UpdateFee ret = new UpdateFee(null, bindings.CommitmentUpdate_get_update_fee(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public void set_update_add_htlcs(UpdateAddHTLC[] val) { + bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, Arrays.stream(val).mapToLong(arr_conv_15 -> arr_conv_15 == null ? 0 : arr_conv_15.ptr & ~1).toArray()); + /* TODO 2 UpdateAddHTLC */; } - public void set_update_fee(CommitmentUpdate this_ptr, UpdateFee val) { - bindings.CommitmentUpdate_set_update_fee(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) { + bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, Arrays.stream(val).mapToLong(arr_conv_19 -> arr_conv_19 == null ? 0 : arr_conv_19.ptr & ~1).toArray()); + /* TODO 2 UpdateFulfillHTLC */; + } + + public void set_update_fail_htlcs(UpdateFailHTLC[] val) { + bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, Arrays.stream(val).mapToLong(arr_conv_16 -> arr_conv_16 == null ? 0 : arr_conv_16.ptr & ~1).toArray()); + /* TODO 2 UpdateFailHTLC */; + } + + public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) { + bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, Arrays.stream(val).mapToLong(arr_conv_25 -> arr_conv_25 == null ? 0 : arr_conv_25.ptr & ~1).toArray()); + /* TODO 2 UpdateFailMalformedHTLC */; + } + + public UpdateFee get_update_fee() { + long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr); + UpdateFee ret_hu_conv = new UpdateFee(null, ret); + return ret_hu_conv; + } + + public void set_update_fee(UpdateFee val) { + bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public CommitmentSigned get_commitment_signed(CommitmentUpdate this_ptr) { - CommitmentSigned ret = new CommitmentSigned(null, bindings.CommitmentUpdate_get_commitment_signed(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public CommitmentSigned get_commitment_signed() { + long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr); + CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + return ret_hu_conv; } - public void set_commitment_signed(CommitmentUpdate this_ptr, CommitmentSigned val) { - bindings.CommitmentUpdate_set_commitment_signed(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_commitment_signed(CommitmentSigned val) { + bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - // Skipped CommitmentUpdate_new + public static CommitmentUpdate constructor_new(UpdateAddHTLC[] update_add_htlcs_arg, UpdateFulfillHTLC[] update_fulfill_htlcs_arg, UpdateFailHTLC[] update_fail_htlcs_arg, UpdateFailMalformedHTLC[] update_fail_malformed_htlcs_arg, UpdateFee update_fee_arg, CommitmentSigned commitment_signed_arg) { + long ret = bindings.CommitmentUpdate_new(Arrays.stream(update_add_htlcs_arg).mapToLong(arr_conv_15 -> arr_conv_15 == null ? 0 : arr_conv_15.ptr & ~1).toArray(), Arrays.stream(update_fulfill_htlcs_arg).mapToLong(arr_conv_19 -> arr_conv_19 == null ? 0 : arr_conv_19.ptr & ~1).toArray(), Arrays.stream(update_fail_htlcs_arg).mapToLong(arr_conv_16 -> arr_conv_16 == null ? 0 : arr_conv_16.ptr & ~1).toArray(), Arrays.stream(update_fail_malformed_htlcs_arg).mapToLong(arr_conv_25 -> arr_conv_25 == null ? 0 : arr_conv_25.ptr & ~1).toArray(), update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1); + CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret); + /* TODO 2 UpdateAddHTLC */; + /* TODO 2 UpdateFulfillHTLC */; + /* TODO 2 UpdateFailHTLC */; + /* TODO 2 UpdateFailMalformedHTLC */; + ret_hu_conv.ptrs_to.add(update_fee_arg); + ret_hu_conv.ptrs_to.add(commitment_signed_arg); + return ret_hu_conv; + } + } diff --git a/src/main/java/org/ldk/structs/DataLossProtect.java b/src/main/java/org/ldk/structs/DataLossProtect.java index f4bf70f1..2a5438e1 100644 --- a/src/main/java/org/ldk/structs/DataLossProtect.java +++ b/src/main/java/org/ldk/structs/DataLossProtect.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class DataLossProtect extends CommonBase { DataLossProtect(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class DataLossProtect extends CommonBase { bindings.DataLossProtect_free(ptr); } - public DataLossProtect(DataLossProtect orig) { - super(bindings.DataLossProtect_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static DataLossProtect constructor_clone(DataLossProtect orig) { + long ret = bindings.DataLossProtect_clone(orig == null ? 0 : orig.ptr & ~1); + DataLossProtect ret_hu_conv = new DataLossProtect(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_your_last_per_commitment_secret(DataLossProtect this_ptr) { - byte[] ret = bindings.DataLossProtect_get_your_last_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_your_last_per_commitment_secret() { + byte[] ret = bindings.DataLossProtect_get_your_last_per_commitment_secret(this.ptr); return ret; } - public void set_your_last_per_commitment_secret(DataLossProtect this_ptr, byte[] val) { - bindings.DataLossProtect_set_your_last_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_your_last_per_commitment_secret(byte[] val) { + bindings.DataLossProtect_set_your_last_per_commitment_secret(this.ptr, val); } - public byte[] get_my_current_per_commitment_point(DataLossProtect this_ptr) { - byte[] ret = bindings.DataLossProtect_get_my_current_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_my_current_per_commitment_point() { + byte[] ret = bindings.DataLossProtect_get_my_current_per_commitment_point(this.ptr); return ret; } - public void set_my_current_per_commitment_point(DataLossProtect this_ptr, byte[] val) { - bindings.DataLossProtect_set_my_current_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_my_current_per_commitment_point(byte[] val) { + bindings.DataLossProtect_set_my_current_per_commitment_point(this.ptr, val); } - public DataLossProtect(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) { - super(bindings.DataLossProtect_new(your_last_per_commitment_secret_arg, my_current_per_commitment_point_arg)); + public static DataLossProtect constructor_new(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) { + long ret = bindings.DataLossProtect_new(your_last_per_commitment_secret_arg, my_current_per_commitment_point_arg); + DataLossProtect ret_hu_conv = new DataLossProtect(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/DecodeError.java b/src/main/java/org/ldk/structs/DecodeError.java index 71ff6155..4ed9f4de 100644 --- a/src/main/java/org/ldk/structs/DecodeError.java +++ b/src/main/java/org/ldk/structs/DecodeError.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class DecodeError extends CommonBase { DecodeError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java index bcb2e8e3..0b638356 100644 --- a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java +++ b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class DirectionalChannelInfo extends CommonBase { DirectionalChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,59 +14,50 @@ public class DirectionalChannelInfo extends CommonBase { bindings.DirectionalChannelInfo_free(ptr); } - public int get_last_update(DirectionalChannelInfo this_ptr) { - int ret = bindings.DirectionalChannelInfo_get_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_last_update() { + int ret = bindings.DirectionalChannelInfo_get_last_update(this.ptr); return ret; } - public void set_last_update(DirectionalChannelInfo this_ptr, int val) { - bindings.DirectionalChannelInfo_set_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_last_update(int val) { + bindings.DirectionalChannelInfo_set_last_update(this.ptr, val); } - public boolean get_enabled(DirectionalChannelInfo this_ptr) { - boolean ret = bindings.DirectionalChannelInfo_get_enabled(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_enabled() { + boolean ret = bindings.DirectionalChannelInfo_get_enabled(this.ptr); return ret; } - public void set_enabled(DirectionalChannelInfo this_ptr, boolean val) { - bindings.DirectionalChannelInfo_set_enabled(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_enabled(boolean val) { + bindings.DirectionalChannelInfo_set_enabled(this.ptr, val); } - public short get_cltv_expiry_delta(DirectionalChannelInfo this_ptr) { - short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_cltv_expiry_delta() { + short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this.ptr); return ret; } - public void set_cltv_expiry_delta(DirectionalChannelInfo this_ptr, short val) { - bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry_delta(short val) { + bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this.ptr, val); } - public long get_htlc_minimum_msat(DirectionalChannelInfo this_ptr) { - long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_minimum_msat() { + long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(DirectionalChannelInfo this_ptr, long val) { - bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_minimum_msat(long val) { + bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this.ptr, val); } - public ChannelUpdate get_last_update_message(DirectionalChannelInfo this_ptr) { - ChannelUpdate ret = new ChannelUpdate(null, bindings.DirectionalChannelInfo_get_last_update_message(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelUpdate get_last_update_message() { + long ret = bindings.DirectionalChannelInfo_get_last_update_message(this.ptr); + ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret); + return ret_hu_conv; } - public void set_last_update_message(DirectionalChannelInfo this_ptr, ChannelUpdate val) { - bindings.DirectionalChannelInfo_set_last_update_message(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_last_update_message(ChannelUpdate val) { + bindings.DirectionalChannelInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } @@ -73,8 +67,10 @@ public class DirectionalChannelInfo extends CommonBase { return ret; } - public DirectionalChannelInfo(byte[] ser) { - super(bindings.DirectionalChannelInfo_read(ser)); + public static DirectionalChannelInfo constructor_read(byte[] ser) { + long ret = bindings.DirectionalChannelInfo_read(ser); + DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/ErrorAction.java b/src/main/java/org/ldk/structs/ErrorAction.java new file mode 100644 index 00000000..642fb0a4 --- /dev/null +++ b/src/main/java/org/ldk/structs/ErrorAction.java @@ -0,0 +1,40 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class ErrorAction extends CommonBase { + private ErrorAction(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static ErrorAction constr_from_ptr(long ptr) { + bindings.LDKErrorAction raw_val = bindings.LDKErrorAction_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKErrorAction.DisconnectPeer.class) { + return new DisconnectPeer(null, ptr); + } + if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreError.class) { + return new IgnoreError(null, ptr); + } + if (raw_val.getClass() == bindings.LDKErrorAction.SendErrorMessage.class) { + return new SendErrorMessage(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class DisconnectPeer extends ErrorAction { + public ErrorMessage msg; + private DisconnectPeer(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class IgnoreError extends ErrorAction { + private IgnoreError(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendErrorMessage extends ErrorAction { + public ErrorMessage msg; + private SendErrorMessage(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/ErrorMessage.java b/src/main/java/org/ldk/structs/ErrorMessage.java index 25f19094..d0182f31 100644 --- a/src/main/java/org/ldk/structs/ErrorMessage.java +++ b/src/main/java/org/ldk/structs/ErrorMessage.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ErrorMessage extends CommonBase { ErrorMessage(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,30 +14,35 @@ public class ErrorMessage extends CommonBase { bindings.ErrorMessage_free(ptr); } - public ErrorMessage(ErrorMessage orig) { - super(bindings.ErrorMessage_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ErrorMessage constructor_clone(ErrorMessage orig) { + long ret = bindings.ErrorMessage_clone(orig == null ? 0 : orig.ptr & ~1); + ErrorMessage ret_hu_conv = new ErrorMessage(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(ErrorMessage this_ptr) { - byte[] ret = bindings.ErrorMessage_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.ErrorMessage_get_channel_id(this.ptr); return ret; } - public void set_channel_id(ErrorMessage this_ptr, byte[] val) { - bindings.ErrorMessage_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.ErrorMessage_set_channel_id(this.ptr, val); } - // Skipped ErrorMessage_get_data - public void set_data(ErrorMessage this_ptr, byte[] val) { - bindings.ErrorMessage_set_data(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public String get_data() { + String ret = bindings.ErrorMessage_get_data(this.ptr); + return ret; + } + + public void set_data(byte[] val) { + bindings.ErrorMessage_set_data(this.ptr, val); } - public ErrorMessage(byte[] channel_id_arg, byte[] data_arg) { - super(bindings.ErrorMessage_new(channel_id_arg, data_arg)); + public static ErrorMessage constructor_new(byte[] channel_id_arg, byte[] data_arg) { + long ret = bindings.ErrorMessage_new(channel_id_arg, data_arg); + ErrorMessage ret_hu_conv = new ErrorMessage(null, ret); + return ret_hu_conv; } public byte[] write(ErrorMessage obj) { @@ -43,8 +51,10 @@ public class ErrorMessage extends CommonBase { return ret; } - public ErrorMessage(byte[] ser) { - super(bindings.ErrorMessage_read(ser)); + public static ErrorMessage constructor_read(byte[] ser) { + long ret = bindings.ErrorMessage_read(ser); + ErrorMessage ret_hu_conv = new ErrorMessage(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Event.java b/src/main/java/org/ldk/structs/Event.java new file mode 100644 index 00000000..d191cb0a --- /dev/null +++ b/src/main/java/org/ldk/structs/Event.java @@ -0,0 +1,80 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Event extends CommonBase { + private Event(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static Event constr_from_ptr(long ptr) { + bindings.LDKEvent raw_val = bindings.LDKEvent_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) { + return new FundingGenerationReady(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.FundingBroadcastSafe.class) { + return new FundingBroadcastSafe(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) { + return new PaymentReceived(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) { + return new PaymentSent(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) { + return new PaymentFailed(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) { + return new PendingHTLCsForwardable(null, ptr); + } + if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) { + return new SpendableOutputs(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class FundingGenerationReady extends Event { + public byte[] temporary_channel_id; + public long channel_value_satoshis; + public byte[] output_script; + public long user_channel_id; + private FundingGenerationReady(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class FundingBroadcastSafe extends Event { + public OutPoint funding_txo; + public long user_channel_id; + private FundingBroadcastSafe(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class PaymentReceived extends Event { + public byte[] payment_hash; + public byte[] payment_secret; + public long amt; + private PaymentReceived(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class PaymentSent extends Event { + public byte[] payment_preimage; + private PaymentSent(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class PaymentFailed extends Event { + public byte[] payment_hash; + public boolean rejected_by_dest; + private PaymentFailed(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class PendingHTLCsForwardable extends Event { + public long time_forwardable; + private PendingHTLCsForwardable(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SpendableOutputs extends Event { + public SpendableOutputDescriptor[] outputs; + private SpendableOutputs(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/EventsProvider.java b/src/main/java/org/ldk/structs/EventsProvider.java index 1002d8d4..ed6ef602 100644 --- a/src/main/java/org/ldk/structs/EventsProvider.java +++ b/src/main/java/org/ldk/structs/EventsProvider.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class EventsProvider extends CommonBase { EventsProvider(Object _dummy, long ptr) { super(ptr); } public EventsProvider(bindings.LDKEventsProvider arg) { @@ -15,5 +17,15 @@ public class EventsProvider extends CommonBase { bindings.EventsProvider_free(ptr); super.finalize(); } - // Skipped EventsProvider_get_and_clear_pending_events + public Event[] get_and_clear_pending_events() { + long[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr); + Event[] arr_conv_7_arr = new Event[ret.length]; + for (int h = 0; h < ret.length; h++) { + long arr_conv_7 = ret[h]; + Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7); + arr_conv_7_arr[h] = arr_conv_7_hu_conv; + } + return arr_conv_7_arr; + } + } diff --git a/src/main/java/org/ldk/structs/FeeEstimator.java b/src/main/java/org/ldk/structs/FeeEstimator.java index 69a5936e..13c16315 100644 --- a/src/main/java/org/ldk/structs/FeeEstimator.java +++ b/src/main/java/org/ldk/structs/FeeEstimator.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class FeeEstimator extends CommonBase { FeeEstimator(Object _dummy, long ptr) { super(ptr); } public FeeEstimator(bindings.LDKFeeEstimator arg) { diff --git a/src/main/java/org/ldk/structs/Filter.java b/src/main/java/org/ldk/structs/Filter.java index 9b9dcede..b4094bd1 100644 --- a/src/main/java/org/ldk/structs/Filter.java +++ b/src/main/java/org/ldk/structs/Filter.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Filter extends CommonBase { Filter(Object _dummy, long ptr) { super(ptr); } public Filter(bindings.LDKFilter arg) { diff --git a/src/main/java/org/ldk/structs/FundingCreated.java b/src/main/java/org/ldk/structs/FundingCreated.java index 27c86a0c..f45f2c68 100644 --- a/src/main/java/org/ldk/structs/FundingCreated.java +++ b/src/main/java/org/ldk/structs/FundingCreated.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class FundingCreated extends CommonBase { FundingCreated(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,57 +14,53 @@ public class FundingCreated extends CommonBase { bindings.FundingCreated_free(ptr); } - public FundingCreated(FundingCreated orig) { - super(bindings.FundingCreated_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static FundingCreated constructor_clone(FundingCreated orig) { + long ret = bindings.FundingCreated_clone(orig == null ? 0 : orig.ptr & ~1); + FundingCreated ret_hu_conv = new FundingCreated(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_temporary_channel_id(FundingCreated this_ptr) { - byte[] ret = bindings.FundingCreated_get_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_temporary_channel_id() { + byte[] ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr); return ret; } - public void set_temporary_channel_id(FundingCreated this_ptr, byte[] val) { - bindings.FundingCreated_set_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_temporary_channel_id(byte[] val) { + bindings.FundingCreated_set_temporary_channel_id(this.ptr, val); } - public byte[] get_funding_txid(FundingCreated this_ptr) { - byte[] ret = bindings.FundingCreated_get_funding_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_funding_txid() { + byte[] ret = bindings.FundingCreated_get_funding_txid(this.ptr); return ret; } - public void set_funding_txid(FundingCreated this_ptr, byte[] val) { - bindings.FundingCreated_set_funding_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_txid(byte[] val) { + bindings.FundingCreated_set_funding_txid(this.ptr, val); } - public short get_funding_output_index(FundingCreated this_ptr) { - short ret = bindings.FundingCreated_get_funding_output_index(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_funding_output_index() { + short ret = bindings.FundingCreated_get_funding_output_index(this.ptr); return ret; } - public void set_funding_output_index(FundingCreated this_ptr, short val) { - bindings.FundingCreated_set_funding_output_index(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_output_index(short val) { + bindings.FundingCreated_set_funding_output_index(this.ptr, val); } - public byte[] get_signature(FundingCreated this_ptr) { - byte[] ret = bindings.FundingCreated_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.FundingCreated_get_signature(this.ptr); return ret; } - public void set_signature(FundingCreated this_ptr, byte[] val) { - bindings.FundingCreated_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.FundingCreated_set_signature(this.ptr, val); } - public FundingCreated(byte[] temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) { - super(bindings.FundingCreated_new(temporary_channel_id_arg, funding_txid_arg, funding_output_index_arg, signature_arg)); + public static FundingCreated constructor_new(byte[] temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) { + long ret = bindings.FundingCreated_new(temporary_channel_id_arg, funding_txid_arg, funding_output_index_arg, signature_arg); + FundingCreated ret_hu_conv = new FundingCreated(null, ret); + return ret_hu_conv; } public byte[] write(FundingCreated obj) { @@ -70,8 +69,10 @@ public class FundingCreated extends CommonBase { return ret; } - public FundingCreated(byte[] ser) { - super(bindings.FundingCreated_read(ser)); + public static FundingCreated constructor_read(byte[] ser) { + long ret = bindings.FundingCreated_read(ser); + FundingCreated ret_hu_conv = new FundingCreated(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/FundingLocked.java b/src/main/java/org/ldk/structs/FundingLocked.java index ac0cdf23..1cf7d7ac 100644 --- a/src/main/java/org/ldk/structs/FundingLocked.java +++ b/src/main/java/org/ldk/structs/FundingLocked.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class FundingLocked extends CommonBase { FundingLocked(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class FundingLocked extends CommonBase { bindings.FundingLocked_free(ptr); } - public FundingLocked(FundingLocked orig) { - super(bindings.FundingLocked_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static FundingLocked constructor_clone(FundingLocked orig) { + long ret = bindings.FundingLocked_clone(orig == null ? 0 : orig.ptr & ~1); + FundingLocked ret_hu_conv = new FundingLocked(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(FundingLocked this_ptr) { - byte[] ret = bindings.FundingLocked_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.FundingLocked_get_channel_id(this.ptr); return ret; } - public void set_channel_id(FundingLocked this_ptr, byte[] val) { - bindings.FundingLocked_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.FundingLocked_set_channel_id(this.ptr, val); } - public byte[] get_next_per_commitment_point(FundingLocked this_ptr) { - byte[] ret = bindings.FundingLocked_get_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_next_per_commitment_point() { + byte[] ret = bindings.FundingLocked_get_next_per_commitment_point(this.ptr); return ret; } - public void set_next_per_commitment_point(FundingLocked this_ptr, byte[] val) { - bindings.FundingLocked_set_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_next_per_commitment_point(byte[] val) { + bindings.FundingLocked_set_next_per_commitment_point(this.ptr, val); } - public FundingLocked(byte[] channel_id_arg, byte[] next_per_commitment_point_arg) { - super(bindings.FundingLocked_new(channel_id_arg, next_per_commitment_point_arg)); + public static FundingLocked constructor_new(byte[] channel_id_arg, byte[] next_per_commitment_point_arg) { + long ret = bindings.FundingLocked_new(channel_id_arg, next_per_commitment_point_arg); + FundingLocked ret_hu_conv = new FundingLocked(null, ret); + return ret_hu_conv; } public byte[] write(FundingLocked obj) { @@ -48,8 +51,10 @@ public class FundingLocked extends CommonBase { return ret; } - public FundingLocked(byte[] ser) { - super(bindings.FundingLocked_read(ser)); + public static FundingLocked constructor_read(byte[] ser) { + long ret = bindings.FundingLocked_read(ser); + FundingLocked ret_hu_conv = new FundingLocked(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/FundingSigned.java b/src/main/java/org/ldk/structs/FundingSigned.java index 8cd651c1..640c3c1e 100644 --- a/src/main/java/org/ldk/structs/FundingSigned.java +++ b/src/main/java/org/ldk/structs/FundingSigned.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class FundingSigned extends CommonBase { FundingSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class FundingSigned extends CommonBase { bindings.FundingSigned_free(ptr); } - public FundingSigned(FundingSigned orig) { - super(bindings.FundingSigned_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static FundingSigned constructor_clone(FundingSigned orig) { + long ret = bindings.FundingSigned_clone(orig == null ? 0 : orig.ptr & ~1); + FundingSigned ret_hu_conv = new FundingSigned(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(FundingSigned this_ptr) { - byte[] ret = bindings.FundingSigned_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.FundingSigned_get_channel_id(this.ptr); return ret; } - public void set_channel_id(FundingSigned this_ptr, byte[] val) { - bindings.FundingSigned_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.FundingSigned_set_channel_id(this.ptr, val); } - public byte[] get_signature(FundingSigned this_ptr) { - byte[] ret = bindings.FundingSigned_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.FundingSigned_get_signature(this.ptr); return ret; } - public void set_signature(FundingSigned this_ptr, byte[] val) { - bindings.FundingSigned_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.FundingSigned_set_signature(this.ptr, val); } - public FundingSigned(byte[] channel_id_arg, byte[] signature_arg) { - super(bindings.FundingSigned_new(channel_id_arg, signature_arg)); + public static FundingSigned constructor_new(byte[] channel_id_arg, byte[] signature_arg) { + long ret = bindings.FundingSigned_new(channel_id_arg, signature_arg); + FundingSigned ret_hu_conv = new FundingSigned(null, ret); + return ret_hu_conv; } public byte[] write(FundingSigned obj) { @@ -48,8 +51,10 @@ public class FundingSigned extends CommonBase { return ret; } - public FundingSigned(byte[] ser) { - super(bindings.FundingSigned_read(ser)); + public static FundingSigned constructor_read(byte[] ser) { + long ret = bindings.FundingSigned_read(ser); + FundingSigned ret_hu_conv = new FundingSigned(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/GossipTimestampFilter.java b/src/main/java/org/ldk/structs/GossipTimestampFilter.java index 96787b6a..5efcccf8 100644 --- a/src/main/java/org/ldk/structs/GossipTimestampFilter.java +++ b/src/main/java/org/ldk/structs/GossipTimestampFilter.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class GossipTimestampFilter extends CommonBase { GossipTimestampFilter(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,50 +14,50 @@ public class GossipTimestampFilter extends CommonBase { bindings.GossipTimestampFilter_free(ptr); } - public GossipTimestampFilter(GossipTimestampFilter orig) { - super(bindings.GossipTimestampFilter_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static GossipTimestampFilter constructor_clone(GossipTimestampFilter orig) { + long ret = bindings.GossipTimestampFilter_clone(orig == null ? 0 : orig.ptr & ~1); + GossipTimestampFilter ret_hu_conv = new GossipTimestampFilter(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(GossipTimestampFilter this_ptr) { - byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(GossipTimestampFilter this_ptr, byte[] val) { - bindings.GossipTimestampFilter_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.GossipTimestampFilter_set_chain_hash(this.ptr, val); } - public int get_first_timestamp(GossipTimestampFilter this_ptr) { - int ret = bindings.GossipTimestampFilter_get_first_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_first_timestamp() { + int ret = bindings.GossipTimestampFilter_get_first_timestamp(this.ptr); return ret; } - public void set_first_timestamp(GossipTimestampFilter this_ptr, int val) { - bindings.GossipTimestampFilter_set_first_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_first_timestamp(int val) { + bindings.GossipTimestampFilter_set_first_timestamp(this.ptr, val); } - public int get_timestamp_range(GossipTimestampFilter this_ptr) { - int ret = bindings.GossipTimestampFilter_get_timestamp_range(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_timestamp_range() { + int ret = bindings.GossipTimestampFilter_get_timestamp_range(this.ptr); return ret; } - public void set_timestamp_range(GossipTimestampFilter this_ptr, int val) { - bindings.GossipTimestampFilter_set_timestamp_range(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_timestamp_range(int val) { + bindings.GossipTimestampFilter_set_timestamp_range(this.ptr, val); } - public GossipTimestampFilter(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) { - super(bindings.GossipTimestampFilter_new(chain_hash_arg, first_timestamp_arg, timestamp_range_arg)); + public static GossipTimestampFilter constructor_new(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) { + long ret = bindings.GossipTimestampFilter_new(chain_hash_arg, first_timestamp_arg, timestamp_range_arg); + GossipTimestampFilter ret_hu_conv = new GossipTimestampFilter(null, ret); + return ret_hu_conv; } - public GossipTimestampFilter(byte[] ser) { - super(bindings.GossipTimestampFilter_read(ser)); + public static GossipTimestampFilter constructor_read(byte[] ser) { + long ret = bindings.GossipTimestampFilter_read(ser); + GossipTimestampFilter ret_hu_conv = new GossipTimestampFilter(null, ret); + return ret_hu_conv; } public byte[] write(GossipTimestampFilter obj) { diff --git a/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java b/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java new file mode 100644 index 00000000..63224cd8 --- /dev/null +++ b/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java @@ -0,0 +1,43 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class HTLCFailChannelUpdate extends CommonBase { + private HTLCFailChannelUpdate(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static HTLCFailChannelUpdate constr_from_ptr(long ptr) { + bindings.LDKHTLCFailChannelUpdate raw_val = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage.class) { + return new ChannelUpdateMessage(null, ptr); + } + if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelClosed.class) { + return new ChannelClosed(null, ptr); + } + if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.NodeFailure.class) { + return new NodeFailure(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class ChannelUpdateMessage extends HTLCFailChannelUpdate { + public ChannelUpdate msg; + private ChannelUpdateMessage(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class ChannelClosed extends HTLCFailChannelUpdate { + public long short_channel_id; + public boolean is_permanent; + private ChannelClosed(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class NodeFailure extends HTLCFailChannelUpdate { + public byte[] node_id; + public boolean is_permanent; + private NodeFailure(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java b/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java index eaf132b8..c6e730a7 100644 --- a/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java +++ b/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class HTLCOutputInCommitment extends CommonBase { HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,53 +14,47 @@ public class HTLCOutputInCommitment extends CommonBase { bindings.HTLCOutputInCommitment_free(ptr); } - public HTLCOutputInCommitment(HTLCOutputInCommitment orig) { - super(bindings.HTLCOutputInCommitment_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static HTLCOutputInCommitment constructor_clone(HTLCOutputInCommitment orig) { + long ret = bindings.HTLCOutputInCommitment_clone(orig == null ? 0 : orig.ptr & ~1); + HTLCOutputInCommitment ret_hu_conv = new HTLCOutputInCommitment(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public boolean get_offered(HTLCOutputInCommitment this_ptr) { - boolean ret = bindings.HTLCOutputInCommitment_get_offered(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_offered() { + boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr); return ret; } - public void set_offered(HTLCOutputInCommitment this_ptr, boolean val) { - bindings.HTLCOutputInCommitment_set_offered(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_offered(boolean val) { + bindings.HTLCOutputInCommitment_set_offered(this.ptr, val); } - public long get_amount_msat(HTLCOutputInCommitment this_ptr) { - long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_amount_msat() { + long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr); return ret; } - public void set_amount_msat(HTLCOutputInCommitment this_ptr, long val) { - bindings.HTLCOutputInCommitment_set_amount_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_amount_msat(long val) { + bindings.HTLCOutputInCommitment_set_amount_msat(this.ptr, val); } - public int get_cltv_expiry(HTLCOutputInCommitment this_ptr) { - int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_cltv_expiry() { + int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr); return ret; } - public void set_cltv_expiry(HTLCOutputInCommitment this_ptr, int val) { - bindings.HTLCOutputInCommitment_set_cltv_expiry(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry(int val) { + bindings.HTLCOutputInCommitment_set_cltv_expiry(this.ptr, val); } - public byte[] get_payment_hash(HTLCOutputInCommitment this_ptr) { - byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_hash() { + byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr); return ret; } - public void set_payment_hash(HTLCOutputInCommitment this_ptr, byte[] val) { - bindings.HTLCOutputInCommitment_set_payment_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_hash(byte[] val) { + bindings.HTLCOutputInCommitment_set_payment_hash(this.ptr, val); } public byte[] write(HTLCOutputInCommitment obj) { @@ -66,8 +63,10 @@ public class HTLCOutputInCommitment extends CommonBase { return ret; } - public HTLCOutputInCommitment(byte[] ser) { - super(bindings.HTLCOutputInCommitment_read(ser)); + public static HTLCOutputInCommitment constructor_read(byte[] ser) { + long ret = bindings.HTLCOutputInCommitment_read(ser); + HTLCOutputInCommitment ret_hu_conv = new HTLCOutputInCommitment(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/HTLCUpdate.java b/src/main/java/org/ldk/structs/HTLCUpdate.java index 9ffcbd0f..008ca802 100644 --- a/src/main/java/org/ldk/structs/HTLCUpdate.java +++ b/src/main/java/org/ldk/structs/HTLCUpdate.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class HTLCUpdate extends CommonBase { HTLCUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,9 +14,11 @@ public class HTLCUpdate extends CommonBase { bindings.HTLCUpdate_free(ptr); } - public HTLCUpdate(HTLCUpdate orig) { - super(bindings.HTLCUpdate_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static HTLCUpdate constructor_clone(HTLCUpdate orig) { + long ret = bindings.HTLCUpdate_clone(orig == null ? 0 : orig.ptr & ~1); + HTLCUpdate ret_hu_conv = new HTLCUpdate(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } public byte[] write(HTLCUpdate obj) { @@ -22,8 +27,10 @@ public class HTLCUpdate extends CommonBase { return ret; } - public HTLCUpdate(byte[] ser) { - super(bindings.HTLCUpdate_read(ser)); + public static HTLCUpdate constructor_read(byte[] ser) { + long ret = bindings.HTLCUpdate_read(ser); + HTLCUpdate ret_hu_conv = new HTLCUpdate(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java b/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java index e48709b7..4dd599a5 100644 --- a/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java +++ b/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class HolderCommitmentTransaction extends CommonBase { HolderCommitmentTransaction(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,40 +14,43 @@ public class HolderCommitmentTransaction extends CommonBase { bindings.HolderCommitmentTransaction_free(ptr); } - public HolderCommitmentTransaction(HolderCommitmentTransaction orig) { - super(bindings.HolderCommitmentTransaction_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static HolderCommitmentTransaction constructor_clone(HolderCommitmentTransaction orig) { + long ret = bindings.HolderCommitmentTransaction_clone(orig == null ? 0 : orig.ptr & ~1); + HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } // Skipped HolderCommitmentTransaction_get_unsigned_tx // Skipped HolderCommitmentTransaction_set_unsigned_tx - public byte[] get_counterparty_sig(HolderCommitmentTransaction this_ptr) { - byte[] ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_counterparty_sig() { + byte[] ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this.ptr); return ret; } - public void set_counterparty_sig(HolderCommitmentTransaction this_ptr, byte[] val) { - bindings.HolderCommitmentTransaction_set_counterparty_sig(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_counterparty_sig(byte[] val) { + bindings.HolderCommitmentTransaction_set_counterparty_sig(this.ptr, val); } - public int get_feerate_per_kw(HolderCommitmentTransaction this_ptr) { - int ret = bindings.HolderCommitmentTransaction_get_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_feerate_per_kw() { + int ret = bindings.HolderCommitmentTransaction_get_feerate_per_kw(this.ptr); return ret; } - public void set_feerate_per_kw(HolderCommitmentTransaction this_ptr, int val) { - bindings.HolderCommitmentTransaction_set_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_feerate_per_kw(int val) { + bindings.HolderCommitmentTransaction_set_feerate_per_kw(this.ptr, val); + } + + public void set_per_htlc(TwoTuple[] val) { + bindings.HolderCommitmentTransaction_set_per_htlc(this.ptr, Arrays.stream(val).mapToLong(arr_conv_42 -> /*TODO b*/0).toArray()); + /* TODO 2 TwoTuple */; } - // Skipped HolderCommitmentTransaction_set_per_htlc // Skipped HolderCommitmentTransaction_new_missing_holder_sig public TxCreationKeys trust_key_derivation() { - TxCreationKeys ret = new TxCreationKeys(null, bindings.HolderCommitmentTransaction_trust_key_derivation(this.ptr)); - return ret; + long ret = bindings.HolderCommitmentTransaction_trust_key_derivation(this.ptr); + TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret); + return ret_hu_conv; } public byte[] txid() { @@ -64,8 +70,10 @@ public class HolderCommitmentTransaction extends CommonBase { return ret; } - public HolderCommitmentTransaction(byte[] ser) { - super(bindings.HolderCommitmentTransaction_read(ser)); + public static HolderCommitmentTransaction constructor_read(byte[] ser) { + long ret = bindings.HolderCommitmentTransaction_read(ser); + HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/InMemoryChannelKeys.java b/src/main/java/org/ldk/structs/InMemoryChannelKeys.java index 5176b137..00825ab3 100644 --- a/src/main/java/org/ldk/structs/InMemoryChannelKeys.java +++ b/src/main/java/org/ldk/structs/InMemoryChannelKeys.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class InMemoryChannelKeys extends CommonBase { InMemoryChannelKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,81 +14,72 @@ public class InMemoryChannelKeys extends CommonBase { bindings.InMemoryChannelKeys_free(ptr); } - public InMemoryChannelKeys(InMemoryChannelKeys orig) { - super(bindings.InMemoryChannelKeys_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static InMemoryChannelKeys constructor_clone(InMemoryChannelKeys orig) { + long ret = bindings.InMemoryChannelKeys_clone(orig == null ? 0 : orig.ptr & ~1); + InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_funding_key(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_funding_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_funding_key() { + byte[] ret = bindings.InMemoryChannelKeys_get_funding_key(this.ptr); return ret; } - public void set_funding_key(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_funding_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_key(byte[] val) { + bindings.InMemoryChannelKeys_set_funding_key(this.ptr, val); } - public byte[] get_revocation_base_key(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_revocation_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_revocation_base_key() { + byte[] ret = bindings.InMemoryChannelKeys_get_revocation_base_key(this.ptr); return ret; } - public void set_revocation_base_key(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_revocation_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_revocation_base_key(byte[] val) { + bindings.InMemoryChannelKeys_set_revocation_base_key(this.ptr, val); } - public byte[] get_payment_key(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_key() { + byte[] ret = bindings.InMemoryChannelKeys_get_payment_key(this.ptr); return ret; } - public void set_payment_key(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_key(byte[] val) { + bindings.InMemoryChannelKeys_set_payment_key(this.ptr, val); } - public byte[] get_delayed_payment_base_key(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_delayed_payment_base_key() { + byte[] ret = bindings.InMemoryChannelKeys_get_delayed_payment_base_key(this.ptr); return ret; } - public void set_delayed_payment_base_key(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_delayed_payment_base_key(byte[] val) { + bindings.InMemoryChannelKeys_set_delayed_payment_base_key(this.ptr, val); } - public byte[] get_htlc_base_key(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_htlc_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_htlc_base_key() { + byte[] ret = bindings.InMemoryChannelKeys_get_htlc_base_key(this.ptr); return ret; } - public void set_htlc_base_key(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_htlc_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_base_key(byte[] val) { + bindings.InMemoryChannelKeys_set_htlc_base_key(this.ptr, val); } - public byte[] get_commitment_seed(InMemoryChannelKeys this_ptr) { - byte[] ret = bindings.InMemoryChannelKeys_get_commitment_seed(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_commitment_seed() { + byte[] ret = bindings.InMemoryChannelKeys_get_commitment_seed(this.ptr); return ret; } - public void set_commitment_seed(InMemoryChannelKeys this_ptr, byte[] val) { - bindings.InMemoryChannelKeys_set_commitment_seed(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_commitment_seed(byte[] val) { + bindings.InMemoryChannelKeys_set_commitment_seed(this.ptr, val); } // Skipped InMemoryChannelKeys_new public ChannelPublicKeys counterparty_pubkeys() { - ChannelPublicKeys ret = new ChannelPublicKeys(null, bindings.InMemoryChannelKeys_counterparty_pubkeys(this.ptr)); - return ret; + long ret = bindings.InMemoryChannelKeys_counterparty_pubkeys(this.ptr); + ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret); + return ret_hu_conv; } public short counterparty_selected_contest_delay() { @@ -99,9 +93,10 @@ public class InMemoryChannelKeys extends CommonBase { } public ChannelKeys as_ChannelKeys() { - ChannelKeys ret = new ChannelKeys(null, bindings.InMemoryChannelKeys_as_ChannelKeys(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.InMemoryChannelKeys_as_ChannelKeys(this.ptr); + ChannelKeys ret_hu_conv = new ChannelKeys(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } public byte[] write(InMemoryChannelKeys obj) { @@ -110,8 +105,10 @@ public class InMemoryChannelKeys extends CommonBase { return ret; } - public InMemoryChannelKeys(byte[] ser) { - super(bindings.InMemoryChannelKeys_read(ser)); + public static InMemoryChannelKeys constructor_read(byte[] ser) { + long ret = bindings.InMemoryChannelKeys_read(ser); + InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Init.java b/src/main/java/org/ldk/structs/Init.java index 3c998bd9..37f87de7 100644 --- a/src/main/java/org/ldk/structs/Init.java +++ b/src/main/java/org/ldk/structs/Init.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Init extends CommonBase { Init(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,9 +14,11 @@ public class Init extends CommonBase { bindings.Init_free(ptr); } - public Init(Init orig) { - super(bindings.Init_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static Init constructor_clone(Init orig) { + long ret = bindings.Init_clone(orig == null ? 0 : orig.ptr & ~1); + Init ret_hu_conv = new Init(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } public byte[] write(Init obj) { @@ -22,8 +27,10 @@ public class Init extends CommonBase { return ret; } - public Init(byte[] ser) { - super(bindings.Init_read(ser)); + public static Init constructor_read(byte[] ser) { + long ret = bindings.Init_read(ser); + Init ret_hu_conv = new Init(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/InitFeatures.java b/src/main/java/org/ldk/structs/InitFeatures.java index 4310438e..c6184f09 100644 --- a/src/main/java/org/ldk/structs/InitFeatures.java +++ b/src/main/java/org/ldk/structs/InitFeatures.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class InitFeatures extends CommonBase { InitFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/KeysInterface.java b/src/main/java/org/ldk/structs/KeysInterface.java index 22ea9eb3..589793e4 100644 --- a/src/main/java/org/ldk/structs/KeysInterface.java +++ b/src/main/java/org/ldk/structs/KeysInterface.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class KeysInterface extends CommonBase { KeysInterface(Object _dummy, long ptr) { super(ptr); } public KeysInterface(bindings.LDKKeysInterface arg) { @@ -31,9 +33,10 @@ public class KeysInterface extends CommonBase { } public ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis) { - ChannelKeys ret = new ChannelKeys(null, bindings.KeysInterface_get_channel_keys(this.ptr, inbound, channel_value_satoshis)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.KeysInterface_get_channel_keys(this.ptr, inbound, channel_value_satoshis); + ChannelKeys ret_hu_conv = new ChannelKeys(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } public byte[] get_secure_random_bytes() { diff --git a/src/main/java/org/ldk/structs/KeysManager.java b/src/main/java/org/ldk/structs/KeysManager.java index da59e435..5269c40d 100644 --- a/src/main/java/org/ldk/structs/KeysManager.java +++ b/src/main/java/org/ldk/structs/KeysManager.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class KeysManager extends CommonBase { KeysManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,19 +14,23 @@ public class KeysManager extends CommonBase { bindings.KeysManager_free(ptr); } - public KeysManager(byte[] seed, LDKNetwork network, long starting_time_secs, int starting_time_nanos) { - super(bindings.KeysManager_new(seed, network, starting_time_secs, starting_time_nanos)); + public static KeysManager constructor_new(byte[] seed, LDKNetwork network, long starting_time_secs, int starting_time_nanos) { + long ret = bindings.KeysManager_new(seed, network, starting_time_secs, starting_time_nanos); + KeysManager ret_hu_conv = new KeysManager(null, ret); + return ret_hu_conv; } public InMemoryChannelKeys derive_channel_keys(long channel_value_satoshis, long params_1, long params_2) { - InMemoryChannelKeys ret = new InMemoryChannelKeys(null, bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, params_1, params_2)); - return ret; + long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, params_1, params_2); + InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret); + return ret_hu_conv; } public KeysInterface as_KeysInterface() { - KeysInterface ret = new KeysInterface(null, bindings.KeysManager_as_KeysInterface(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.KeysManager_as_KeysInterface(this.ptr); + KeysInterface ret_hu_conv = new KeysInterface(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/LightningError.java b/src/main/java/org/ldk/structs/LightningError.java index 6574e77b..be3d7593 100644 --- a/src/main/java/org/ldk/structs/LightningError.java +++ b/src/main/java/org/ldk/structs/LightningError.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class LightningError extends CommonBase { LightningError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,10 +14,13 @@ public class LightningError extends CommonBase { bindings.LightningError_free(ptr); } - // Skipped LightningError_get_err - public void set_err(LightningError this_ptr, byte[] val) { - bindings.LightningError_set_err(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public String get_err() { + String ret = bindings.LightningError_get_err(this.ptr); + return ret; + } + + public void set_err(byte[] val) { + bindings.LightningError_set_err(this.ptr, val); } // Skipped LightningError_get_action diff --git a/src/main/java/org/ldk/structs/LockedNetworkGraph.java b/src/main/java/org/ldk/structs/LockedNetworkGraph.java index 614a5d96..55f1dad8 100644 --- a/src/main/java/org/ldk/structs/LockedNetworkGraph.java +++ b/src/main/java/org/ldk/structs/LockedNetworkGraph.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class LockedNetworkGraph extends CommonBase implements AutoCloseable { LockedNetworkGraph(Object _dummy, long ptr) { super(ptr); } @Override public void close() { @@ -10,8 +13,9 @@ public class LockedNetworkGraph extends CommonBase implements AutoCloseable { } public NetworkGraph graph() { - NetworkGraph ret = new NetworkGraph(null, bindings.LockedNetworkGraph_graph(this.ptr)); - return ret; + long ret = bindings.LockedNetworkGraph_graph(this.ptr); + NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Logger.java b/src/main/java/org/ldk/structs/Logger.java index abf5a632..1daafb3b 100644 --- a/src/main/java/org/ldk/structs/Logger.java +++ b/src/main/java/org/ldk/structs/Logger.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Logger extends CommonBase { Logger(Object _dummy, long ptr) { super(ptr); } public Logger(bindings.LDKLogger arg) { diff --git a/src/main/java/org/ldk/structs/MessageHandler.java b/src/main/java/org/ldk/structs/MessageHandler.java index 736bac89..d2f3892c 100644 --- a/src/main/java/org/ldk/structs/MessageHandler.java +++ b/src/main/java/org/ldk/structs/MessageHandler.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class MessageHandler extends CommonBase { MessageHandler(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,36 +14,36 @@ public class MessageHandler extends CommonBase { bindings.MessageHandler_free(ptr); } - public ChannelMessageHandler get_chan_handler(MessageHandler this_ptr) { - ChannelMessageHandler ret = new ChannelMessageHandler(null, bindings.MessageHandler_get_chan_handler(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelMessageHandler get_chan_handler() { + long ret = bindings.MessageHandler_get_chan_handler(this.ptr); + ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_chan_handler(MessageHandler this_ptr, ChannelMessageHandler val) { - bindings.MessageHandler_set_chan_handler(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_chan_handler(ChannelMessageHandler val) { + bindings.MessageHandler_set_chan_handler(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public RoutingMessageHandler get_route_handler(MessageHandler this_ptr) { - RoutingMessageHandler ret = new RoutingMessageHandler(null, bindings.MessageHandler_get_route_handler(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - ret.ptrs_to.add(this); - this.ptrs_to.add(this_ptr); - return ret; + public RoutingMessageHandler get_route_handler() { + long ret = bindings.MessageHandler_get_route_handler(this.ptr); + RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_route_handler(MessageHandler this_ptr, RoutingMessageHandler val) { - bindings.MessageHandler_set_route_handler(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr); - this.ptrs_to.add(this_ptr); + public void set_route_handler(RoutingMessageHandler val) { + bindings.MessageHandler_set_route_handler(this.ptr, val == null ? 0 : val.ptr); this.ptrs_to.add(val); } - public MessageHandler(ChannelMessageHandler chan_handler_arg, RoutingMessageHandler route_handler_arg) { - super(bindings.MessageHandler_new(chan_handler_arg == null ? 0 : chan_handler_arg.ptr, route_handler_arg == null ? 0 : route_handler_arg.ptr)); - this.ptrs_to.add(chan_handler_arg); - this.ptrs_to.add(route_handler_arg); + public static MessageHandler constructor_new(ChannelMessageHandler chan_handler_arg, RoutingMessageHandler route_handler_arg) { + long ret = bindings.MessageHandler_new(chan_handler_arg == null ? 0 : chan_handler_arg.ptr, route_handler_arg == null ? 0 : route_handler_arg.ptr); + MessageHandler ret_hu_conv = new MessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(chan_handler_arg); + ret_hu_conv.ptrs_to.add(route_handler_arg); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/MessageSendEvent.java b/src/main/java/org/ldk/structs/MessageSendEvent.java new file mode 100644 index 00000000..460ec3e8 --- /dev/null +++ b/src/main/java/org/ldk/structs/MessageSendEvent.java @@ -0,0 +1,158 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class MessageSendEvent extends CommonBase { + private MessageSendEvent(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static MessageSendEvent constr_from_ptr(long ptr) { + bindings.LDKMessageSendEvent raw_val = bindings.LDKMessageSendEvent_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendAcceptChannel.class) { + return new SendAcceptChannel(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendOpenChannel.class) { + return new SendOpenChannel(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingCreated.class) { + return new SendFundingCreated(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingSigned.class) { + return new SendFundingSigned(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingLocked.class) { + return new SendFundingLocked(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendAnnouncementSignatures.class) { + return new SendAnnouncementSignatures(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.UpdateHTLCs.class) { + return new UpdateHTLCs(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendRevokeAndACK.class) { + return new SendRevokeAndACK(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendClosingSigned.class) { + return new SendClosingSigned(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendShutdown.class) { + return new SendShutdown(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelReestablish.class) { + return new SendChannelReestablish(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement.class) { + return new BroadcastChannelAnnouncement(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement.class) { + return new BroadcastNodeAnnouncement(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastChannelUpdate.class) { + return new BroadcastChannelUpdate(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.HandleError.class) { + return new HandleError(null, ptr); + } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate.class) { + return new PaymentFailureNetworkUpdate(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class SendAcceptChannel extends MessageSendEvent { + public byte[] node_id; + public AcceptChannel msg; + private SendAcceptChannel(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendOpenChannel extends MessageSendEvent { + public byte[] node_id; + public OpenChannel msg; + private SendOpenChannel(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendFundingCreated extends MessageSendEvent { + public byte[] node_id; + public FundingCreated msg; + private SendFundingCreated(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendFundingSigned extends MessageSendEvent { + public byte[] node_id; + public FundingSigned msg; + private SendFundingSigned(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendFundingLocked extends MessageSendEvent { + public byte[] node_id; + public FundingLocked msg; + private SendFundingLocked(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendAnnouncementSignatures extends MessageSendEvent { + public byte[] node_id; + public AnnouncementSignatures msg; + private SendAnnouncementSignatures(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class UpdateHTLCs extends MessageSendEvent { + public byte[] node_id; + public CommitmentUpdate updates; + private UpdateHTLCs(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendRevokeAndACK extends MessageSendEvent { + public byte[] node_id; + public RevokeAndACK msg; + private SendRevokeAndACK(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendClosingSigned extends MessageSendEvent { + public byte[] node_id; + public ClosingSigned msg; + private SendClosingSigned(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendShutdown extends MessageSendEvent { + public byte[] node_id; + public Shutdown msg; + private SendShutdown(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class SendChannelReestablish extends MessageSendEvent { + public byte[] node_id; + public ChannelReestablish msg; + private SendChannelReestablish(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class BroadcastChannelAnnouncement extends MessageSendEvent { + public ChannelAnnouncement msg; + public ChannelUpdate update_msg; + private BroadcastChannelAnnouncement(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class BroadcastNodeAnnouncement extends MessageSendEvent { + public NodeAnnouncement msg; + private BroadcastNodeAnnouncement(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class BroadcastChannelUpdate extends MessageSendEvent { + public ChannelUpdate msg; + private BroadcastChannelUpdate(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class HandleError extends MessageSendEvent { + public byte[] node_id; + public ErrorAction action; + private HandleError(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class PaymentFailureNetworkUpdate extends MessageSendEvent { + public HTLCFailChannelUpdate update; + private PaymentFailureNetworkUpdate(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/MessageSendEventsProvider.java b/src/main/java/org/ldk/structs/MessageSendEventsProvider.java index 6af563b3..6073cb64 100644 --- a/src/main/java/org/ldk/structs/MessageSendEventsProvider.java +++ b/src/main/java/org/ldk/structs/MessageSendEventsProvider.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class MessageSendEventsProvider extends CommonBase { MessageSendEventsProvider(Object _dummy, long ptr) { super(ptr); } public MessageSendEventsProvider(bindings.LDKMessageSendEventsProvider arg) { @@ -15,5 +17,15 @@ public class MessageSendEventsProvider extends CommonBase { bindings.MessageSendEventsProvider_free(ptr); super.finalize(); } - // Skipped MessageSendEventsProvider_get_and_clear_pending_msg_events + public MessageSendEvent[] get_and_clear_pending_msg_events() { + long[] ret = bindings.MessageSendEventsProvider_get_and_clear_pending_msg_events(this.ptr); + MessageSendEvent[] arr_conv_18_arr = new MessageSendEvent[ret.length]; + for (int s = 0; s < ret.length; s++) { + long arr_conv_18 = ret[s]; + MessageSendEvent arr_conv_18_hu_conv = MessageSendEvent.constr_from_ptr(arr_conv_18); + arr_conv_18_arr[s] = arr_conv_18_hu_conv; + } + return arr_conv_18_arr; + } + } diff --git a/src/main/java/org/ldk/structs/MonitorEvent.java b/src/main/java/org/ldk/structs/MonitorEvent.java index 35adb837..030ef699 100644 --- a/src/main/java/org/ldk/structs/MonitorEvent.java +++ b/src/main/java/org/ldk/structs/MonitorEvent.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class MonitorEvent extends CommonBase { MonitorEvent(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/MonitorUpdateError.java b/src/main/java/org/ldk/structs/MonitorUpdateError.java index bd0eefc8..4537e5fa 100644 --- a/src/main/java/org/ldk/structs/MonitorUpdateError.java +++ b/src/main/java/org/ldk/structs/MonitorUpdateError.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class MonitorUpdateError extends CommonBase { MonitorUpdateError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/NetAddress.java b/src/main/java/org/ldk/structs/NetAddress.java new file mode 100644 index 00000000..73c93ae1 --- /dev/null +++ b/src/main/java/org/ldk/structs/NetAddress.java @@ -0,0 +1,55 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class NetAddress extends CommonBase { + private NetAddress(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static NetAddress constr_from_ptr(long ptr) { + bindings.LDKNetAddress raw_val = bindings.LDKNetAddress_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKNetAddress.IPv4.class) { + return new IPv4(null, ptr); + } + if (raw_val.getClass() == bindings.LDKNetAddress.IPv6.class) { + return new IPv6(null, ptr); + } + if (raw_val.getClass() == bindings.LDKNetAddress.OnionV2.class) { + return new OnionV2(null, ptr); + } + if (raw_val.getClass() == bindings.LDKNetAddress.OnionV3.class) { + return new OnionV3(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class IPv4 extends NetAddress { + public byte[] addr; + public short port; + private IPv4(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class IPv6 extends NetAddress { + public byte[] addr; + public short port; + private IPv6(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class OnionV2 extends NetAddress { + public byte[] addr; + public short port; + private OnionV2(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class OnionV3 extends NetAddress { + public byte[] ed25519_pubkey; + public short checksum; + public byte version; + public short port; + private OnionV3(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java index bb976f65..d5d4780e 100644 --- a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java +++ b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NetGraphMsgHandler extends CommonBase { NetGraphMsgHandler(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,22 +14,26 @@ public class NetGraphMsgHandler extends CommonBase { bindings.NetGraphMsgHandler_free(ptr); } - public NetGraphMsgHandler(Access chain_access, Logger logger) { - super(bindings.NetGraphMsgHandler_new(chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr)); - this.ptrs_to.add(chain_access); - this.ptrs_to.add(logger); + public static NetGraphMsgHandler constructor_new(Access chain_access, Logger logger) { + long ret = bindings.NetGraphMsgHandler_new(chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr); + NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret); + ret_hu_conv.ptrs_to.add(chain_access); + ret_hu_conv.ptrs_to.add(logger); + return ret_hu_conv; } // Skipped NetGraphMsgHandler_from_net_graph public LockedNetworkGraph read_locked_graph() { - LockedNetworkGraph ret = new LockedNetworkGraph(null, bindings.NetGraphMsgHandler_read_locked_graph(this.ptr)); - return ret; + long ret = bindings.NetGraphMsgHandler_read_locked_graph(this.ptr); + LockedNetworkGraph ret_hu_conv = new LockedNetworkGraph(null, ret); + return ret_hu_conv; } public RoutingMessageHandler as_RoutingMessageHandler() { - RoutingMessageHandler ret = new RoutingMessageHandler(null, bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr)); - ret.ptrs_to.add(this); - return ret; + long ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr); + RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/NetworkGraph.java b/src/main/java/org/ldk/structs/NetworkGraph.java index 79647091..1bb8f5d8 100644 --- a/src/main/java/org/ldk/structs/NetworkGraph.java +++ b/src/main/java/org/ldk/structs/NetworkGraph.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NetworkGraph extends CommonBase { NetworkGraph(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -17,12 +20,16 @@ public class NetworkGraph extends CommonBase { return ret; } - public NetworkGraph(byte[] ser) { - super(bindings.NetworkGraph_read(ser)); + public static NetworkGraph constructor_read(byte[] ser) { + long ret = bindings.NetworkGraph_read(ser); + NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); + return ret_hu_conv; } - public NetworkGraph() { - super(bindings.NetworkGraph_new()); + public static NetworkGraph constructor_new() { + long ret = bindings.NetworkGraph_new(); + NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); + return ret_hu_conv; } public void close_channel_from_update(long short_channel_id, boolean is_permanent) { diff --git a/src/main/java/org/ldk/structs/NodeAnnouncement.java b/src/main/java/org/ldk/structs/NodeAnnouncement.java index f65da9b8..f75a8c3d 100644 --- a/src/main/java/org/ldk/structs/NodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/NodeAnnouncement.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NodeAnnouncement extends CommonBase { NodeAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,37 +14,38 @@ public class NodeAnnouncement extends CommonBase { bindings.NodeAnnouncement_free(ptr); } - public NodeAnnouncement(NodeAnnouncement orig) { - super(bindings.NodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static NodeAnnouncement constructor_clone(NodeAnnouncement orig) { + long ret = bindings.NodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1); + NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_signature(NodeAnnouncement this_ptr) { - byte[] ret = bindings.NodeAnnouncement_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_signature() { + byte[] ret = bindings.NodeAnnouncement_get_signature(this.ptr); return ret; } - public void set_signature(NodeAnnouncement this_ptr, byte[] val) { - bindings.NodeAnnouncement_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_signature(byte[] val) { + bindings.NodeAnnouncement_set_signature(this.ptr, val); } - public UnsignedNodeAnnouncement get_contents(NodeAnnouncement this_ptr) { - UnsignedNodeAnnouncement ret = new UnsignedNodeAnnouncement(null, bindings.NodeAnnouncement_get_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public UnsignedNodeAnnouncement get_contents() { + long ret = bindings.NodeAnnouncement_get_contents(this.ptr); + UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); + return ret_hu_conv; } - public void set_contents(NodeAnnouncement this_ptr, UnsignedNodeAnnouncement val) { - bindings.NodeAnnouncement_set_contents(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_contents(UnsignedNodeAnnouncement val) { + bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public NodeAnnouncement(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) { - super(bindings.NodeAnnouncement_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1)); - this.ptrs_to.add(contents_arg); + public static NodeAnnouncement constructor_new(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) { + long ret = bindings.NodeAnnouncement_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1); + NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(contents_arg); + return ret_hu_conv; } public byte[] write(NodeAnnouncement obj) { @@ -50,8 +54,10 @@ public class NodeAnnouncement extends CommonBase { return ret; } - public NodeAnnouncement(byte[] ser) { - super(bindings.NodeAnnouncement_read(ser)); + public static NodeAnnouncement constructor_read(byte[] ser) { + long ret = bindings.NodeAnnouncement_read(ser); + NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java index 9edaf2f1..e426a0e2 100644 --- a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java +++ b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NodeAnnouncementInfo extends CommonBase { NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,56 +14,53 @@ public class NodeAnnouncementInfo extends CommonBase { bindings.NodeAnnouncementInfo_free(ptr); } - public NodeFeatures get_features(NodeAnnouncementInfo this_ptr) { - NodeFeatures ret = new NodeFeatures(null, bindings.NodeAnnouncementInfo_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public NodeFeatures get_features() { + long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr); + NodeFeatures ret_hu_conv = new NodeFeatures(null, ret); + return ret_hu_conv; } // Skipped NodeAnnouncementInfo_set_features - public int get_last_update(NodeAnnouncementInfo this_ptr) { - int ret = bindings.NodeAnnouncementInfo_get_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_last_update() { + int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr); return ret; } - public void set_last_update(NodeAnnouncementInfo this_ptr, int val) { - bindings.NodeAnnouncementInfo_set_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_last_update(int val) { + bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val); } - public byte[] get_rgb(NodeAnnouncementInfo this_ptr) { - byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_rgb() { + byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr); return ret; } - public void set_rgb(NodeAnnouncementInfo this_ptr, byte[] val) { - bindings.NodeAnnouncementInfo_set_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_rgb(byte[] val) { + bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val); } - public byte[] get_alias(NodeAnnouncementInfo this_ptr) { - byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_alias() { + byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr); return ret; } - public void set_alias(NodeAnnouncementInfo this_ptr, byte[] val) { - bindings.NodeAnnouncementInfo_set_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_alias(byte[] val) { + bindings.NodeAnnouncementInfo_set_alias(this.ptr, val); } - // Skipped NodeAnnouncementInfo_set_addresses - public NodeAnnouncement get_announcement_message(NodeAnnouncementInfo this_ptr) { - NodeAnnouncement ret = new NodeAnnouncement(null, bindings.NodeAnnouncementInfo_get_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public void set_addresses(NetAddress[] val) { + bindings.NodeAnnouncementInfo_set_addresses(this.ptr, Arrays.stream(val).mapToLong(arr_conv_12 -> arr_conv_12.conv_to_c()).toArray()); + /* TODO 2 NetAddress */; + } + + public NodeAnnouncement get_announcement_message() { + long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr); + NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret); + return ret_hu_conv; } - public void set_announcement_message(NodeAnnouncementInfo this_ptr, NodeAnnouncement val) { - bindings.NodeAnnouncementInfo_set_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_announcement_message(NodeAnnouncement val) { + bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } @@ -71,8 +71,10 @@ public class NodeAnnouncementInfo extends CommonBase { return ret; } - public NodeAnnouncementInfo(byte[] ser) { - super(bindings.NodeAnnouncementInfo_read(ser)); + public static NodeAnnouncementInfo constructor_read(byte[] ser) { + long ret = bindings.NodeAnnouncementInfo_read(ser); + NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/NodeFeatures.java b/src/main/java/org/ldk/structs/NodeFeatures.java index a9016680..71281dd7 100644 --- a/src/main/java/org/ldk/structs/NodeFeatures.java +++ b/src/main/java/org/ldk/structs/NodeFeatures.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NodeFeatures extends CommonBase { NodeFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/NodeInfo.java b/src/main/java/org/ldk/structs/NodeInfo.java index 7d797e15..bc453609 100644 --- a/src/main/java/org/ldk/structs/NodeInfo.java +++ b/src/main/java/org/ldk/structs/NodeInfo.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NodeInfo extends CommonBase { NodeInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,23 +14,25 @@ public class NodeInfo extends CommonBase { bindings.NodeInfo_free(ptr); } - // Skipped NodeInfo_set_channels - public RoutingFees get_lowest_inbound_channel_fees(NodeInfo this_ptr) { - RoutingFees ret = new RoutingFees(null, bindings.NodeInfo_get_lowest_inbound_channel_fees(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public void set_channels(long[] val) { + bindings.NodeInfo_set_channels(this.ptr, val); + } + + public RoutingFees get_lowest_inbound_channel_fees() { + long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr); + RoutingFees ret_hu_conv = new RoutingFees(null, ret); + return ret_hu_conv; } - public void set_lowest_inbound_channel_fees(NodeInfo this_ptr, RoutingFees val) { - bindings.NodeInfo_set_lowest_inbound_channel_fees(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_lowest_inbound_channel_fees(RoutingFees val) { + bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public NodeAnnouncementInfo get_announcement_info(NodeInfo this_ptr) { - NodeAnnouncementInfo ret = new NodeAnnouncementInfo(null, bindings.NodeInfo_get_announcement_info(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public NodeAnnouncementInfo get_announcement_info() { + long ret = bindings.NodeInfo_get_announcement_info(this.ptr); + NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret); + return ret_hu_conv; } // Skipped NodeInfo_set_announcement_info @@ -38,8 +43,10 @@ public class NodeInfo extends CommonBase { return ret; } - public NodeInfo(byte[] ser) { - super(bindings.NodeInfo_read(ser)); + public static NodeInfo constructor_read(byte[] ser) { + long ret = bindings.NodeInfo_read(ser); + NodeInfo ret_hu_conv = new NodeInfo(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/OpenChannel.java b/src/main/java/org/ldk/structs/OpenChannel.java index 8c550ed8..8dfe7bf5 100644 --- a/src/main/java/org/ldk/structs/OpenChannel.java +++ b/src/main/java/org/ldk/structs/OpenChannel.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class OpenChannel extends CommonBase { OpenChannel(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,207 +14,173 @@ public class OpenChannel extends CommonBase { bindings.OpenChannel_free(ptr); } - public OpenChannel(OpenChannel orig) { - super(bindings.OpenChannel_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static OpenChannel constructor_clone(OpenChannel orig) { + long ret = bindings.OpenChannel_clone(orig == null ? 0 : orig.ptr & ~1); + OpenChannel ret_hu_conv = new OpenChannel(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.OpenChannel_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.OpenChannel_set_chain_hash(this.ptr, val); } - public byte[] get_temporary_channel_id(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_temporary_channel_id() { + byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr); return ret; } - public void set_temporary_channel_id(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_temporary_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_temporary_channel_id(byte[] val) { + bindings.OpenChannel_set_temporary_channel_id(this.ptr, val); } - public long get_funding_satoshis(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_funding_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_funding_satoshis() { + long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr); return ret; } - public void set_funding_satoshis(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_funding_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_satoshis(long val) { + bindings.OpenChannel_set_funding_satoshis(this.ptr, val); } - public long get_push_msat(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_push_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_push_msat() { + long ret = bindings.OpenChannel_get_push_msat(this.ptr); return ret; } - public void set_push_msat(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_push_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_push_msat(long val) { + bindings.OpenChannel_set_push_msat(this.ptr, val); } - public long get_dust_limit_satoshis(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_dust_limit_satoshis() { + long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr); return ret; } - public void set_dust_limit_satoshis(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_dust_limit_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_dust_limit_satoshis(long val) { + bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val); } - public long get_max_htlc_value_in_flight_msat(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_max_htlc_value_in_flight_msat() { + long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr); return ret; } - public void set_max_htlc_value_in_flight_msat(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_htlc_value_in_flight_msat(long val) { + bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val); } - public long get_channel_reserve_satoshis(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_channel_reserve_satoshis() { + long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr); return ret; } - public void set_channel_reserve_satoshis(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_channel_reserve_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_reserve_satoshis(long val) { + bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val); } - public long get_htlc_minimum_msat(OpenChannel this_ptr) { - long ret = bindings.OpenChannel_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_minimum_msat() { + long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(OpenChannel this_ptr, long val) { - bindings.OpenChannel_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_minimum_msat(long val) { + bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val); } - public int get_feerate_per_kw(OpenChannel this_ptr) { - int ret = bindings.OpenChannel_get_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_feerate_per_kw() { + int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr); return ret; } - public void set_feerate_per_kw(OpenChannel this_ptr, int val) { - bindings.OpenChannel_set_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_feerate_per_kw(int val) { + bindings.OpenChannel_set_feerate_per_kw(this.ptr, val); } - public short get_to_self_delay(OpenChannel this_ptr) { - short ret = bindings.OpenChannel_get_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_to_self_delay() { + short ret = bindings.OpenChannel_get_to_self_delay(this.ptr); return ret; } - public void set_to_self_delay(OpenChannel this_ptr, short val) { - bindings.OpenChannel_set_to_self_delay(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_to_self_delay(short val) { + bindings.OpenChannel_set_to_self_delay(this.ptr, val); } - public short get_max_accepted_htlcs(OpenChannel this_ptr) { - short ret = bindings.OpenChannel_get_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_max_accepted_htlcs() { + short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr); return ret; } - public void set_max_accepted_htlcs(OpenChannel this_ptr, short val) { - bindings.OpenChannel_set_max_accepted_htlcs(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_max_accepted_htlcs(short val) { + bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val); } - public byte[] get_funding_pubkey(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_funding_pubkey() { + byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr); return ret; } - public void set_funding_pubkey(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_funding_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_funding_pubkey(byte[] val) { + bindings.OpenChannel_set_funding_pubkey(this.ptr, val); } - public byte[] get_revocation_basepoint(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_revocation_basepoint() { + byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr); return ret; } - public void set_revocation_basepoint(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_revocation_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_revocation_basepoint(byte[] val) { + bindings.OpenChannel_set_revocation_basepoint(this.ptr, val); } - public byte[] get_payment_point(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_point() { + byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr); return ret; } - public void set_payment_point(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_payment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_point(byte[] val) { + bindings.OpenChannel_set_payment_point(this.ptr, val); } - public byte[] get_delayed_payment_basepoint(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_delayed_payment_basepoint() { + byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr); return ret; } - public void set_delayed_payment_basepoint(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_delayed_payment_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_delayed_payment_basepoint(byte[] val) { + bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, val); } - public byte[] get_htlc_basepoint(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_htlc_basepoint() { + byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr); return ret; } - public void set_htlc_basepoint(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_htlc_basepoint(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_basepoint(byte[] val) { + bindings.OpenChannel_set_htlc_basepoint(this.ptr, val); } - public byte[] get_first_per_commitment_point(OpenChannel this_ptr) { - byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_first_per_commitment_point() { + byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr); return ret; } - public void set_first_per_commitment_point(OpenChannel this_ptr, byte[] val) { - bindings.OpenChannel_set_first_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_first_per_commitment_point(byte[] val) { + bindings.OpenChannel_set_first_per_commitment_point(this.ptr, val); } - public byte get_channel_flags(OpenChannel this_ptr) { - byte ret = bindings.OpenChannel_get_channel_flags(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte get_channel_flags() { + byte ret = bindings.OpenChannel_get_channel_flags(this.ptr); return ret; } - public void set_channel_flags(OpenChannel this_ptr, byte val) { - bindings.OpenChannel_set_channel_flags(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_flags(byte val) { + bindings.OpenChannel_set_channel_flags(this.ptr, val); } public byte[] write(OpenChannel obj) { @@ -220,8 +189,10 @@ public class OpenChannel extends CommonBase { return ret; } - public OpenChannel(byte[] ser) { - super(bindings.OpenChannel_read(ser)); + public static OpenChannel constructor_read(byte[] ser) { + long ret = bindings.OpenChannel_read(ser); + OpenChannel ret_hu_conv = new OpenChannel(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/OutPoint.java b/src/main/java/org/ldk/structs/OutPoint.java index a980f095..0d9085c9 100644 --- a/src/main/java/org/ldk/structs/OutPoint.java +++ b/src/main/java/org/ldk/structs/OutPoint.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class OutPoint extends CommonBase { OutPoint(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class OutPoint extends CommonBase { bindings.OutPoint_free(ptr); } - public OutPoint(OutPoint orig) { - super(bindings.OutPoint_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static OutPoint constructor_clone(OutPoint orig) { + long ret = bindings.OutPoint_clone(orig == null ? 0 : orig.ptr & ~1); + OutPoint ret_hu_conv = new OutPoint(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_txid(OutPoint this_ptr) { - byte[] ret = bindings.OutPoint_get_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_txid() { + byte[] ret = bindings.OutPoint_get_txid(this.ptr); return ret; } - public void set_txid(OutPoint this_ptr, byte[] val) { - bindings.OutPoint_set_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_txid(byte[] val) { + bindings.OutPoint_set_txid(this.ptr, val); } - public short get_index(OutPoint this_ptr) { - short ret = bindings.OutPoint_get_index(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_index() { + short ret = bindings.OutPoint_get_index(this.ptr); return ret; } - public void set_index(OutPoint this_ptr, short val) { - bindings.OutPoint_set_index(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_index(short val) { + bindings.OutPoint_set_index(this.ptr, val); } - public OutPoint(byte[] txid_arg, short index_arg) { - super(bindings.OutPoint_new(txid_arg, index_arg)); + public static OutPoint constructor_new(byte[] txid_arg, short index_arg) { + long ret = bindings.OutPoint_new(txid_arg, index_arg); + OutPoint ret_hu_conv = new OutPoint(null, ret); + return ret_hu_conv; } public byte[] to_channel_id() { @@ -53,8 +56,10 @@ public class OutPoint extends CommonBase { return ret; } - public OutPoint(byte[] ser) { - super(bindings.OutPoint_read(ser)); + public static OutPoint constructor_read(byte[] ser) { + long ret = bindings.OutPoint_read(ser); + OutPoint ret_hu_conv = new OutPoint(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/PaymentSendFailure.java b/src/main/java/org/ldk/structs/PaymentSendFailure.java index 1df65ed0..5db694ee 100644 --- a/src/main/java/org/ldk/structs/PaymentSendFailure.java +++ b/src/main/java/org/ldk/structs/PaymentSendFailure.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class PaymentSendFailure extends CommonBase { PaymentSendFailure(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/org/ldk/structs/PeerHandleError.java b/src/main/java/org/ldk/structs/PeerHandleError.java index 6586e91c..a7240bc6 100644 --- a/src/main/java/org/ldk/structs/PeerHandleError.java +++ b/src/main/java/org/ldk/structs/PeerHandleError.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class PeerHandleError extends CommonBase { PeerHandleError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,19 +14,19 @@ public class PeerHandleError extends CommonBase { bindings.PeerHandleError_free(ptr); } - public boolean get_no_connection_possible(PeerHandleError this_ptr) { - boolean ret = bindings.PeerHandleError_get_no_connection_possible(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_no_connection_possible() { + boolean ret = bindings.PeerHandleError_get_no_connection_possible(this.ptr); return ret; } - public void set_no_connection_possible(PeerHandleError this_ptr, boolean val) { - bindings.PeerHandleError_set_no_connection_possible(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_no_connection_possible(boolean val) { + bindings.PeerHandleError_set_no_connection_possible(this.ptr, val); } - public PeerHandleError(boolean no_connection_possible_arg) { - super(bindings.PeerHandleError_new(no_connection_possible_arg)); + public static PeerHandleError constructor_new(boolean no_connection_possible_arg) { + long ret = bindings.PeerHandleError_new(no_connection_possible_arg); + PeerHandleError ret_hu_conv = new PeerHandleError(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/PeerManager.java b/src/main/java/org/ldk/structs/PeerManager.java index 319b979e..0a542cd3 100644 --- a/src/main/java/org/ldk/structs/PeerManager.java +++ b/src/main/java/org/ldk/structs/PeerManager.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class PeerManager extends CommonBase { PeerManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,14 +14,20 @@ public class PeerManager extends CommonBase { bindings.PeerManager_free(ptr); } - public PeerManager(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger) { - super(bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr)); - this.ptrs_to.add(message_handler_chan_handler_arg); - this.ptrs_to.add(message_handler_route_handler_arg); - this.ptrs_to.add(logger); + public static PeerManager constructor_new(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger) { + long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr); + PeerManager ret_hu_conv = new PeerManager(null, ret); + ret_hu_conv.ptrs_to.add(message_handler_chan_handler_arg); + ret_hu_conv.ptrs_to.add(message_handler_route_handler_arg); + ret_hu_conv.ptrs_to.add(logger); + return ret_hu_conv; + } + + public byte[][] get_peer_node_ids() { + byte[][] ret = bindings.PeerManager_get_peer_node_ids(this.ptr); + return ret; } - // Skipped PeerManager_get_peer_node_ids // Skipped PeerManager_new_outbound_connection // Skipped PeerManager_new_inbound_connection // Skipped PeerManager_write_buffer_space_avail diff --git a/src/main/java/org/ldk/structs/Ping.java b/src/main/java/org/ldk/structs/Ping.java index a6953912..5ca952f1 100644 --- a/src/main/java/org/ldk/structs/Ping.java +++ b/src/main/java/org/ldk/structs/Ping.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Ping extends CommonBase { Ping(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class Ping extends CommonBase { bindings.Ping_free(ptr); } - public Ping(Ping orig) { - super(bindings.Ping_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static Ping constructor_clone(Ping orig) { + long ret = bindings.Ping_clone(orig == null ? 0 : orig.ptr & ~1); + Ping ret_hu_conv = new Ping(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public short get_ponglen(Ping this_ptr) { - short ret = bindings.Ping_get_ponglen(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_ponglen() { + short ret = bindings.Ping_get_ponglen(this.ptr); return ret; } - public void set_ponglen(Ping this_ptr, short val) { - bindings.Ping_set_ponglen(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_ponglen(short val) { + bindings.Ping_set_ponglen(this.ptr, val); } - public short get_byteslen(Ping this_ptr) { - short ret = bindings.Ping_get_byteslen(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_byteslen() { + short ret = bindings.Ping_get_byteslen(this.ptr); return ret; } - public void set_byteslen(Ping this_ptr, short val) { - bindings.Ping_set_byteslen(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_byteslen(short val) { + bindings.Ping_set_byteslen(this.ptr, val); } - public Ping(short ponglen_arg, short byteslen_arg) { - super(bindings.Ping_new(ponglen_arg, byteslen_arg)); + public static Ping constructor_new(short ponglen_arg, short byteslen_arg) { + long ret = bindings.Ping_new(ponglen_arg, byteslen_arg); + Ping ret_hu_conv = new Ping(null, ret); + return ret_hu_conv; } public byte[] write(Ping obj) { @@ -48,8 +51,10 @@ public class Ping extends CommonBase { return ret; } - public Ping(byte[] ser) { - super(bindings.Ping_read(ser)); + public static Ping constructor_read(byte[] ser) { + long ret = bindings.Ping_read(ser); + Ping ret_hu_conv = new Ping(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Pong.java b/src/main/java/org/ldk/structs/Pong.java index 35be59ce..80f2995d 100644 --- a/src/main/java/org/ldk/structs/Pong.java +++ b/src/main/java/org/ldk/structs/Pong.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Pong extends CommonBase { Pong(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,24 +14,26 @@ public class Pong extends CommonBase { bindings.Pong_free(ptr); } - public Pong(Pong orig) { - super(bindings.Pong_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static Pong constructor_clone(Pong orig) { + long ret = bindings.Pong_clone(orig == null ? 0 : orig.ptr & ~1); + Pong ret_hu_conv = new Pong(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public short get_byteslen(Pong this_ptr) { - short ret = bindings.Pong_get_byteslen(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_byteslen() { + short ret = bindings.Pong_get_byteslen(this.ptr); return ret; } - public void set_byteslen(Pong this_ptr, short val) { - bindings.Pong_set_byteslen(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_byteslen(short val) { + bindings.Pong_set_byteslen(this.ptr, val); } - public Pong(short byteslen_arg) { - super(bindings.Pong_new(byteslen_arg)); + public static Pong constructor_new(short byteslen_arg) { + long ret = bindings.Pong_new(byteslen_arg); + Pong ret_hu_conv = new Pong(null, ret); + return ret_hu_conv; } public byte[] write(Pong obj) { @@ -37,8 +42,10 @@ public class Pong extends CommonBase { return ret; } - public Pong(byte[] ser) { - super(bindings.Pong_read(ser)); + public static Pong constructor_read(byte[] ser) { + long ret = bindings.Pong_read(ser); + Pong ret_hu_conv = new Pong(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java b/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java index 26222393..1f4bae79 100644 --- a/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java +++ b/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class PreCalculatedTxCreationKeys extends CommonBase { PreCalculatedTxCreationKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,14 +14,17 @@ public class PreCalculatedTxCreationKeys extends CommonBase { bindings.PreCalculatedTxCreationKeys_free(ptr); } - public PreCalculatedTxCreationKeys(TxCreationKeys keys) { - super(bindings.PreCalculatedTxCreationKeys_new(keys == null ? 0 : keys.ptr & ~1)); - this.ptrs_to.add(keys); + public static PreCalculatedTxCreationKeys constructor_new(TxCreationKeys keys) { + long ret = bindings.PreCalculatedTxCreationKeys_new(keys == null ? 0 : keys.ptr & ~1); + PreCalculatedTxCreationKeys ret_hu_conv = new PreCalculatedTxCreationKeys(null, ret); + ret_hu_conv.ptrs_to.add(keys); + return ret_hu_conv; } public TxCreationKeys trust_key_derivation() { - TxCreationKeys ret = new TxCreationKeys(null, bindings.PreCalculatedTxCreationKeys_trust_key_derivation(this.ptr)); - return ret; + long ret = bindings.PreCalculatedTxCreationKeys_trust_key_derivation(this.ptr); + TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret); + return ret_hu_conv; } public byte[] per_commitment_point() { diff --git a/src/main/java/org/ldk/structs/QueryChannelRange.java b/src/main/java/org/ldk/structs/QueryChannelRange.java index d0f45df0..fe205872 100644 --- a/src/main/java/org/ldk/structs/QueryChannelRange.java +++ b/src/main/java/org/ldk/structs/QueryChannelRange.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class QueryChannelRange extends CommonBase { QueryChannelRange(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,50 +14,50 @@ public class QueryChannelRange extends CommonBase { bindings.QueryChannelRange_free(ptr); } - public QueryChannelRange(QueryChannelRange orig) { - super(bindings.QueryChannelRange_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static QueryChannelRange constructor_clone(QueryChannelRange orig) { + long ret = bindings.QueryChannelRange_clone(orig == null ? 0 : orig.ptr & ~1); + QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(QueryChannelRange this_ptr) { - byte[] ret = bindings.QueryChannelRange_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.QueryChannelRange_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(QueryChannelRange this_ptr, byte[] val) { - bindings.QueryChannelRange_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.QueryChannelRange_set_chain_hash(this.ptr, val); } - public int get_first_blocknum(QueryChannelRange this_ptr) { - int ret = bindings.QueryChannelRange_get_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_first_blocknum() { + int ret = bindings.QueryChannelRange_get_first_blocknum(this.ptr); return ret; } - public void set_first_blocknum(QueryChannelRange this_ptr, int val) { - bindings.QueryChannelRange_set_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_first_blocknum(int val) { + bindings.QueryChannelRange_set_first_blocknum(this.ptr, val); } - public int get_number_of_blocks(QueryChannelRange this_ptr) { - int ret = bindings.QueryChannelRange_get_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_number_of_blocks() { + int ret = bindings.QueryChannelRange_get_number_of_blocks(this.ptr); return ret; } - public void set_number_of_blocks(QueryChannelRange this_ptr, int val) { - bindings.QueryChannelRange_set_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_number_of_blocks(int val) { + bindings.QueryChannelRange_set_number_of_blocks(this.ptr, val); } - public QueryChannelRange(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) { - super(bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg)); + public static QueryChannelRange constructor_new(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) { + long ret = bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg); + QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret); + return ret_hu_conv; } - public QueryChannelRange(byte[] ser) { - super(bindings.QueryChannelRange_read(ser)); + public static QueryChannelRange constructor_read(byte[] ser) { + long ret = bindings.QueryChannelRange_read(ser); + QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret); + return ret_hu_conv; } public byte[] write(QueryChannelRange obj) { diff --git a/src/main/java/org/ldk/structs/QueryShortChannelIds.java b/src/main/java/org/ldk/structs/QueryShortChannelIds.java index 4a04a404..c68d4209 100644 --- a/src/main/java/org/ldk/structs/QueryShortChannelIds.java +++ b/src/main/java/org/ldk/structs/QueryShortChannelIds.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class QueryShortChannelIds extends CommonBase { QueryShortChannelIds(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,26 +14,36 @@ public class QueryShortChannelIds extends CommonBase { bindings.QueryShortChannelIds_free(ptr); } - public QueryShortChannelIds(QueryShortChannelIds orig) { - super(bindings.QueryShortChannelIds_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static QueryShortChannelIds constructor_clone(QueryShortChannelIds orig) { + long ret = bindings.QueryShortChannelIds_clone(orig == null ? 0 : orig.ptr & ~1); + QueryShortChannelIds ret_hu_conv = new QueryShortChannelIds(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(QueryShortChannelIds this_ptr) { - byte[] ret = bindings.QueryShortChannelIds_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.QueryShortChannelIds_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(QueryShortChannelIds this_ptr, byte[] val) { - bindings.QueryShortChannelIds_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.QueryShortChannelIds_set_chain_hash(this.ptr, val); } - // Skipped QueryShortChannelIds_set_short_channel_ids - // Skipped QueryShortChannelIds_new - public QueryShortChannelIds(byte[] ser) { - super(bindings.QueryShortChannelIds_read(ser)); + public void set_short_channel_ids(long[] val) { + bindings.QueryShortChannelIds_set_short_channel_ids(this.ptr, val); + } + + public static QueryShortChannelIds constructor_new(byte[] chain_hash_arg, long[] short_channel_ids_arg) { + long ret = bindings.QueryShortChannelIds_new(chain_hash_arg, short_channel_ids_arg); + QueryShortChannelIds ret_hu_conv = new QueryShortChannelIds(null, ret); + return ret_hu_conv; + } + + public static QueryShortChannelIds constructor_read(byte[] ser) { + long ret = bindings.QueryShortChannelIds_read(ser); + QueryShortChannelIds ret_hu_conv = new QueryShortChannelIds(null, ret); + return ret_hu_conv; } public byte[] write(QueryShortChannelIds obj) { diff --git a/src/main/java/org/ldk/structs/ReplyChannelRange.java b/src/main/java/org/ldk/structs/ReplyChannelRange.java index 3a306718..939620ba 100644 --- a/src/main/java/org/ldk/structs/ReplyChannelRange.java +++ b/src/main/java/org/ldk/structs/ReplyChannelRange.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ReplyChannelRange extends CommonBase { ReplyChannelRange(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,59 +14,63 @@ public class ReplyChannelRange extends CommonBase { bindings.ReplyChannelRange_free(ptr); } - public ReplyChannelRange(ReplyChannelRange orig) { - super(bindings.ReplyChannelRange_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ReplyChannelRange constructor_clone(ReplyChannelRange orig) { + long ret = bindings.ReplyChannelRange_clone(orig == null ? 0 : orig.ptr & ~1); + ReplyChannelRange ret_hu_conv = new ReplyChannelRange(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(ReplyChannelRange this_ptr) { - byte[] ret = bindings.ReplyChannelRange_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.ReplyChannelRange_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(ReplyChannelRange this_ptr, byte[] val) { - bindings.ReplyChannelRange_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.ReplyChannelRange_set_chain_hash(this.ptr, val); } - public int get_first_blocknum(ReplyChannelRange this_ptr) { - int ret = bindings.ReplyChannelRange_get_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_first_blocknum() { + int ret = bindings.ReplyChannelRange_get_first_blocknum(this.ptr); return ret; } - public void set_first_blocknum(ReplyChannelRange this_ptr, int val) { - bindings.ReplyChannelRange_set_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_first_blocknum(int val) { + bindings.ReplyChannelRange_set_first_blocknum(this.ptr, val); } - public int get_number_of_blocks(ReplyChannelRange this_ptr) { - int ret = bindings.ReplyChannelRange_get_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_number_of_blocks() { + int ret = bindings.ReplyChannelRange_get_number_of_blocks(this.ptr); return ret; } - public void set_number_of_blocks(ReplyChannelRange this_ptr, int val) { - bindings.ReplyChannelRange_set_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_number_of_blocks(int val) { + bindings.ReplyChannelRange_set_number_of_blocks(this.ptr, val); } - public boolean get_full_information(ReplyChannelRange this_ptr) { - boolean ret = bindings.ReplyChannelRange_get_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_full_information() { + boolean ret = bindings.ReplyChannelRange_get_full_information(this.ptr); return ret; } - public void set_full_information(ReplyChannelRange this_ptr, boolean val) { - bindings.ReplyChannelRange_set_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_full_information(boolean val) { + bindings.ReplyChannelRange_set_full_information(this.ptr, val); } - // Skipped ReplyChannelRange_set_short_channel_ids - // Skipped ReplyChannelRange_new - public ReplyChannelRange(byte[] ser) { - super(bindings.ReplyChannelRange_read(ser)); + public void set_short_channel_ids(long[] val) { + bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, val); + } + + public static ReplyChannelRange constructor_new(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, boolean full_information_arg, long[] short_channel_ids_arg) { + long ret = bindings.ReplyChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg); + ReplyChannelRange ret_hu_conv = new ReplyChannelRange(null, ret); + return ret_hu_conv; + } + + public static ReplyChannelRange constructor_read(byte[] ser) { + long ret = bindings.ReplyChannelRange_read(ser); + ReplyChannelRange ret_hu_conv = new ReplyChannelRange(null, ret); + return ret_hu_conv; } public byte[] write(ReplyChannelRange obj) { diff --git a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java index 9af5948d..947ca85a 100644 --- a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java +++ b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ReplyShortChannelIdsEnd extends CommonBase { ReplyShortChannelIdsEnd(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,39 +14,41 @@ public class ReplyShortChannelIdsEnd extends CommonBase { bindings.ReplyShortChannelIdsEnd_free(ptr); } - public ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd orig) { - super(bindings.ReplyShortChannelIdsEnd_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static ReplyShortChannelIdsEnd constructor_clone(ReplyShortChannelIdsEnd orig) { + long ret = bindings.ReplyShortChannelIdsEnd_clone(orig == null ? 0 : orig.ptr & ~1); + ReplyShortChannelIdsEnd ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(ReplyShortChannelIdsEnd this_ptr) { - byte[] ret = bindings.ReplyShortChannelIdsEnd_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.ReplyShortChannelIdsEnd_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(ReplyShortChannelIdsEnd this_ptr, byte[] val) { - bindings.ReplyShortChannelIdsEnd_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.ReplyShortChannelIdsEnd_set_chain_hash(this.ptr, val); } - public boolean get_full_information(ReplyShortChannelIdsEnd this_ptr) { - boolean ret = bindings.ReplyShortChannelIdsEnd_get_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_full_information() { + boolean ret = bindings.ReplyShortChannelIdsEnd_get_full_information(this.ptr); return ret; } - public void set_full_information(ReplyShortChannelIdsEnd this_ptr, boolean val) { - bindings.ReplyShortChannelIdsEnd_set_full_information(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_full_information(boolean val) { + bindings.ReplyShortChannelIdsEnd_set_full_information(this.ptr, val); } - public ReplyShortChannelIdsEnd(byte[] chain_hash_arg, boolean full_information_arg) { - super(bindings.ReplyShortChannelIdsEnd_new(chain_hash_arg, full_information_arg)); + public static ReplyShortChannelIdsEnd constructor_new(byte[] chain_hash_arg, boolean full_information_arg) { + long ret = bindings.ReplyShortChannelIdsEnd_new(chain_hash_arg, full_information_arg); + ReplyShortChannelIdsEnd ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret); + return ret_hu_conv; } - public ReplyShortChannelIdsEnd(byte[] ser) { - super(bindings.ReplyShortChannelIdsEnd_read(ser)); + public static ReplyShortChannelIdsEnd constructor_read(byte[] ser) { + long ret = bindings.ReplyShortChannelIdsEnd_read(ser); + ReplyShortChannelIdsEnd ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret); + return ret_hu_conv; } public byte[] write(ReplyShortChannelIdsEnd obj) { diff --git a/src/main/java/org/ldk/structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.java b/src/main/java/org/ldk/structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.java new file mode 100644 index 00000000..328451c4 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.java @@ -0,0 +1,34 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ extends CommonBase { + private Result_C2Tuple_SignatureCVec_SignatureZZNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(ptr); super.finalize(); + } + + public static final class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_OK extends Result_C2Tuple_SignatureCVec_SignatureZZNoneZ { + public TwoTuple res; + private Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(ptr); + byte[] res_a = bindings.LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(res); + byte[][] res_b = bindings.LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(res); + TwoTuple res_conv = new TwoTuple(res_a, res_b); + this.res = res_conv; + } + + } + public static final class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_Err extends Result_C2Tuple_SignatureCVec_SignatureZZNoneZ { + public byte err; + private Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_CVec_SignatureZNoneZ.java b/src/main/java/org/ldk/structs/Result_CVec_SignatureZNoneZ.java new file mode 100644 index 00000000..3f9e4918 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_CVec_SignatureZNoneZ.java @@ -0,0 +1,30 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_CVec_SignatureZNoneZ extends CommonBase { + private Result_CVec_SignatureZNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_CVec_SignatureZNoneZ_free(ptr); super.finalize(); + } + + public static final class Result_CVec_SignatureZNoneZ_OK extends Result_CVec_SignatureZNoneZ { + public byte[][] res; + private Result_CVec_SignatureZNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_CVec_SignatureZNoneZ_get_ok(ptr); + } + + } + public static final class Result_CVec_SignatureZNoneZ_Err extends Result_CVec_SignatureZNoneZ { + public byte err; + private Result_CVec_SignatureZNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_CVec_SignatureZNoneZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_CVec_u8ZPeerHandleErrorZ.java b/src/main/java/org/ldk/structs/Result_CVec_u8ZPeerHandleErrorZ.java new file mode 100644 index 00000000..e9df1bc4 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_CVec_u8ZPeerHandleErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase { + private Result_CVec_u8ZPeerHandleErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_CVec_u8ZPeerHandleErrorZ_OK extends Result_CVec_u8ZPeerHandleErrorZ { + public byte[] res; + private Result_CVec_u8ZPeerHandleErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(ptr); + } + + } + public static final class Result_CVec_u8ZPeerHandleErrorZ_Err extends Result_CVec_u8ZPeerHandleErrorZ { + public PeerHandleError err; + private Result_CVec_u8ZPeerHandleErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(ptr); + PeerHandleError err_hu_conv = new PeerHandleError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_NoneAPIErrorZ.java b/src/main/java/org/ldk/structs/Result_NoneAPIErrorZ.java new file mode 100644 index 00000000..21f66dd4 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NoneAPIErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_NoneAPIErrorZ extends CommonBase { + private Result_NoneAPIErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_NoneAPIErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_NoneAPIErrorZ_OK extends Result_NoneAPIErrorZ { + public byte res; + private Result_NoneAPIErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_NoneAPIErrorZ_get_ok(ptr); + } + + } + public static final class Result_NoneAPIErrorZ_Err extends Result_NoneAPIErrorZ { + public APIError err; + private Result_NoneAPIErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_NoneAPIErrorZ_get_err(ptr); + APIError err_hu_conv = APIError.constr_from_ptr(err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_NoneChannelMonitorUpdateErrZ.java b/src/main/java/org/ldk/structs/Result_NoneChannelMonitorUpdateErrZ.java new file mode 100644 index 00000000..d1f26e93 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NoneChannelMonitorUpdateErrZ.java @@ -0,0 +1,30 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_NoneChannelMonitorUpdateErrZ extends CommonBase { + private Result_NoneChannelMonitorUpdateErrZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_NoneChannelMonitorUpdateErrZ_free(ptr); super.finalize(); + } + + public static final class Result_NoneChannelMonitorUpdateErrZ_OK extends Result_NoneChannelMonitorUpdateErrZ { + public byte res; + private Result_NoneChannelMonitorUpdateErrZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(ptr); + } + + } + public static final class Result_NoneChannelMonitorUpdateErrZ_Err extends Result_NoneChannelMonitorUpdateErrZ { + public LDKChannelMonitorUpdateErr err; + private Result_NoneChannelMonitorUpdateErrZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_NoneMonitorUpdateErrorZ.java b/src/main/java/org/ldk/structs/Result_NoneMonitorUpdateErrorZ.java new file mode 100644 index 00000000..2e063dc7 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NoneMonitorUpdateErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_NoneMonitorUpdateErrorZ extends CommonBase { + private Result_NoneMonitorUpdateErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_NoneMonitorUpdateErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_NoneMonitorUpdateErrorZ_OK extends Result_NoneMonitorUpdateErrorZ { + public byte res; + private Result_NoneMonitorUpdateErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_NoneMonitorUpdateErrorZ_get_ok(ptr); + } + + } + public static final class Result_NoneMonitorUpdateErrorZ_Err extends Result_NoneMonitorUpdateErrorZ { + public MonitorUpdateError err; + private Result_NoneMonitorUpdateErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_NoneMonitorUpdateErrorZ_get_err(ptr); + MonitorUpdateError err_hu_conv = new MonitorUpdateError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_NonePaymentSendFailureZ.java b/src/main/java/org/ldk/structs/Result_NonePaymentSendFailureZ.java new file mode 100644 index 00000000..9b011510 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NonePaymentSendFailureZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_NonePaymentSendFailureZ extends CommonBase { + private Result_NonePaymentSendFailureZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_NonePaymentSendFailureZ_free(ptr); super.finalize(); + } + + public static final class Result_NonePaymentSendFailureZ_OK extends Result_NonePaymentSendFailureZ { + public byte res; + private Result_NonePaymentSendFailureZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_NonePaymentSendFailureZ_get_ok(ptr); + } + + } + public static final class Result_NonePaymentSendFailureZ_Err extends Result_NonePaymentSendFailureZ { + public PaymentSendFailure err; + private Result_NonePaymentSendFailureZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_NonePaymentSendFailureZ_get_err(ptr); + PaymentSendFailure err_hu_conv = new PaymentSendFailure(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_NonePeerHandleErrorZ.java b/src/main/java/org/ldk/structs/Result_NonePeerHandleErrorZ.java new file mode 100644 index 00000000..6bbcd969 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NonePeerHandleErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_NonePeerHandleErrorZ extends CommonBase { + private Result_NonePeerHandleErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_NonePeerHandleErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_NonePeerHandleErrorZ_OK extends Result_NonePeerHandleErrorZ { + public byte res; + private Result_NonePeerHandleErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_NonePeerHandleErrorZ_get_ok(ptr); + } + + } + public static final class Result_NonePeerHandleErrorZ_Err extends Result_NonePeerHandleErrorZ { + public PeerHandleError err; + private Result_NonePeerHandleErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_NonePeerHandleErrorZ_get_err(ptr); + PeerHandleError err_hu_conv = new PeerHandleError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_PublicKeySecpErrorZ.java b/src/main/java/org/ldk/structs/Result_PublicKeySecpErrorZ.java new file mode 100644 index 00000000..39dd8247 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_PublicKeySecpErrorZ.java @@ -0,0 +1,30 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_PublicKeySecpErrorZ extends CommonBase { + private Result_PublicKeySecpErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_PublicKeySecpErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_PublicKeySecpErrorZ_OK extends Result_PublicKeySecpErrorZ { + public byte[] res; + private Result_PublicKeySecpErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_PublicKeySecpErrorZ_get_ok(ptr); + } + + } + public static final class Result_PublicKeySecpErrorZ_Err extends Result_PublicKeySecpErrorZ { + public LDKSecp256k1Error err; + private Result_PublicKeySecpErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_PublicKeySecpErrorZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_RouteLightningErrorZ.java b/src/main/java/org/ldk/structs/Result_RouteLightningErrorZ.java new file mode 100644 index 00000000..865b4c9f --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_RouteLightningErrorZ.java @@ -0,0 +1,34 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_RouteLightningErrorZ extends CommonBase { + private Result_RouteLightningErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_RouteLightningErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_RouteLightningErrorZ_OK extends Result_RouteLightningErrorZ { + public Route res; + private Result_RouteLightningErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_RouteLightningErrorZ_get_ok(ptr); + Route res_hu_conv = new Route(null, res); + this.res = res_hu_conv; + } + + } + public static final class Result_RouteLightningErrorZ_Err extends Result_RouteLightningErrorZ { + public LightningError err; + private Result_RouteLightningErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_RouteLightningErrorZ_get_err(ptr); + LightningError err_hu_conv = new LightningError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_SecretKeySecpErrorZ.java b/src/main/java/org/ldk/structs/Result_SecretKeySecpErrorZ.java new file mode 100644 index 00000000..7df06e5d --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_SecretKeySecpErrorZ.java @@ -0,0 +1,30 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_SecretKeySecpErrorZ extends CommonBase { + private Result_SecretKeySecpErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_SecretKeySecpErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_SecretKeySecpErrorZ_OK extends Result_SecretKeySecpErrorZ { + public byte[] res; + private Result_SecretKeySecpErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_SecretKeySecpErrorZ_get_ok(ptr); + } + + } + public static final class Result_SecretKeySecpErrorZ_Err extends Result_SecretKeySecpErrorZ { + public LDKSecp256k1Error err; + private Result_SecretKeySecpErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_SecretKeySecpErrorZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_SignatureNoneZ.java b/src/main/java/org/ldk/structs/Result_SignatureNoneZ.java new file mode 100644 index 00000000..18bf1690 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_SignatureNoneZ.java @@ -0,0 +1,30 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_SignatureNoneZ extends CommonBase { + private Result_SignatureNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_SignatureNoneZ_free(ptr); super.finalize(); + } + + public static final class Result_SignatureNoneZ_OK extends Result_SignatureNoneZ { + public byte[] res; + private Result_SignatureNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_SignatureNoneZ_get_ok(ptr); + } + + } + public static final class Result_SignatureNoneZ_Err extends Result_SignatureNoneZ { + public byte err; + private Result_SignatureNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_SignatureNoneZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_TxCreationKeysSecpErrorZ.java b/src/main/java/org/ldk/structs/Result_TxCreationKeysSecpErrorZ.java new file mode 100644 index 00000000..f0f0a67a --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_TxCreationKeysSecpErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_TxCreationKeysSecpErrorZ extends CommonBase { + private Result_TxCreationKeysSecpErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_TxCreationKeysSecpErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_TxCreationKeysSecpErrorZ_OK extends Result_TxCreationKeysSecpErrorZ { + public TxCreationKeys res; + private Result_TxCreationKeysSecpErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_TxCreationKeysSecpErrorZ_get_ok(ptr); + TxCreationKeys res_hu_conv = new TxCreationKeys(null, res); + this.res = res_hu_conv; + } + + } + public static final class Result_TxCreationKeysSecpErrorZ_Err extends Result_TxCreationKeysSecpErrorZ { + public LDKSecp256k1Error err; + private Result_TxCreationKeysSecpErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_TxCreationKeysSecpErrorZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_TxOutAccessErrorZ.java b/src/main/java/org/ldk/structs/Result_TxOutAccessErrorZ.java new file mode 100644 index 00000000..3c2c3a2d --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_TxOutAccessErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_TxOutAccessErrorZ extends CommonBase { + private Result_TxOutAccessErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_TxOutAccessErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_TxOutAccessErrorZ_OK extends Result_TxOutAccessErrorZ { + public TxOut res; + private Result_TxOutAccessErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_TxOutAccessErrorZ_get_ok(ptr); + TxOut res_conv = new TxOut(null, res); + this.res = res_conv; + } + + } + public static final class Result_TxOutAccessErrorZ_Err extends Result_TxOutAccessErrorZ { + public LDKAccessError err; + private Result_TxOutAccessErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + this.err = bindings.LDKCResult_TxOutAccessErrorZ_get_err(ptr); + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_boolLightningErrorZ.java b/src/main/java/org/ldk/structs/Result_boolLightningErrorZ.java new file mode 100644 index 00000000..67f766e4 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_boolLightningErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_boolLightningErrorZ extends CommonBase { + private Result_boolLightningErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_boolLightningErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_boolLightningErrorZ_OK extends Result_boolLightningErrorZ { + public boolean res; + private Result_boolLightningErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_boolLightningErrorZ_get_ok(ptr); + } + + } + public static final class Result_boolLightningErrorZ_Err extends Result_boolLightningErrorZ { + public LightningError err; + private Result_boolLightningErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_boolLightningErrorZ_get_err(ptr); + LightningError err_hu_conv = new LightningError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/Result_boolPeerHandleErrorZ.java b/src/main/java/org/ldk/structs/Result_boolPeerHandleErrorZ.java new file mode 100644 index 00000000..1adf3491 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_boolPeerHandleErrorZ.java @@ -0,0 +1,32 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Result_boolPeerHandleErrorZ extends CommonBase { + private Result_boolPeerHandleErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + bindings.CResult_boolPeerHandleErrorZ_free(ptr); super.finalize(); + } + + public static final class Result_boolPeerHandleErrorZ_OK extends Result_boolPeerHandleErrorZ { + public boolean res; + private Result_boolPeerHandleErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + this.res = bindings.LDKCResult_boolPeerHandleErrorZ_get_ok(ptr); + } + + } + public static final class Result_boolPeerHandleErrorZ_Err extends Result_boolPeerHandleErrorZ { + public PeerHandleError err; + private Result_boolPeerHandleErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_boolPeerHandleErrorZ_get_err(ptr); + PeerHandleError err_hu_conv = new PeerHandleError(null, err); + this.err = err_hu_conv; + } + } +} diff --git a/src/main/java/org/ldk/structs/RevokeAndACK.java b/src/main/java/org/ldk/structs/RevokeAndACK.java index fe189a83..5409d3b9 100644 --- a/src/main/java/org/ldk/structs/RevokeAndACK.java +++ b/src/main/java/org/ldk/structs/RevokeAndACK.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RevokeAndACK extends CommonBase { RevokeAndACK(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,46 +14,44 @@ public class RevokeAndACK extends CommonBase { bindings.RevokeAndACK_free(ptr); } - public RevokeAndACK(RevokeAndACK orig) { - super(bindings.RevokeAndACK_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static RevokeAndACK constructor_clone(RevokeAndACK orig) { + long ret = bindings.RevokeAndACK_clone(orig == null ? 0 : orig.ptr & ~1); + RevokeAndACK ret_hu_conv = new RevokeAndACK(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(RevokeAndACK this_ptr) { - byte[] ret = bindings.RevokeAndACK_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.RevokeAndACK_get_channel_id(this.ptr); return ret; } - public void set_channel_id(RevokeAndACK this_ptr, byte[] val) { - bindings.RevokeAndACK_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.RevokeAndACK_set_channel_id(this.ptr, val); } - public byte[] get_per_commitment_secret(RevokeAndACK this_ptr) { - byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_per_commitment_secret() { + byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this.ptr); return ret; } - public void set_per_commitment_secret(RevokeAndACK this_ptr, byte[] val) { - bindings.RevokeAndACK_set_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_per_commitment_secret(byte[] val) { + bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, val); } - public byte[] get_next_per_commitment_point(RevokeAndACK this_ptr) { - byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_next_per_commitment_point() { + byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr); return ret; } - public void set_next_per_commitment_point(RevokeAndACK this_ptr, byte[] val) { - bindings.RevokeAndACK_set_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_next_per_commitment_point(byte[] val) { + bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, val); } - public RevokeAndACK(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) { - super(bindings.RevokeAndACK_new(channel_id_arg, per_commitment_secret_arg, next_per_commitment_point_arg)); + public static RevokeAndACK constructor_new(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) { + long ret = bindings.RevokeAndACK_new(channel_id_arg, per_commitment_secret_arg, next_per_commitment_point_arg); + RevokeAndACK ret_hu_conv = new RevokeAndACK(null, ret); + return ret_hu_conv; } public byte[] write(RevokeAndACK obj) { @@ -59,8 +60,10 @@ public class RevokeAndACK extends CommonBase { return ret; } - public RevokeAndACK(byte[] ser) { - super(bindings.RevokeAndACK_read(ser)); + public static RevokeAndACK constructor_read(byte[] ser) { + long ret = bindings.RevokeAndACK_read(ser); + RevokeAndACK ret_hu_conv = new RevokeAndACK(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Route.java b/src/main/java/org/ldk/structs/Route.java index ec5853e3..b7864b49 100644 --- a/src/main/java/org/ldk/structs/Route.java +++ b/src/main/java/org/ldk/structs/Route.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Route extends CommonBase { Route(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,21 +14,35 @@ public class Route extends CommonBase { bindings.Route_free(ptr); } - public Route(Route orig) { - super(bindings.Route_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static Route constructor_clone(Route orig) { + long ret = bindings.Route_clone(orig == null ? 0 : orig.ptr & ~1); + Route ret_hu_conv = new Route(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; + } + + public void set_paths(RouteHop[][] val) { + bindings.Route_set_paths(this.ptr, (long[][])Arrays.stream(val).map(arr_conv_12 -> Arrays.stream(arr_conv_12).mapToLong(arr_conv_10 -> arr_conv_10 == null ? 0 : arr_conv_10.ptr & ~1).toArray()).toArray()); + /* TODO 2 RouteHop[] */; + } + + public static Route constructor_new(RouteHop[][] paths_arg) { + long ret = bindings.Route_new((long[][])Arrays.stream(paths_arg).map(arr_conv_12 -> Arrays.stream(arr_conv_12).mapToLong(arr_conv_10 -> arr_conv_10 == null ? 0 : arr_conv_10.ptr & ~1).toArray()).toArray()); + Route ret_hu_conv = new Route(null, ret); + /* TODO 2 RouteHop[] */; + return ret_hu_conv; } - // Skipped Route_set_paths - // Skipped Route_new public byte[] write(Route obj) { byte[] ret = bindings.Route_write(obj == null ? 0 : obj.ptr & ~1); this.ptrs_to.add(obj); return ret; } - public Route(byte[] ser) { - super(bindings.Route_read(ser)); + public static Route constructor_read(byte[] ser) { + long ret = bindings.Route_read(ser); + Route ret_hu_conv = new Route(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/RouteHint.java b/src/main/java/org/ldk/structs/RouteHint.java index f7897200..9c6e0f79 100644 --- a/src/main/java/org/ldk/structs/RouteHint.java +++ b/src/main/java/org/ldk/structs/RouteHint.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RouteHint extends CommonBase { RouteHint(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,70 +14,65 @@ public class RouteHint extends CommonBase { bindings.RouteHint_free(ptr); } - public RouteHint(RouteHint orig) { - super(bindings.RouteHint_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static RouteHint constructor_clone(RouteHint orig) { + long ret = bindings.RouteHint_clone(orig == null ? 0 : orig.ptr & ~1); + RouteHint ret_hu_conv = new RouteHint(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_src_node_id(RouteHint this_ptr) { - byte[] ret = bindings.RouteHint_get_src_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_src_node_id() { + byte[] ret = bindings.RouteHint_get_src_node_id(this.ptr); return ret; } - public void set_src_node_id(RouteHint this_ptr, byte[] val) { - bindings.RouteHint_set_src_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_src_node_id(byte[] val) { + bindings.RouteHint_set_src_node_id(this.ptr, val); } - public long get_short_channel_id(RouteHint this_ptr) { - long ret = bindings.RouteHint_get_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_short_channel_id() { + long ret = bindings.RouteHint_get_short_channel_id(this.ptr); return ret; } - public void set_short_channel_id(RouteHint this_ptr, long val) { - bindings.RouteHint_set_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_short_channel_id(long val) { + bindings.RouteHint_set_short_channel_id(this.ptr, val); } - public RoutingFees get_fees(RouteHint this_ptr) { - RoutingFees ret = new RoutingFees(null, bindings.RouteHint_get_fees(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public RoutingFees get_fees() { + long ret = bindings.RouteHint_get_fees(this.ptr); + RoutingFees ret_hu_conv = new RoutingFees(null, ret); + return ret_hu_conv; } - public void set_fees(RouteHint this_ptr, RoutingFees val) { - bindings.RouteHint_set_fees(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_fees(RoutingFees val) { + bindings.RouteHint_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public short get_cltv_expiry_delta(RouteHint this_ptr) { - short ret = bindings.RouteHint_get_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_cltv_expiry_delta() { + short ret = bindings.RouteHint_get_cltv_expiry_delta(this.ptr); return ret; } - public void set_cltv_expiry_delta(RouteHint this_ptr, short val) { - bindings.RouteHint_set_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry_delta(short val) { + bindings.RouteHint_set_cltv_expiry_delta(this.ptr, val); } - public long get_htlc_minimum_msat(RouteHint this_ptr) { - long ret = bindings.RouteHint_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_minimum_msat() { + long ret = bindings.RouteHint_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(RouteHint this_ptr, long val) { - bindings.RouteHint_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_minimum_msat(long val) { + bindings.RouteHint_set_htlc_minimum_msat(this.ptr, val); } - public RouteHint(byte[] src_node_id_arg, long short_channel_id_arg, RoutingFees fees_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg) { - super(bindings.RouteHint_new(src_node_id_arg, short_channel_id_arg, fees_arg == null ? 0 : fees_arg.ptr & ~1, cltv_expiry_delta_arg, htlc_minimum_msat_arg)); - this.ptrs_to.add(fees_arg); + public static RouteHint constructor_new(byte[] src_node_id_arg, long short_channel_id_arg, RoutingFees fees_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg) { + long ret = bindings.RouteHint_new(src_node_id_arg, short_channel_id_arg, fees_arg == null ? 0 : fees_arg.ptr & ~1, cltv_expiry_delta_arg, htlc_minimum_msat_arg); + RouteHint ret_hu_conv = new RouteHint(null, ret); + ret_hu_conv.ptrs_to.add(fees_arg); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/RouteHop.java b/src/main/java/org/ldk/structs/RouteHop.java index a094d172..74e5816d 100644 --- a/src/main/java/org/ldk/structs/RouteHop.java +++ b/src/main/java/org/ldk/structs/RouteHop.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RouteHop extends CommonBase { RouteHop(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,67 +14,61 @@ public class RouteHop extends CommonBase { bindings.RouteHop_free(ptr); } - public RouteHop(RouteHop orig) { - super(bindings.RouteHop_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static RouteHop constructor_clone(RouteHop orig) { + long ret = bindings.RouteHop_clone(orig == null ? 0 : orig.ptr & ~1); + RouteHop ret_hu_conv = new RouteHop(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_pubkey(RouteHop this_ptr) { - byte[] ret = bindings.RouteHop_get_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_pubkey() { + byte[] ret = bindings.RouteHop_get_pubkey(this.ptr); return ret; } - public void set_pubkey(RouteHop this_ptr, byte[] val) { - bindings.RouteHop_set_pubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_pubkey(byte[] val) { + bindings.RouteHop_set_pubkey(this.ptr, val); } - public NodeFeatures get_node_features(RouteHop this_ptr) { - NodeFeatures ret = new NodeFeatures(null, bindings.RouteHop_get_node_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public NodeFeatures get_node_features() { + long ret = bindings.RouteHop_get_node_features(this.ptr); + NodeFeatures ret_hu_conv = new NodeFeatures(null, ret); + return ret_hu_conv; } // Skipped RouteHop_set_node_features - public long get_short_channel_id(RouteHop this_ptr) { - long ret = bindings.RouteHop_get_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_short_channel_id() { + long ret = bindings.RouteHop_get_short_channel_id(this.ptr); return ret; } - public void set_short_channel_id(RouteHop this_ptr, long val) { - bindings.RouteHop_set_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_short_channel_id(long val) { + bindings.RouteHop_set_short_channel_id(this.ptr, val); } - public ChannelFeatures get_channel_features(RouteHop this_ptr) { - ChannelFeatures ret = new ChannelFeatures(null, bindings.RouteHop_get_channel_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelFeatures get_channel_features() { + long ret = bindings.RouteHop_get_channel_features(this.ptr); + ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret); + return ret_hu_conv; } // Skipped RouteHop_set_channel_features - public long get_fee_msat(RouteHop this_ptr) { - long ret = bindings.RouteHop_get_fee_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_fee_msat() { + long ret = bindings.RouteHop_get_fee_msat(this.ptr); return ret; } - public void set_fee_msat(RouteHop this_ptr, long val) { - bindings.RouteHop_set_fee_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_fee_msat(long val) { + bindings.RouteHop_set_fee_msat(this.ptr, val); } - public int get_cltv_expiry_delta(RouteHop this_ptr) { - int ret = bindings.RouteHop_get_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_cltv_expiry_delta() { + int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr); return ret; } - public void set_cltv_expiry_delta(RouteHop this_ptr, int val) { - bindings.RouteHop_set_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry_delta(int val) { + bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val); } // Skipped RouteHop_new diff --git a/src/main/java/org/ldk/structs/RoutingFees.java b/src/main/java/org/ldk/structs/RoutingFees.java index 201b830a..a182fea6 100644 --- a/src/main/java/org/ldk/structs/RoutingFees.java +++ b/src/main/java/org/ldk/structs/RoutingFees.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RoutingFees extends CommonBase { RoutingFees(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,39 +14,41 @@ public class RoutingFees extends CommonBase { bindings.RoutingFees_free(ptr); } - public RoutingFees(RoutingFees orig) { - super(bindings.RoutingFees_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static RoutingFees constructor_clone(RoutingFees orig) { + long ret = bindings.RoutingFees_clone(orig == null ? 0 : orig.ptr & ~1); + RoutingFees ret_hu_conv = new RoutingFees(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public int get_base_msat(RoutingFees this_ptr) { - int ret = bindings.RoutingFees_get_base_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_base_msat() { + int ret = bindings.RoutingFees_get_base_msat(this.ptr); return ret; } - public void set_base_msat(RoutingFees this_ptr, int val) { - bindings.RoutingFees_set_base_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_base_msat(int val) { + bindings.RoutingFees_set_base_msat(this.ptr, val); } - public int get_proportional_millionths(RoutingFees this_ptr) { - int ret = bindings.RoutingFees_get_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_proportional_millionths() { + int ret = bindings.RoutingFees_get_proportional_millionths(this.ptr); return ret; } - public void set_proportional_millionths(RoutingFees this_ptr, int val) { - bindings.RoutingFees_set_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_proportional_millionths(int val) { + bindings.RoutingFees_set_proportional_millionths(this.ptr, val); } - public RoutingFees(int base_msat_arg, int proportional_millionths_arg) { - super(bindings.RoutingFees_new(base_msat_arg, proportional_millionths_arg)); + public static RoutingFees constructor_new(int base_msat_arg, int proportional_millionths_arg) { + long ret = bindings.RoutingFees_new(base_msat_arg, proportional_millionths_arg); + RoutingFees ret_hu_conv = new RoutingFees(null, ret); + return ret_hu_conv; } - public RoutingFees(byte[] ser) { - super(bindings.RoutingFees_read(ser)); + public static RoutingFees constructor_read(byte[] ser) { + long ret = bindings.RoutingFees_read(ser); + RoutingFees ret_hu_conv = new RoutingFees(null, ret); + return ret_hu_conv; } public byte[] write(RoutingFees obj) { diff --git a/src/main/java/org/ldk/structs/RoutingMessageHandler.java b/src/main/java/org/ldk/structs/RoutingMessageHandler.java index d1723d32..a4b61b97 100644 --- a/src/main/java/org/ldk/structs/RoutingMessageHandler.java +++ b/src/main/java/org/ldk/structs/RoutingMessageHandler.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RoutingMessageHandler extends CommonBase { RoutingMessageHandler(Object _dummy, long ptr) { super(ptr); } public RoutingMessageHandler(bindings.LDKRoutingMessageHandler arg) { @@ -19,8 +21,34 @@ public class RoutingMessageHandler extends CommonBase { // Skipped RoutingMessageHandler_handle_channel_announcement // Skipped RoutingMessageHandler_handle_channel_update // Skipped RoutingMessageHandler_handle_htlc_fail_channel_update - // Skipped RoutingMessageHandler_get_next_channel_announcements - // Skipped RoutingMessageHandler_get_next_node_announcements + public ThreeTuple[] get_next_channel_announcements(long starting_point, byte batch_amount) { + long[] ret = bindings.RoutingMessageHandler_get_next_channel_announcements(this.ptr, starting_point, batch_amount); + ThreeTuple[] arr_conv_63_arr = new ThreeTuple[ret.length]; + for (int l = 0; l < ret.length; l++) { + long arr_conv_63 = ret[l]; + long arr_conv_63_a = bindings.LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(arr_conv_63); + ChannelAnnouncement arr_conv_63_a_hu_conv = new ChannelAnnouncement(null, arr_conv_63_a);; + long arr_conv_63_b = bindings.LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(arr_conv_63); + ChannelUpdate arr_conv_63_b_hu_conv = new ChannelUpdate(null, arr_conv_63_b);; + long arr_conv_63_c = bindings.LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(arr_conv_63); + ChannelUpdate arr_conv_63_c_hu_conv = new ChannelUpdate(null, arr_conv_63_c);; + ThreeTuple arr_conv_63_conv = new ThreeTuple(arr_conv_63_a_hu_conv, arr_conv_63_b_hu_conv, arr_conv_63_c_hu_conv); + arr_conv_63_arr[l] = arr_conv_63_conv; + } + return arr_conv_63_arr; + } + + public NodeAnnouncement[] get_next_node_announcements(byte[] starting_point, byte batch_amount) { + long[] ret = bindings.RoutingMessageHandler_get_next_node_announcements(this.ptr, starting_point, batch_amount); + NodeAnnouncement[] arr_conv_18_arr = new NodeAnnouncement[ret.length]; + for (int s = 0; s < ret.length; s++) { + long arr_conv_18 = ret[s]; + NodeAnnouncement arr_conv_18_hu_conv = new NodeAnnouncement(null, arr_conv_18); + arr_conv_18_arr[s] = arr_conv_18_hu_conv; + } + return arr_conv_18_arr; + } + public boolean should_request_full_sync(byte[] node_id) { boolean ret = bindings.RoutingMessageHandler_should_request_full_sync(this.ptr, node_id); return ret; diff --git a/src/main/java/org/ldk/structs/Shutdown.java b/src/main/java/org/ldk/structs/Shutdown.java index 11151126..6b95b568 100644 --- a/src/main/java/org/ldk/structs/Shutdown.java +++ b/src/main/java/org/ldk/structs/Shutdown.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Shutdown extends CommonBase { Shutdown(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class Shutdown extends CommonBase { bindings.Shutdown_free(ptr); } - public Shutdown(Shutdown orig) { - super(bindings.Shutdown_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static Shutdown constructor_clone(Shutdown orig) { + long ret = bindings.Shutdown_clone(orig == null ? 0 : orig.ptr & ~1); + Shutdown ret_hu_conv = new Shutdown(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(Shutdown this_ptr) { - byte[] ret = bindings.Shutdown_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.Shutdown_get_channel_id(this.ptr); return ret; } - public void set_channel_id(Shutdown this_ptr, byte[] val) { - bindings.Shutdown_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.Shutdown_set_channel_id(this.ptr, val); } - public byte[] get_scriptpubkey(Shutdown this_ptr) { - byte[] ret = bindings.Shutdown_get_scriptpubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_scriptpubkey() { + byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr); return ret; } - public void set_scriptpubkey(Shutdown this_ptr, byte[] val) { - bindings.Shutdown_set_scriptpubkey(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_scriptpubkey(byte[] val) { + bindings.Shutdown_set_scriptpubkey(this.ptr, val); } - public Shutdown(byte[] channel_id_arg, byte[] scriptpubkey_arg) { - super(bindings.Shutdown_new(channel_id_arg, scriptpubkey_arg)); + public static Shutdown constructor_new(byte[] channel_id_arg, byte[] scriptpubkey_arg) { + long ret = bindings.Shutdown_new(channel_id_arg, scriptpubkey_arg); + Shutdown ret_hu_conv = new Shutdown(null, ret); + return ret_hu_conv; } public byte[] write(Shutdown obj) { @@ -48,8 +51,10 @@ public class Shutdown extends CommonBase { return ret; } - public Shutdown(byte[] ser) { - super(bindings.Shutdown_read(ser)); + public static Shutdown constructor_read(byte[] ser) { + long ret = bindings.Shutdown_read(ser); + Shutdown ret_hu_conv = new Shutdown(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/SocketDescriptor.java b/src/main/java/org/ldk/structs/SocketDescriptor.java index a0e9b753..ae56a983 100644 --- a/src/main/java/org/ldk/structs/SocketDescriptor.java +++ b/src/main/java/org/ldk/structs/SocketDescriptor.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class SocketDescriptor extends CommonBase { SocketDescriptor(Object _dummy, long ptr) { super(ptr); } public SocketDescriptor(bindings.LDKSocketDescriptor arg) { diff --git a/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java new file mode 100644 index 00000000..42dd314b --- /dev/null +++ b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java @@ -0,0 +1,49 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class SpendableOutputDescriptor extends CommonBase { + private SpendableOutputDescriptor(Object _dummy, long ptr) { super(ptr); } + long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } + static SpendableOutputDescriptor constr_from_ptr(long ptr) { + bindings.LDKSpendableOutputDescriptor raw_val = bindings.LDKSpendableOutputDescriptor_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticOutput.class) { + return new StaticOutput(null, ptr); + } + if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.DynamicOutputP2WSH.class) { + return new DynamicOutputP2WSH(null, ptr); + } + if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticOutputCounterpartyPayment.class) { + return new StaticOutputCounterpartyPayment(null, ptr); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class StaticOutput extends SpendableOutputDescriptor { + public OutPoint outpoint; + public TxOut output; + private StaticOutput(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class DynamicOutputP2WSH extends SpendableOutputDescriptor { + public OutPoint outpoint; + public byte[] per_commitment_point; + public short to_self_delay; + public TxOut output; + public TwoTuple key_derivation_params; + public byte[] revocation_pubkey; + private DynamicOutputP2WSH(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } + public final static class StaticOutputCounterpartyPayment extends SpendableOutputDescriptor { + public OutPoint outpoint; + public TxOut output; + public TwoTuple key_derivation_params; + private StaticOutputCounterpartyPayment(Object _dummy, long ptr) { super(null, ptr); } + @Override long conv_to_c() { return 0; /*XXX*/ } + } +} diff --git a/src/main/java/org/ldk/structs/Transaction.java b/src/main/java/org/ldk/structs/Transaction.java new file mode 100644 index 00000000..203c34c3 --- /dev/null +++ b/src/main/java/org/ldk/structs/Transaction.java @@ -0,0 +1,11 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Transaction extends CommonBase{ + Transaction(java.lang.Object _dummy, long ptr) { super(ptr); } +} \ No newline at end of file diff --git a/src/main/java/org/ldk/structs/TxCreationKeys.java b/src/main/java/org/ldk/structs/TxCreationKeys.java index ece60151..cb025587 100644 --- a/src/main/java/org/ldk/structs/TxCreationKeys.java +++ b/src/main/java/org/ldk/structs/TxCreationKeys.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class TxCreationKeys extends CommonBase { TxCreationKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,68 +14,62 @@ public class TxCreationKeys extends CommonBase { bindings.TxCreationKeys_free(ptr); } - public TxCreationKeys(TxCreationKeys orig) { - super(bindings.TxCreationKeys_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static TxCreationKeys constructor_clone(TxCreationKeys orig) { + long ret = bindings.TxCreationKeys_clone(orig == null ? 0 : orig.ptr & ~1); + TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_per_commitment_point(TxCreationKeys this_ptr) { - byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_per_commitment_point() { + byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr); return ret; } - public void set_per_commitment_point(TxCreationKeys this_ptr, byte[] val) { - bindings.TxCreationKeys_set_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_per_commitment_point(byte[] val) { + bindings.TxCreationKeys_set_per_commitment_point(this.ptr, val); } - public byte[] get_revocation_key(TxCreationKeys this_ptr) { - byte[] ret = bindings.TxCreationKeys_get_revocation_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_revocation_key() { + byte[] ret = bindings.TxCreationKeys_get_revocation_key(this.ptr); return ret; } - public void set_revocation_key(TxCreationKeys this_ptr, byte[] val) { - bindings.TxCreationKeys_set_revocation_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_revocation_key(byte[] val) { + bindings.TxCreationKeys_set_revocation_key(this.ptr, val); } - public byte[] get_broadcaster_htlc_key(TxCreationKeys this_ptr) { - byte[] ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_broadcaster_htlc_key() { + byte[] ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr); return ret; } - public void set_broadcaster_htlc_key(TxCreationKeys this_ptr, byte[] val) { - bindings.TxCreationKeys_set_broadcaster_htlc_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_broadcaster_htlc_key(byte[] val) { + bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, val); } - public byte[] get_countersignatory_htlc_key(TxCreationKeys this_ptr) { - byte[] ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_countersignatory_htlc_key() { + byte[] ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr); return ret; } - public void set_countersignatory_htlc_key(TxCreationKeys this_ptr, byte[] val) { - bindings.TxCreationKeys_set_countersignatory_htlc_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_countersignatory_htlc_key(byte[] val) { + bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, val); } - public byte[] get_broadcaster_delayed_payment_key(TxCreationKeys this_ptr) { - byte[] ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_broadcaster_delayed_payment_key() { + byte[] ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr); return ret; } - public void set_broadcaster_delayed_payment_key(TxCreationKeys this_ptr, byte[] val) { - bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_broadcaster_delayed_payment_key(byte[] val) { + bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, val); } - public TxCreationKeys(byte[] per_commitment_point_arg, byte[] revocation_key_arg, byte[] broadcaster_htlc_key_arg, byte[] countersignatory_htlc_key_arg, byte[] broadcaster_delayed_payment_key_arg) { - super(bindings.TxCreationKeys_new(per_commitment_point_arg, revocation_key_arg, broadcaster_htlc_key_arg, countersignatory_htlc_key_arg, broadcaster_delayed_payment_key_arg)); + public static TxCreationKeys constructor_new(byte[] per_commitment_point_arg, byte[] revocation_key_arg, byte[] broadcaster_htlc_key_arg, byte[] countersignatory_htlc_key_arg, byte[] broadcaster_delayed_payment_key_arg) { + long ret = bindings.TxCreationKeys_new(per_commitment_point_arg, revocation_key_arg, broadcaster_htlc_key_arg, countersignatory_htlc_key_arg, broadcaster_delayed_payment_key_arg); + TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret); + return ret_hu_conv; } public byte[] write(TxCreationKeys obj) { @@ -81,8 +78,10 @@ public class TxCreationKeys extends CommonBase { return ret; } - public TxCreationKeys(byte[] ser) { - super(bindings.TxCreationKeys_read(ser)); + public static TxCreationKeys constructor_read(byte[] ser) { + long ret = bindings.TxCreationKeys_read(ser); + TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret); + return ret_hu_conv; } // Skipped TxCreationKeys_derive_new diff --git a/src/main/java/org/ldk/structs/TxOut.java b/src/main/java/org/ldk/structs/TxOut.java new file mode 100644 index 00000000..438c92a0 --- /dev/null +++ b/src/main/java/org/ldk/structs/TxOut.java @@ -0,0 +1,11 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class TxOut extends CommonBase{ + TxOut(java.lang.Object _dummy, long ptr) { super(ptr); } +} \ No newline at end of file diff --git a/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java index 959ad922..a5b624b1 100644 --- a/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UnsignedChannelAnnouncement extends CommonBase { UnsignedChannelAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,82 +14,72 @@ public class UnsignedChannelAnnouncement extends CommonBase { bindings.UnsignedChannelAnnouncement_free(ptr); } - public UnsignedChannelAnnouncement(UnsignedChannelAnnouncement orig) { - super(bindings.UnsignedChannelAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UnsignedChannelAnnouncement constructor_clone(UnsignedChannelAnnouncement orig) { + long ret = bindings.UnsignedChannelAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1); + UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public ChannelFeatures get_features(UnsignedChannelAnnouncement this_ptr) { - ChannelFeatures ret = new ChannelFeatures(null, bindings.UnsignedChannelAnnouncement_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelFeatures get_features() { + long ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr); + ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret); + return ret_hu_conv; } // Skipped UnsignedChannelAnnouncement_set_features - public byte[] get_chain_hash(UnsignedChannelAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(UnsignedChannelAnnouncement this_ptr, byte[] val) { - bindings.UnsignedChannelAnnouncement_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.UnsignedChannelAnnouncement_set_chain_hash(this.ptr, val); } - public long get_short_channel_id(UnsignedChannelAnnouncement this_ptr) { - long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_short_channel_id() { + long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr); return ret; } - public void set_short_channel_id(UnsignedChannelAnnouncement this_ptr, long val) { - bindings.UnsignedChannelAnnouncement_set_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_short_channel_id(long val) { + bindings.UnsignedChannelAnnouncement_set_short_channel_id(this.ptr, val); } - public byte[] get_node_id_1(UnsignedChannelAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_id_1() { + byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this.ptr); return ret; } - public void set_node_id_1(UnsignedChannelAnnouncement this_ptr, byte[] val) { - bindings.UnsignedChannelAnnouncement_set_node_id_1(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_id_1(byte[] val) { + bindings.UnsignedChannelAnnouncement_set_node_id_1(this.ptr, val); } - public byte[] get_node_id_2(UnsignedChannelAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_id_2() { + byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this.ptr); return ret; } - public void set_node_id_2(UnsignedChannelAnnouncement this_ptr, byte[] val) { - bindings.UnsignedChannelAnnouncement_set_node_id_2(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_id_2(byte[] val) { + bindings.UnsignedChannelAnnouncement_set_node_id_2(this.ptr, val); } - public byte[] get_bitcoin_key_1(UnsignedChannelAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_bitcoin_key_1() { + byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this.ptr); return ret; } - public void set_bitcoin_key_1(UnsignedChannelAnnouncement this_ptr, byte[] val) { - bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_bitcoin_key_1(byte[] val) { + bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this.ptr, val); } - public byte[] get_bitcoin_key_2(UnsignedChannelAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_bitcoin_key_2() { + byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this.ptr); return ret; } - public void set_bitcoin_key_2(UnsignedChannelAnnouncement this_ptr, byte[] val) { - bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_bitcoin_key_2(byte[] val) { + bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this.ptr, val); } public byte[] write(UnsignedChannelAnnouncement obj) { @@ -95,8 +88,10 @@ public class UnsignedChannelAnnouncement extends CommonBase { return ret; } - public UnsignedChannelAnnouncement(byte[] ser) { - super(bindings.UnsignedChannelAnnouncement_read(ser)); + public static UnsignedChannelAnnouncement constructor_read(byte[] ser) { + long ret = bindings.UnsignedChannelAnnouncement_read(ser); + UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java b/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java index 20f1fe20..0fa6b1e5 100644 --- a/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java +++ b/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UnsignedChannelUpdate extends CommonBase { UnsignedChannelUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,97 +14,83 @@ public class UnsignedChannelUpdate extends CommonBase { bindings.UnsignedChannelUpdate_free(ptr); } - public UnsignedChannelUpdate(UnsignedChannelUpdate orig) { - super(bindings.UnsignedChannelUpdate_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UnsignedChannelUpdate constructor_clone(UnsignedChannelUpdate orig) { + long ret = bindings.UnsignedChannelUpdate_clone(orig == null ? 0 : orig.ptr & ~1); + UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_chain_hash(UnsignedChannelUpdate this_ptr) { - byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_chain_hash() { + byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr); return ret; } - public void set_chain_hash(UnsignedChannelUpdate this_ptr, byte[] val) { - bindings.UnsignedChannelUpdate_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_chain_hash(byte[] val) { + bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, val); } - public long get_short_channel_id(UnsignedChannelUpdate this_ptr) { - long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_short_channel_id() { + long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr); return ret; } - public void set_short_channel_id(UnsignedChannelUpdate this_ptr, long val) { - bindings.UnsignedChannelUpdate_set_short_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_short_channel_id(long val) { + bindings.UnsignedChannelUpdate_set_short_channel_id(this.ptr, val); } - public int get_timestamp(UnsignedChannelUpdate this_ptr) { - int ret = bindings.UnsignedChannelUpdate_get_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_timestamp() { + int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr); return ret; } - public void set_timestamp(UnsignedChannelUpdate this_ptr, int val) { - bindings.UnsignedChannelUpdate_set_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_timestamp(int val) { + bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val); } - public byte get_flags(UnsignedChannelUpdate this_ptr) { - byte ret = bindings.UnsignedChannelUpdate_get_flags(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte get_flags() { + byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr); return ret; } - public void set_flags(UnsignedChannelUpdate this_ptr, byte val) { - bindings.UnsignedChannelUpdate_set_flags(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_flags(byte val) { + bindings.UnsignedChannelUpdate_set_flags(this.ptr, val); } - public short get_cltv_expiry_delta(UnsignedChannelUpdate this_ptr) { - short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_cltv_expiry_delta() { + short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr); return ret; } - public void set_cltv_expiry_delta(UnsignedChannelUpdate this_ptr, short val) { - bindings.UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry_delta(short val) { + bindings.UnsignedChannelUpdate_set_cltv_expiry_delta(this.ptr, val); } - public long get_htlc_minimum_msat(UnsignedChannelUpdate this_ptr) { - long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_minimum_msat() { + long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(UnsignedChannelUpdate this_ptr, long val) { - bindings.UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_minimum_msat(long val) { + bindings.UnsignedChannelUpdate_set_htlc_minimum_msat(this.ptr, val); } - public int get_fee_base_msat(UnsignedChannelUpdate this_ptr) { - int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_fee_base_msat() { + int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr); return ret; } - public void set_fee_base_msat(UnsignedChannelUpdate this_ptr, int val) { - bindings.UnsignedChannelUpdate_set_fee_base_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_fee_base_msat(int val) { + bindings.UnsignedChannelUpdate_set_fee_base_msat(this.ptr, val); } - public int get_fee_proportional_millionths(UnsignedChannelUpdate this_ptr) { - int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_fee_proportional_millionths() { + int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr); return ret; } - public void set_fee_proportional_millionths(UnsignedChannelUpdate this_ptr, int val) { - bindings.UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_fee_proportional_millionths(int val) { + bindings.UnsignedChannelUpdate_set_fee_proportional_millionths(this.ptr, val); } public byte[] write(UnsignedChannelUpdate obj) { @@ -110,8 +99,10 @@ public class UnsignedChannelUpdate extends CommonBase { return ret; } - public UnsignedChannelUpdate(byte[] ser) { - super(bindings.UnsignedChannelUpdate_read(ser)); + public static UnsignedChannelUpdate constructor_read(byte[] ser) { + long ret = bindings.UnsignedChannelUpdate_read(ser); + UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java index 7c336734..4c905aa1 100644 --- a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UnsignedNodeAnnouncement extends CommonBase { UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,71 +14,71 @@ public class UnsignedNodeAnnouncement extends CommonBase { bindings.UnsignedNodeAnnouncement_free(ptr); } - public UnsignedNodeAnnouncement(UnsignedNodeAnnouncement orig) { - super(bindings.UnsignedNodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UnsignedNodeAnnouncement constructor_clone(UnsignedNodeAnnouncement orig) { + long ret = bindings.UnsignedNodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1); + UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public NodeFeatures get_features(UnsignedNodeAnnouncement this_ptr) { - NodeFeatures ret = new NodeFeatures(null, bindings.UnsignedNodeAnnouncement_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public NodeFeatures get_features() { + long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr); + NodeFeatures ret_hu_conv = new NodeFeatures(null, ret); + return ret_hu_conv; } // Skipped UnsignedNodeAnnouncement_set_features - public int get_timestamp(UnsignedNodeAnnouncement this_ptr) { - int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_timestamp() { + int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr); return ret; } - public void set_timestamp(UnsignedNodeAnnouncement this_ptr, int val) { - bindings.UnsignedNodeAnnouncement_set_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_timestamp(int val) { + bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val); } - public byte[] get_node_id(UnsignedNodeAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_node_id() { + byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr); return ret; } - public void set_node_id(UnsignedNodeAnnouncement this_ptr, byte[] val) { - bindings.UnsignedNodeAnnouncement_set_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_node_id(byte[] val) { + bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val); } - public byte[] get_rgb(UnsignedNodeAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_rgb() { + byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr); return ret; } - public void set_rgb(UnsignedNodeAnnouncement this_ptr, byte[] val) { - bindings.UnsignedNodeAnnouncement_set_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_rgb(byte[] val) { + bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, val); } - public byte[] get_alias(UnsignedNodeAnnouncement this_ptr) { - byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_alias() { + byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr); return ret; } - public void set_alias(UnsignedNodeAnnouncement this_ptr, byte[] val) { - bindings.UnsignedNodeAnnouncement_set_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_alias(byte[] val) { + bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val); + } + + public void set_addresses(NetAddress[] val) { + bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, Arrays.stream(val).mapToLong(arr_conv_12 -> arr_conv_12.conv_to_c()).toArray()); + /* TODO 2 NetAddress */; } - // Skipped UnsignedNodeAnnouncement_set_addresses public byte[] write(UnsignedNodeAnnouncement obj) { byte[] ret = bindings.UnsignedNodeAnnouncement_write(obj == null ? 0 : obj.ptr & ~1); this.ptrs_to.add(obj); return ret; } - public UnsignedNodeAnnouncement(byte[] ser) { - super(bindings.UnsignedNodeAnnouncement_read(ser)); + public static UnsignedNodeAnnouncement constructor_read(byte[] ser) { + long ret = bindings.UnsignedNodeAnnouncement_read(ser); + UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UpdateAddHTLC.java b/src/main/java/org/ldk/structs/UpdateAddHTLC.java index 2d1baf69..7e33edf0 100644 --- a/src/main/java/org/ldk/structs/UpdateAddHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateAddHTLC.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UpdateAddHTLC extends CommonBase { UpdateAddHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,64 +14,56 @@ public class UpdateAddHTLC extends CommonBase { bindings.UpdateAddHTLC_free(ptr); } - public UpdateAddHTLC(UpdateAddHTLC orig) { - super(bindings.UpdateAddHTLC_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UpdateAddHTLC constructor_clone(UpdateAddHTLC orig) { + long ret = bindings.UpdateAddHTLC_clone(orig == null ? 0 : orig.ptr & ~1); + UpdateAddHTLC ret_hu_conv = new UpdateAddHTLC(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(UpdateAddHTLC this_ptr) { - byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr); return ret; } - public void set_channel_id(UpdateAddHTLC this_ptr, byte[] val) { - bindings.UpdateAddHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.UpdateAddHTLC_set_channel_id(this.ptr, val); } - public long get_htlc_id(UpdateAddHTLC this_ptr) { - long ret = bindings.UpdateAddHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_id() { + long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr); return ret; } - public void set_htlc_id(UpdateAddHTLC this_ptr, long val) { - bindings.UpdateAddHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_id(long val) { + bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val); } - public long get_amount_msat(UpdateAddHTLC this_ptr) { - long ret = bindings.UpdateAddHTLC_get_amount_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_amount_msat() { + long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr); return ret; } - public void set_amount_msat(UpdateAddHTLC this_ptr, long val) { - bindings.UpdateAddHTLC_set_amount_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_amount_msat(long val) { + bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val); } - public byte[] get_payment_hash(UpdateAddHTLC this_ptr) { - byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_hash() { + byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr); return ret; } - public void set_payment_hash(UpdateAddHTLC this_ptr, byte[] val) { - bindings.UpdateAddHTLC_set_payment_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_hash(byte[] val) { + bindings.UpdateAddHTLC_set_payment_hash(this.ptr, val); } - public int get_cltv_expiry(UpdateAddHTLC this_ptr) { - int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_cltv_expiry() { + int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr); return ret; } - public void set_cltv_expiry(UpdateAddHTLC this_ptr, int val) { - bindings.UpdateAddHTLC_set_cltv_expiry(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_cltv_expiry(int val) { + bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val); } public byte[] write(UpdateAddHTLC obj) { @@ -77,8 +72,10 @@ public class UpdateAddHTLC extends CommonBase { return ret; } - public UpdateAddHTLC(byte[] ser) { - super(bindings.UpdateAddHTLC_read(ser)); + public static UpdateAddHTLC constructor_read(byte[] ser) { + long ret = bindings.UpdateAddHTLC_read(ser); + UpdateAddHTLC ret_hu_conv = new UpdateAddHTLC(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UpdateFailHTLC.java b/src/main/java/org/ldk/structs/UpdateFailHTLC.java index 2c4536e8..f533eb37 100644 --- a/src/main/java/org/ldk/structs/UpdateFailHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFailHTLC.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UpdateFailHTLC extends CommonBase { UpdateFailHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,31 +14,29 @@ public class UpdateFailHTLC extends CommonBase { bindings.UpdateFailHTLC_free(ptr); } - public UpdateFailHTLC(UpdateFailHTLC orig) { - super(bindings.UpdateFailHTLC_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UpdateFailHTLC constructor_clone(UpdateFailHTLC orig) { + long ret = bindings.UpdateFailHTLC_clone(orig == null ? 0 : orig.ptr & ~1); + UpdateFailHTLC ret_hu_conv = new UpdateFailHTLC(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(UpdateFailHTLC this_ptr) { - byte[] ret = bindings.UpdateFailHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.UpdateFailHTLC_get_channel_id(this.ptr); return ret; } - public void set_channel_id(UpdateFailHTLC this_ptr, byte[] val) { - bindings.UpdateFailHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.UpdateFailHTLC_set_channel_id(this.ptr, val); } - public long get_htlc_id(UpdateFailHTLC this_ptr) { - long ret = bindings.UpdateFailHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_id() { + long ret = bindings.UpdateFailHTLC_get_htlc_id(this.ptr); return ret; } - public void set_htlc_id(UpdateFailHTLC this_ptr, long val) { - bindings.UpdateFailHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_id(long val) { + bindings.UpdateFailHTLC_set_htlc_id(this.ptr, val); } public byte[] write(UpdateFailHTLC obj) { @@ -44,8 +45,10 @@ public class UpdateFailHTLC extends CommonBase { return ret; } - public UpdateFailHTLC(byte[] ser) { - super(bindings.UpdateFailHTLC_read(ser)); + public static UpdateFailHTLC constructor_read(byte[] ser) { + long ret = bindings.UpdateFailHTLC_read(ser); + UpdateFailHTLC ret_hu_conv = new UpdateFailHTLC(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java b/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java index ea74f6d7..1a6c8aea 100644 --- a/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UpdateFailMalformedHTLC extends CommonBase { UpdateFailMalformedHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,42 +14,38 @@ public class UpdateFailMalformedHTLC extends CommonBase { bindings.UpdateFailMalformedHTLC_free(ptr); } - public UpdateFailMalformedHTLC(UpdateFailMalformedHTLC orig) { - super(bindings.UpdateFailMalformedHTLC_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UpdateFailMalformedHTLC constructor_clone(UpdateFailMalformedHTLC orig) { + long ret = bindings.UpdateFailMalformedHTLC_clone(orig == null ? 0 : orig.ptr & ~1); + UpdateFailMalformedHTLC ret_hu_conv = new UpdateFailMalformedHTLC(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(UpdateFailMalformedHTLC this_ptr) { - byte[] ret = bindings.UpdateFailMalformedHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.UpdateFailMalformedHTLC_get_channel_id(this.ptr); return ret; } - public void set_channel_id(UpdateFailMalformedHTLC this_ptr, byte[] val) { - bindings.UpdateFailMalformedHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.UpdateFailMalformedHTLC_set_channel_id(this.ptr, val); } - public long get_htlc_id(UpdateFailMalformedHTLC this_ptr) { - long ret = bindings.UpdateFailMalformedHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_id() { + long ret = bindings.UpdateFailMalformedHTLC_get_htlc_id(this.ptr); return ret; } - public void set_htlc_id(UpdateFailMalformedHTLC this_ptr, long val) { - bindings.UpdateFailMalformedHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_id(long val) { + bindings.UpdateFailMalformedHTLC_set_htlc_id(this.ptr, val); } - public short get_failure_code(UpdateFailMalformedHTLC this_ptr) { - short ret = bindings.UpdateFailMalformedHTLC_get_failure_code(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public short get_failure_code() { + short ret = bindings.UpdateFailMalformedHTLC_get_failure_code(this.ptr); return ret; } - public void set_failure_code(UpdateFailMalformedHTLC this_ptr, short val) { - bindings.UpdateFailMalformedHTLC_set_failure_code(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_failure_code(short val) { + bindings.UpdateFailMalformedHTLC_set_failure_code(this.ptr, val); } public byte[] write(UpdateFailMalformedHTLC obj) { @@ -55,8 +54,10 @@ public class UpdateFailMalformedHTLC extends CommonBase { return ret; } - public UpdateFailMalformedHTLC(byte[] ser) { - super(bindings.UpdateFailMalformedHTLC_read(ser)); + public static UpdateFailMalformedHTLC constructor_read(byte[] ser) { + long ret = bindings.UpdateFailMalformedHTLC_read(ser); + UpdateFailMalformedHTLC ret_hu_conv = new UpdateFailMalformedHTLC(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UpdateFee.java b/src/main/java/org/ldk/structs/UpdateFee.java index e915bad0..77f14f6c 100644 --- a/src/main/java/org/ldk/structs/UpdateFee.java +++ b/src/main/java/org/ldk/structs/UpdateFee.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UpdateFee extends CommonBase { UpdateFee(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,35 +14,35 @@ public class UpdateFee extends CommonBase { bindings.UpdateFee_free(ptr); } - public UpdateFee(UpdateFee orig) { - super(bindings.UpdateFee_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UpdateFee constructor_clone(UpdateFee orig) { + long ret = bindings.UpdateFee_clone(orig == null ? 0 : orig.ptr & ~1); + UpdateFee ret_hu_conv = new UpdateFee(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(UpdateFee this_ptr) { - byte[] ret = bindings.UpdateFee_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.UpdateFee_get_channel_id(this.ptr); return ret; } - public void set_channel_id(UpdateFee this_ptr, byte[] val) { - bindings.UpdateFee_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.UpdateFee_set_channel_id(this.ptr, val); } - public int get_feerate_per_kw(UpdateFee this_ptr) { - int ret = bindings.UpdateFee_get_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public int get_feerate_per_kw() { + int ret = bindings.UpdateFee_get_feerate_per_kw(this.ptr); return ret; } - public void set_feerate_per_kw(UpdateFee this_ptr, int val) { - bindings.UpdateFee_set_feerate_per_kw(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_feerate_per_kw(int val) { + bindings.UpdateFee_set_feerate_per_kw(this.ptr, val); } - public UpdateFee(byte[] channel_id_arg, int feerate_per_kw_arg) { - super(bindings.UpdateFee_new(channel_id_arg, feerate_per_kw_arg)); + public static UpdateFee constructor_new(byte[] channel_id_arg, int feerate_per_kw_arg) { + long ret = bindings.UpdateFee_new(channel_id_arg, feerate_per_kw_arg); + UpdateFee ret_hu_conv = new UpdateFee(null, ret); + return ret_hu_conv; } public byte[] write(UpdateFee obj) { @@ -48,8 +51,10 @@ public class UpdateFee extends CommonBase { return ret; } - public UpdateFee(byte[] ser) { - super(bindings.UpdateFee_read(ser)); + public static UpdateFee constructor_read(byte[] ser) { + long ret = bindings.UpdateFee_read(ser); + UpdateFee ret_hu_conv = new UpdateFee(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java b/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java index a373425c..cf1a60c1 100644 --- a/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UpdateFulfillHTLC extends CommonBase { UpdateFulfillHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,46 +14,44 @@ public class UpdateFulfillHTLC extends CommonBase { bindings.UpdateFulfillHTLC_free(ptr); } - public UpdateFulfillHTLC(UpdateFulfillHTLC orig) { - super(bindings.UpdateFulfillHTLC_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UpdateFulfillHTLC constructor_clone(UpdateFulfillHTLC orig) { + long ret = bindings.UpdateFulfillHTLC_clone(orig == null ? 0 : orig.ptr & ~1); + UpdateFulfillHTLC ret_hu_conv = new UpdateFulfillHTLC(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public byte[] get_channel_id(UpdateFulfillHTLC this_ptr) { - byte[] ret = bindings.UpdateFulfillHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr); return ret; } - public void set_channel_id(UpdateFulfillHTLC this_ptr, byte[] val) { - bindings.UpdateFulfillHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, val); } - public long get_htlc_id(UpdateFulfillHTLC this_ptr) { - long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_htlc_id() { + long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr); return ret; } - public void set_htlc_id(UpdateFulfillHTLC this_ptr, long val) { - bindings.UpdateFulfillHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_htlc_id(long val) { + bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val); } - public byte[] get_payment_preimage(UpdateFulfillHTLC this_ptr) { - byte[] ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_payment_preimage() { + byte[] ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr); return ret; } - public void set_payment_preimage(UpdateFulfillHTLC this_ptr, byte[] val) { - bindings.UpdateFulfillHTLC_set_payment_preimage(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_payment_preimage(byte[] val) { + bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, val); } - public UpdateFulfillHTLC(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) { - super(bindings.UpdateFulfillHTLC_new(channel_id_arg, htlc_id_arg, payment_preimage_arg)); + public static UpdateFulfillHTLC constructor_new(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) { + long ret = bindings.UpdateFulfillHTLC_new(channel_id_arg, htlc_id_arg, payment_preimage_arg); + UpdateFulfillHTLC ret_hu_conv = new UpdateFulfillHTLC(null, ret); + return ret_hu_conv; } public byte[] write(UpdateFulfillHTLC obj) { @@ -59,8 +60,10 @@ public class UpdateFulfillHTLC extends CommonBase { return ret; } - public UpdateFulfillHTLC(byte[] ser) { - super(bindings.UpdateFulfillHTLC_read(ser)); + public static UpdateFulfillHTLC constructor_read(byte[] ser) { + long ret = bindings.UpdateFulfillHTLC_read(ser); + UpdateFulfillHTLC ret_hu_conv = new UpdateFulfillHTLC(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index 5ebd15c9..446270d4 100644 --- a/src/main/java/org/ldk/structs/UserConfig.java +++ b/src/main/java/org/ldk/structs/UserConfig.java @@ -2,7 +2,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class UserConfig extends CommonBase { UserConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") @@ -11,56 +14,59 @@ public class UserConfig extends CommonBase { bindings.UserConfig_free(ptr); } - public UserConfig(UserConfig orig) { - super(bindings.UserConfig_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public static UserConfig constructor_clone(UserConfig orig) { + long ret = bindings.UserConfig_clone(orig == null ? 0 : orig.ptr & ~1); + UserConfig ret_hu_conv = new UserConfig(null, ret); + ret_hu_conv.ptrs_to.add(orig); + return ret_hu_conv; } - public ChannelHandshakeConfig get_own_channel_config(UserConfig this_ptr) { - ChannelHandshakeConfig ret = new ChannelHandshakeConfig(null, bindings.UserConfig_get_own_channel_config(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelHandshakeConfig get_own_channel_config() { + long ret = bindings.UserConfig_get_own_channel_config(this.ptr); + ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret); + return ret_hu_conv; } - public void set_own_channel_config(UserConfig this_ptr, ChannelHandshakeConfig val) { - bindings.UserConfig_set_own_channel_config(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_own_channel_config(ChannelHandshakeConfig val) { + bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public ChannelHandshakeLimits get_peer_channel_config_limits(UserConfig this_ptr) { - ChannelHandshakeLimits ret = new ChannelHandshakeLimits(null, bindings.UserConfig_get_peer_channel_config_limits(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelHandshakeLimits get_peer_channel_config_limits() { + long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr); + ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); + return ret_hu_conv; } - public void set_peer_channel_config_limits(UserConfig this_ptr, ChannelHandshakeLimits val) { - bindings.UserConfig_set_peer_channel_config_limits(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_peer_channel_config_limits(ChannelHandshakeLimits val) { + bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public ChannelConfig get_channel_options(UserConfig this_ptr) { - ChannelConfig ret = new ChannelConfig(null, bindings.UserConfig_get_channel_options(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public ChannelConfig get_channel_options() { + long ret = bindings.UserConfig_get_channel_options(this.ptr); + ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); + return ret_hu_conv; } - public void set_channel_options(UserConfig this_ptr, ChannelConfig val) { - bindings.UserConfig_set_channel_options(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_channel_options(ChannelConfig val) { + bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - public UserConfig(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg) { - super(bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1)); - this.ptrs_to.add(own_channel_config_arg); - this.ptrs_to.add(peer_channel_config_limits_arg); - this.ptrs_to.add(channel_options_arg); + public static UserConfig constructor_new(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg) { + long ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1); + UserConfig ret_hu_conv = new UserConfig(null, ret); + ret_hu_conv.ptrs_to.add(own_channel_config_arg); + ret_hu_conv.ptrs_to.add(peer_channel_config_limits_arg); + ret_hu_conv.ptrs_to.add(channel_options_arg); + return ret_hu_conv; } - public UserConfig() { - super(bindings.UserConfig_default()); + public static UserConfig constructor_default() { + long ret = bindings.UserConfig_default(); + UserConfig ret_hu_conv = new UserConfig(null, ret); + return ret_hu_conv; } } diff --git a/src/main/java/org/ldk/structs/Watch.java b/src/main/java/org/ldk/structs/Watch.java index 8ba612df..c237ed3e 100644 --- a/src/main/java/org/ldk/structs/Watch.java +++ b/src/main/java/org/ldk/structs/Watch.java @@ -1,9 +1,11 @@ package org.ldk.structs; import org.ldk.impl.bindings; - import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Watch extends CommonBase { Watch(Object _dummy, long ptr) { super(ptr); } public Watch(bindings.LDKWatch arg) { @@ -17,5 +19,15 @@ public class Watch extends CommonBase { // Skipped Watch_watch_channel // Skipped Watch_update_channel - // Skipped Watch_release_pending_monitor_events + public MonitorEvent[] release_pending_monitor_events() { + long[] ret = bindings.Watch_release_pending_monitor_events(this.ptr); + MonitorEvent[] arr_conv_14_arr = new MonitorEvent[ret.length]; + for (int o = 0; o < ret.length; o++) { + long arr_conv_14 = ret[o]; + MonitorEvent arr_conv_14_hu_conv = new MonitorEvent(null, arr_conv_14); + arr_conv_14_arr[o] = arr_conv_14_hu_conv; + } + return arr_conv_14_arr; + } + } diff --git a/src/main/java/org/ldk/util/ThreeTuple.java b/src/main/java/org/ldk/util/ThreeTuple.java new file mode 100644 index 00000000..ff63e71f --- /dev/null +++ b/src/main/java/org/ldk/util/ThreeTuple.java @@ -0,0 +1,12 @@ +package org.ldk.util; + +public class ThreeTuple { + public A a; + public B b; + public C c; + public ThreeTuple(A a, B b, C c) { + this.a = a; + this.b = b; + this.c = c; + } +} diff --git a/src/main/java/org/ldk/util/TwoTuple.java b/src/main/java/org/ldk/util/TwoTuple.java new file mode 100644 index 00000000..32b4a910 --- /dev/null +++ b/src/main/java/org/ldk/util/TwoTuple.java @@ -0,0 +1,10 @@ +package org.ldk.util; + +public class TwoTuple { + public A a; + public B b; + public TwoTuple(A a, B b) { + this.a = a; + this.b = b; + } +} diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 36a107ed..57f35b9c 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -61,6 +61,7 @@ static void alloc_freed(void* ptr) { __real_free(it); } static void FREE(void* ptr) { + if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); } @@ -458,8 +459,8 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonito JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg; CHECK(!val->result_ok); - jclass ret = LDKChannelMonitorUpdateErr_to_java(_env, (*val->contents.err)); - return ret; + jclass err_conv = LDKChannelMonitorUpdateErr_to_java(_env, (*val->contents.err)); + return err_conv; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok; @@ -472,8 +473,16 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdate JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg; CHECK(!val->result_ok); - LDKMonitorUpdateError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKMonitorUpdateError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) { LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z"); @@ -512,15 +521,27 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIE } return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlongArray b) { LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut"); LDKThirtyTwoBytes a_ref; CHECK((*_env)->GetArrayLength (_env, a) == 32); (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data); ret->a = a_ref; - LDKCVecTempl_TxOut b_conv = *(LDKCVecTempl_TxOut*)b; - FREE((void*)b); - ret->b = b_conv; + LDKCVecTempl_TxOut b_constr; + b_constr.datalen = (*_env)->GetArrayLength (_env, b); + if (b_constr.datalen > 0) + b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVecTempl_TxOut Elements"); + else + b_constr.data = NULL; + long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL); + for (size_t h = 0; h < b_constr.datalen; h++) { + long arr_conv_7 = b_vals[h]; + LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7; + FREE((void*)arr_conv_7); + b_constr.data[h] = arr_conv_7_conv; + } + (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0); + ret->b = b_constr; return (long)ret; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) { @@ -533,15 +554,26 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1ar LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr; return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature)); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jobjectArray b) { LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature"); LDKSignature a_ref; CHECK((*_env)->GetArrayLength (_env, a) == 64); (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form); ret->a = a_ref; - LDKCVecTempl_Signature b_conv = *(LDKCVecTempl_Signature*)b; - FREE((void*)b); - ret->b = b_conv; + LDKCVecTempl_Signature b_constr; + b_constr.datalen = (*_env)->GetArrayLength (_env, b); + if (b_constr.datalen > 0) + b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVecTempl_Signature Elements"); + else + b_constr.data = NULL; + for (size_t i = 0; i < b_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + b_constr.data[i] = arr_conv_8_ref; + } + ret->b = b_constr; return (long)ret; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { @@ -550,9 +582,8 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1Signa JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg; CHECK(val->result_ok); - LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature"); - *ret = (*val->contents.result); - return (long)ret; + long res_ref = (long)&(*val->contents.result); + return res_ref; } JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg; @@ -565,9 +596,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg; CHECK(val->result_ok); - jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64); - (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, (*val->contents.result).compact_form); - return arg_arr; + jbyteArray res_arr = (*_env)->NewByteArray(_env, 64); + (*_env)->SetByteArrayRegion(_env, res_arr, 0, 64, (*val->contents.result).compact_form); + return res_arr; } JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg; @@ -577,12 +608,16 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1g JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg; CHECK(val->result_ok); - LDKCVecTempl_Signature* ret = MALLOC(sizeof(LDKCVecTempl_Signature), "LDKCVecTempl_Signature"); - *ret = (*val->contents.result); - return (long)ret; + LDKCVecTempl_Signature res_var = (*val->contents.result); + jobjectArray res_arr = (*_env)->NewObjectArray(_env, res_var.datalen, NULL, NULL); + for (size_t i = 0; i < res_var.datalen; i++) { + jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 64); + (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form); + (*_env)->SetObjectArrayElement(_env, res_arr, i, arr_conv_8_arr);} + return res_arr; } JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg; @@ -613,7 +648,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv LDKAPIError_RouteError_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;")); CHECK(LDKAPIError_RouteError_class != NULL); - LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "", "(J)V"); + LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "", "(Ljava/lang/String;)V"); CHECK(LDKAPIError_RouteError_meth != NULL); LDKAPIError_ChannelUnavailable_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;")); @@ -642,8 +677,13 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr return (*_env)->NewObject(_env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate); } case LDKAPIError_RouteError: { - long err_ref = (long)&obj->route_error.err; - return (*_env)->NewObject(_env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_ref); + LDKStr err_str = obj->route_error.err; + char* err_buf = MALLOC(err_str.len + 1, "str conv buf"); + memcpy(err_buf, err_str.chars, err_str.len); + err_buf[err_str.len] = 0; + jstring err_conv = (*_env)->NewStringUTF(_env, err_str.chars); + FREE(err_buf); + return (*_env)->NewObject(_env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv); } case LDKAPIError_ChannelUnavailable: { LDKCVec_u8Z err_var = obj->channel_unavailable.err; @@ -668,9 +708,8 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1ge JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg; CHECK(!val->result_ok); - LDKAPIError* ret = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); - *ret = (*val->contents.err); - return (long)ret; + long err_ref = (long)&(*val->contents.err); + return err_ref; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok; @@ -683,8 +722,16 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFa JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg; CHECK(!val->result_ok); - LDKPaymentSendFailure ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKPaymentSendFailure err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *_env, jclass _b, jlong a, jlong b, jlong c) { LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate"); @@ -719,8 +766,16 @@ JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErr JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg; CHECK(!val->result_ok); - LDKPeerHandleError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKPeerHandleError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) { LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature"); @@ -880,7 +935,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * e LDKEvent_SpendableOutputs_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;")); CHECK(LDKEvent_SpendableOutputs_class != NULL); - LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "", "(J)V"); + LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "", "([J)V"); CHECK(LDKEvent_SpendableOutputs_meth != NULL); } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * _env, jclass _c, jlong ptr) { @@ -927,8 +982,15 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (J return (*_env)->NewObject(_env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable); } case LDKEvent_SpendableOutputs: { - long outputs_ref = (long)&obj->spendable_outputs.outputs; - return (*_env)->NewObject(_env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_ref); + LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs; + jlongArray outputs_arr = (*_env)->NewLongArray(_env, outputs_var.datalen); + jlong *outputs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, outputs_arr, NULL); + for (size_t b = 0; b < outputs_var.datalen; b++) { + long arr_conv_27_ref = (long)&outputs_var.data[b]; + outputs_arr_ptr[b] = arr_conv_27_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, outputs_arr, outputs_arr_ptr, 0); + return (*_env)->NewObject(_env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr); } default: abort(); } @@ -1401,10 +1463,22 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* thi DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_and_clear_pending_msg_events_meth); - LDKCVec_MessageSendEventZ res = *ret; - FREE(ret); - return res; + jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_msg_events_meth); + LDKCVec_MessageSendEventZ ret_constr; + ret_constr.datalen = (*_env)->GetArrayLength (_env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); + else + ret_constr.data = NULL; + long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL); + for (size_t s = 0; s < ret_constr.datalen; s++) { + long arr_conv_18 = ret_vals[s]; + LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18; + FREE((void*)arr_conv_18); + ret_constr.data[s] = arr_conv_18_conv; + } + (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0); + return ret_constr; } static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; @@ -1427,7 +1501,7 @@ static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JN atomic_init(&calls->refcnt, 1); DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J"); + calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J"); CHECK(calls->get_and_clear_pending_msg_events_meth != NULL); LDKMessageSendEventsProvider ret = { @@ -1447,11 +1521,17 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvide CHECK(ret != NULL); return ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) { LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg; - LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ"); - *ret = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg); - return (long)ret; + LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t s = 0; s < ret_var.datalen; s++) { + long arr_conv_18_ref = (long)&ret_var.data[s]; + ret_arr_ptr[s] = arr_conv_18_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) { @@ -1488,10 +1568,22 @@ LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) { DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_and_clear_pending_events_meth); - LDKCVec_EventZ res = *ret; - FREE(ret); - return res; + jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_and_clear_pending_events_meth); + LDKCVec_EventZ ret_constr; + ret_constr.datalen = (*_env)->GetArrayLength (_env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements"); + else + ret_constr.data = NULL; + long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL); + for (size_t h = 0; h < ret_constr.datalen; h++) { + long arr_conv_7 = ret_vals[h]; + LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7; + FREE((void*)arr_conv_7); + ret_constr.data[h] = arr_conv_7_conv; + } + (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0); + return ret_constr; } static void LDKEventsProvider_JCalls_free(void* this_arg) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; @@ -1514,7 +1606,7 @@ static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, atomic_init(&calls->refcnt, 1); DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J"); + calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J"); CHECK(calls->get_and_clear_pending_events_meth != NULL); LDKEventsProvider ret = { @@ -1534,11 +1626,17 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj CHECK(ret != NULL); return ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) { LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg; - LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ"); - *ret = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg); - return (long)ret; + LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t h = 0; h < ret_var.datalen; h++) { + long arr_conv_7_ref = (long)&ret_var.data[h]; + ret_arr_ptr[h] = arr_conv_7_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } typedef struct LDKLogger_JCalls { @@ -1603,15 +1701,14 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErr JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg; CHECK(val->result_ok); - LDKTxOut* ret = MALLOC(sizeof(LDKTxOut), "LDKTxOut"); - *ret = (*val->contents.result); - return (long)ret; + long res_ref = (long)&(*val->contents.result); + return res_ref; } JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg; CHECK(!val->result_ok); - jclass ret = LDKAccessError_to_java(_env, (*val->contents.err)); - return ret; + jclass err_conv = LDKAccessError_to_java(_env, (*val->contents.err)); + return err_conv; } typedef struct LDKAccess_JCalls { atomic_size_t refcnt; @@ -1772,10 +1869,26 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_j JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); long commitment_tx_ref = (long)&commitment_tx; - long htlcs_ref = (long)&htlcs; + LDKCVec_HTLCOutputInCommitmentZ htlcs_var = htlcs; + jlongArray htlcs_arr = (*_env)->NewLongArray(_env, htlcs_var.datalen); + jlong *htlcs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, htlcs_arr, NULL); + for (size_t y = 0; y < htlcs_var.datalen; y++) { + LDKHTLCOutputInCommitment arr_conv_24_var = htlcs_var.data[y]; + CHECK((((long)arr_conv_24_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_24_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_24_ref; + if (arr_conv_24_var.is_owned) { + arr_conv_24_ref = (long)arr_conv_24_var.inner | 1; + } else { + arr_conv_24_ref = (long)&arr_conv_24_var; + } + htlcs_arr_ptr[y] = arr_conv_24_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, htlcs_arr, htlcs_arr_ptr, 0); + FREE(htlcs_var.data); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_ref); + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_arr); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret; FREE(ret); return res; @@ -1888,7 +2001,7 @@ static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobje CHECK(calls->release_commitment_secret_meth != NULL); calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J"); CHECK(calls->key_derivation_params_meth != NULL); - calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J"); + calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJ[J)J"); CHECK(calls->sign_counterparty_commitment_meth != NULL); calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J"); CHECK(calls->sign_holder_commitment_meth != NULL); @@ -1954,17 +2067,32 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_ return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlong htlcs) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlongArray htlcs) { LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg; LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx; FREE((void*)commitment_tx); LDKPreCalculatedTxCreationKeys keys_conv; keys_conv.inner = (void*)(keys & (~1)); keys_conv.is_owned = (keys & 1) || (keys == 0); - LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs; - FREE((void*)htlcs); + LDKCVec_HTLCOutputInCommitmentZ htlcs_constr; + htlcs_constr.datalen = (*_env)->GetArrayLength (_env, htlcs); + if (htlcs_constr.datalen > 0) + htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements"); + else + htlcs_constr.data = NULL; + long* htlcs_vals = (*_env)->GetLongArrayElements (_env, htlcs, NULL); + for (size_t y = 0; y < htlcs_constr.datalen; y++) { + long arr_conv_24 = htlcs_vals[y]; + LDKHTLCOutputInCommitment arr_conv_24_conv; + arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1)); + arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0); + if (arr_conv_24_conv.inner != NULL) + arr_conv_24_conv = HTLCOutputInCommitment_clone(&arr_conv_24_conv); + htlcs_constr.data[y] = arr_conv_24_conv; + } + (*_env)->ReleaseLongArrayElements (_env, htlcs, htlcs_vals, 0); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); - *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_conv); + *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_constr); return (long)ret; } @@ -2149,10 +2277,24 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*_env)->CallLongMethod(_env, obj, j_calls->release_pending_monitor_events_meth); - LDKCVec_MonitorEventZ res = *ret; - FREE(ret); - return res; + jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->release_pending_monitor_events_meth); + LDKCVec_MonitorEventZ ret_constr; + ret_constr.datalen = (*_env)->GetArrayLength (_env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements"); + else + ret_constr.data = NULL; + long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL); + for (size_t o = 0; o < ret_constr.datalen; o++) { + long arr_conv_14 = ret_vals[o]; + LDKMonitorEvent arr_conv_14_conv; + arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1)); + arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0); + // Warning: we may need a move here but can't clone! + ret_constr.data[o] = arr_conv_14_conv; + } + (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0); + return ret_constr; } static void LDKWatch_JCalls_free(void* this_arg) { LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; @@ -2179,7 +2321,7 @@ static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) { CHECK(calls->watch_channel_meth != NULL); calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J"); CHECK(calls->update_channel_meth != NULL); - calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J"); + calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J"); CHECK(calls->release_pending_monitor_events_meth != NULL); LDKWatch ret = { @@ -2234,11 +2376,26 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) { LDKWatch* this_arg_conv = (LDKWatch*)this_arg; - LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ"); - *ret = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg); - return (long)ret; + LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t o = 0; o < ret_var.datalen; o++) { + LDKMonitorEvent arr_conv_14_var = ret_var.data[o]; + CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_14_ref; + if (arr_conv_14_var.is_owned) { + arr_conv_14_ref = (long)arr_conv_14_var.inner | 1; + } else { + arr_conv_14_ref = (long)&arr_conv_14_var; + } + ret_arr_ptr[o] = arr_conv_14_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; } typedef struct LDKFilter_JCalls { @@ -2735,17 +2892,17 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEn LDKNetAddress_IPv4_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;")); CHECK(LDKNetAddress_IPv4_class != NULL); - LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "", "(JS)V"); + LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "", "([BS)V"); CHECK(LDKNetAddress_IPv4_meth != NULL); LDKNetAddress_IPv6_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;")); CHECK(LDKNetAddress_IPv6_class != NULL); - LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "", "(JS)V"); + LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "", "([BS)V"); CHECK(LDKNetAddress_IPv6_meth != NULL); LDKNetAddress_OnionV2_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;")); CHECK(LDKNetAddress_OnionV2_class != NULL); - LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "", "(JS)V"); + LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "", "([BS)V"); CHECK(LDKNetAddress_OnionV2_meth != NULL); LDKNetAddress_OnionV3_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;")); @@ -2757,16 +2914,19 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1p LDKNetAddress *obj = (LDKNetAddress*)ptr; switch(obj->tag) { case LDKNetAddress_IPv4: { - long addr_ref = (long)&obj->i_pv4.addr; - return (*_env)->NewObject(_env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_ref, obj->i_pv4.port); + jbyteArray addr_arr = (*_env)->NewByteArray(_env, 4); + (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 4, obj->i_pv4.addr.data); + return (*_env)->NewObject(_env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port); } case LDKNetAddress_IPv6: { - long addr_ref = (long)&obj->i_pv6.addr; - return (*_env)->NewObject(_env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_ref, obj->i_pv6.port); + jbyteArray addr_arr = (*_env)->NewByteArray(_env, 16); + (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 16, obj->i_pv6.addr.data); + return (*_env)->NewObject(_env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port); } case LDKNetAddress_OnionV2: { - long addr_ref = (long)&obj->onion_v2.addr; - return (*_env)->NewObject(_env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_ref, obj->onion_v2.port); + jbyteArray addr_arr = (*_env)->NewByteArray(_env, 10); + (*_env)->SetByteArrayRegion(_env, addr_arr, 0, 10, obj->onion_v2.addr.data); + return (*_env)->NewObject(_env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port); } case LDKNetAddress_OnionV3: { jbyteArray ed25519_pubkey_arr = (*_env)->NewByteArray(_env, 32); @@ -3532,8 +3692,16 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningE JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg; CHECK(!val->result_ok); - LDKLightningError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKLightningError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) { LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr; @@ -3648,10 +3816,22 @@ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret; - FREE(ret); - return res; + jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr; + ret_constr.datalen = (*_env)->GetArrayLength (_env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements"); + else + ret_constr.data = NULL; + long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL); + for (size_t l = 0; l < ret_constr.datalen; l++) { + long arr_conv_63 = ret_vals[l]; + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63; + FREE((void*)arr_conv_63); + ret_constr.data[l] = arr_conv_63_conv; + } + (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0); + return ret_constr; } LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; @@ -3661,10 +3841,25 @@ LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg (*_env)->SetByteArrayRegion(_env, starting_point_arr, 0, 33, starting_point.compressed_form); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*_env)->CallLongMethod(_env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount); - LDKCVec_NodeAnnouncementZ res = *ret; - FREE(ret); - return res; + jlongArray ret = (*_env)->CallObjectMethod(_env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount); + LDKCVec_NodeAnnouncementZ ret_constr; + ret_constr.datalen = (*_env)->GetArrayLength (_env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements"); + else + ret_constr.data = NULL; + long* ret_vals = (*_env)->GetLongArrayElements (_env, ret, NULL); + for (size_t s = 0; s < ret_constr.datalen; s++) { + long arr_conv_18 = ret_vals[s]; + LDKNodeAnnouncement arr_conv_18_conv; + arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1)); + arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0); + if (arr_conv_18_conv.inner != NULL) + arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv); + ret_constr.data[s] = arr_conv_18_conv; + } + (*_env)->ReleaseLongArrayElements (_env, ret, ret_vals, 0); + return ret_constr; } bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; @@ -3705,9 +3900,9 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * e CHECK(calls->handle_channel_update_meth != NULL); calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V"); CHECK(calls->handle_htlc_fail_channel_update_meth != NULL); - calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J"); + calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J"); CHECK(calls->get_next_channel_announcements_meth != NULL); - calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)J"); + calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J"); CHECK(calls->get_next_node_announcements_meth != NULL); calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z"); CHECK(calls->should_request_full_sync_meth != NULL); @@ -3771,21 +3966,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_ (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jlong starting_point, jbyte batch_amount) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jlong starting_point, jbyte batch_amount) { LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg; - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ"); - *ret = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); - return (long)ret; + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t l = 0; l < ret_var.datalen; l++) { + long arr_conv_63_ref = (long)&ret_var.data[l]; + ret_arr_ptr[l] = arr_conv_63_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray starting_point, jbyte batch_amount) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray starting_point, jbyte batch_amount) { LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg; LDKPublicKey starting_point_ref; CHECK((*_env)->GetArrayLength (_env, starting_point) == 33); (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form); - LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ"); - *ret = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); - return (long)ret; + LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t s = 0; s < ret_var.datalen; s++) { + LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s]; + CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_18_ref; + if (arr_conv_18_var.is_owned) { + arr_conv_18_ref = (long)arr_conv_18_var.inner | 1; + } else { + arr_conv_18_ref = (long)&arr_conv_18_var; + } + ret_arr_ptr[s] = arr_conv_18_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray node_id) { @@ -3923,16 +4139,24 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerH JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg; CHECK(val->result_ok); - LDKCVecTempl_u8 arg_var = (*val->contents.result); - jbyteArray arg_arr = (*_env)->NewByteArray(_env, arg_var.datalen); - (*_env)->SetByteArrayRegion(_env, arg_arr, 0, arg_var.datalen, arg_var.data); - return arg_arr; + LDKCVecTempl_u8 res_var = (*val->contents.result); + jbyteArray res_arr = (*_env)->NewByteArray(_env, res_var.datalen); + (*_env)->SetByteArrayRegion(_env, res_arr, 0, res_var.datalen, res_var.data); + return res_arr; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg; CHECK(!val->result_ok); - LDKPeerHandleError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKPeerHandleError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok; @@ -3945,8 +4169,16 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandle JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg; CHECK(!val->result_ok); - LDKPeerHandleError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKPeerHandleError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok; @@ -3954,15 +4186,15 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpE JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg; CHECK(val->result_ok); - jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32); - (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (*val->contents.result).bytes); - return arg_arr; + jbyteArray res_arr = (*_env)->NewByteArray(_env, 32); + (*_env)->SetByteArrayRegion(_env, res_arr, 0, 32, (*val->contents.result).bytes); + return res_arr; } JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg; CHECK(!val->result_ok); - jclass ret = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); - return ret; + jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); + return err_conv; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok; @@ -3970,15 +4202,15 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpE JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg; CHECK(val->result_ok); - jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33); - (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (*val->contents.result).compressed_form); - return arg_arr; + jbyteArray res_arr = (*_env)->NewByteArray(_env, 33); + (*_env)->SetByteArrayRegion(_env, res_arr, 0, 33, (*val->contents.result).compressed_form); + return res_arr; } JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg; CHECK(!val->result_ok); - jclass ret = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); - return ret; + jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); + return err_conv; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok; @@ -3986,14 +4218,22 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeys JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg; CHECK(val->result_ok); - LDKTxCreationKeys ret = (*val->contents.result); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKTxCreationKeys res_var = (*val->contents.result); + CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long res_ref; + if (res_var.is_owned) { + res_ref = (long)res_var.inner | 1; + } else { + res_ref = (long)&res_var; + } + return res_ref; } JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg; CHECK(!val->result_ok); - jclass ret = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); - return ret; + jclass err_conv = LDKSecp256k1Error_to_java(_env, (*val->contents.err)); + return err_conv; } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) { LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr; @@ -4053,38 +4293,36 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1Ro LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr; return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop)); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){ - LDKCVecTempl_CVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_CVecTempl_RouteHop), "LDKCVecTempl_CVecTempl_RouteHop"); - ret->datalen = (*env)->GetArrayLength(env, elems); - if (ret->datalen == 0) { - ret->data = NULL; - } else { - ret->data = MALLOC(sizeof(LDKCVecTempl_RouteHop) * ret->datalen, "LDKCVecTempl_CVecTempl_RouteHop Data"); - jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL); - for (size_t i = 0; i < ret->datalen; i++) { - jlong arr_elem = java_elems[i]; - LDKCVecTempl_RouteHop arr_elem_conv = *(LDKCVecTempl_RouteHop*)arr_elem; - FREE((void*)arr_elem); - ret->data[i] = arr_elem_conv; - } - (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0); - } - return (long)ret; -} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg; CHECK(val->result_ok); - LDKRoute ret = (*val->contents.result); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKRoute res_var = (*val->contents.result); + CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long res_ref; + if (res_var.is_owned) { + res_ref = (long)res_var.inner | 1; + } else { + res_ref = (long)&res_var; + } + return res_ref; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg; CHECK(!val->result_ok); - LDKLightningError ret = (*val->contents.err); - return ((long)ret.inner) | (ret.is_owned ? 1 : 0); + LDKLightningError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref; + if (err_var.is_owned) { + err_ref = (long)err_var.inner | 1; + } else { + err_ref = (long)&err_var; + } + return err_ref; } JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) { LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr; @@ -4180,11 +4418,22 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ CResult_CVec_SignatureZNoneZ_free(arg_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg; - FREE((void*)arg); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jobjectArray arg) { + LDKCVec_SignatureZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements"); + else + arg_constr.data = NULL; + for (size_t i = 0; i < arg_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + arg_constr.data[i] = arr_conv_8_ref; + } LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ"); - *ret = CResult_CVec_SignatureZNoneZ_ok(arg_conv); + *ret = CResult_CVec_SignatureZNoneZ_ok(arg_constr); return (long)ret; } @@ -4449,154 +4698,472 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ return (long)ret; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)arg; - FREE((void*)arg); - CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_conv = *(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ*)arg; - FREE((void*)arg); - CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_C2Tuple_usizeTransactionZZ arg_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)arg; - FREE((void*)arg); - CVec_C2Tuple_usizeTransactionZZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_conv = *(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)arg; - FREE((void*)arg); - CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_CVec_RouteHopZZ arg_conv = *(LDKCVec_CVec_RouteHopZZ*)arg; - FREE((void*)arg); - CVec_CVec_RouteHopZZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_ChannelDetailsZ arg_conv = *(LDKCVec_ChannelDetailsZ*)arg; - FREE((void*)arg); - CVec_ChannelDetailsZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_ChannelMonitorZ arg_conv = *(LDKCVec_ChannelMonitorZ*)arg; - FREE((void*)arg); - CVec_ChannelMonitorZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_EventZ arg_conv = *(LDKCVec_EventZ*)arg; - FREE((void*)arg); - CVec_EventZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_HTLCOutputInCommitmentZ arg_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)arg; - FREE((void*)arg); - CVec_HTLCOutputInCommitmentZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_MessageSendEventZ arg_conv = *(LDKCVec_MessageSendEventZ*)arg; - FREE((void*)arg); - CVec_MessageSendEventZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_MonitorEventZ arg_conv = *(LDKCVec_MonitorEventZ*)arg; - FREE((void*)arg); - CVec_MonitorEventZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_NetAddressZ arg_conv = *(LDKCVec_NetAddressZ*)arg; - FREE((void*)arg); - CVec_NetAddressZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_NodeAnnouncementZ arg_conv = *(LDKCVec_NodeAnnouncementZ*)arg; - FREE((void*)arg); - CVec_NodeAnnouncementZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_PublicKeyZ arg_conv = *(LDKCVec_PublicKeyZ*)arg; - FREE((void*)arg); - CVec_PublicKeyZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_RouteHintZ arg_conv = *(LDKCVec_RouteHintZ*)arg; - FREE((void*)arg); - CVec_RouteHintZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_RouteHopZ arg_conv = *(LDKCVec_RouteHopZ*)arg; - FREE((void*)arg); - CVec_RouteHopZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg; - FREE((void*)arg); - CVec_SignatureZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_SpendableOutputDescriptorZ arg_conv = *(LDKCVec_SpendableOutputDescriptorZ*)arg; - FREE((void*)arg); - CVec_SpendableOutputDescriptorZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_TransactionZ arg_conv = *(LDKCVec_TransactionZ*)arg; - FREE((void*)arg); - CVec_TransactionZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_TxOutZ arg_conv = *(LDKCVec_TxOutZ*)arg; - FREE((void*)arg); - CVec_TxOutZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_UpdateAddHTLCZ arg_conv = *(LDKCVec_UpdateAddHTLCZ*)arg; - FREE((void*)arg); - CVec_UpdateAddHTLCZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_UpdateFailHTLCZ arg_conv = *(LDKCVec_UpdateFailHTLCZ*)arg; - FREE((void*)arg); - CVec_UpdateFailHTLCZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_UpdateFailMalformedHTLCZ arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)arg; - FREE((void*)arg); - CVec_UpdateFailMalformedHTLCZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_UpdateFulfillHTLCZ arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)arg; - FREE((void*)arg); - CVec_UpdateFulfillHTLCZ_free(arg_conv); -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) { - LDKCVec_u64Z arg_conv = *(LDKCVec_u64Z*)arg; - FREE((void*)arg); - CVec_u64Z_free(arg_conv); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t q = 0; q < arg_constr.datalen; q++) { + long arr_conv_42 = arg_vals[q]; + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42; + FREE((void*)arr_conv_42); + arg_constr.data[q] = arr_conv_42_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t b = 0; b < arg_constr.datalen; b++) { + long arr_conv_27 = arg_vals[b]; + LDKC2Tuple_TxidCVec_TxOutZZ arr_conv_27_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arr_conv_27; + FREE((void*)arr_conv_27); + arg_constr.data[b] = arr_conv_27_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_C2Tuple_usizeTransactionZZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t d = 0; d < arg_constr.datalen; d++) { + long arr_conv_29 = arg_vals[d]; + LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29; + FREE((void*)arr_conv_29); + arg_constr.data[d] = arr_conv_29_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_C2Tuple_usizeTransactionZZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t l = 0; l < arg_constr.datalen; l++) { + long arr_conv_63 = arg_vals[l]; + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63; + FREE((void*)arr_conv_63); + arg_constr.data[l] = arr_conv_63_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) { + LDKCVec_CVec_RouteHopZZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements"); + else + arg_constr.data = NULL; + for (size_t m = 0; m < arg_constr.datalen; m++) { + jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, arg, m); + LDKCVec_RouteHopZ arr_conv_12_constr; + arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12); + if (arr_conv_12_constr.datalen > 0) + arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + arr_conv_12_constr.data = NULL; + long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL); + for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) { + long arr_conv_10 = arr_conv_12_vals[k]; + LDKRouteHop arr_conv_10_conv; + arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1)); + arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0); + arr_conv_12_constr.data[k] = arr_conv_10_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0); + arg_constr.data[m] = arr_conv_12_constr; + } + CVec_CVec_RouteHopZZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_ChannelDetailsZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t q = 0; q < arg_constr.datalen; q++) { + long arr_conv_16 = arg_vals[q]; + LDKChannelDetails arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + arg_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_ChannelDetailsZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_ChannelMonitorZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t q = 0; q < arg_constr.datalen; q++) { + long arr_conv_16 = arg_vals[q]; + LDKChannelMonitor arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + arg_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_ChannelMonitorZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_EventZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t h = 0; h < arg_constr.datalen; h++) { + long arr_conv_7 = arg_vals[h]; + LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7; + FREE((void*)arr_conv_7); + arg_constr.data[h] = arr_conv_7_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_EventZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_HTLCOutputInCommitmentZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t y = 0; y < arg_constr.datalen; y++) { + long arr_conv_24 = arg_vals[y]; + LDKHTLCOutputInCommitment arr_conv_24_conv; + arr_conv_24_conv.inner = (void*)(arr_conv_24 & (~1)); + arr_conv_24_conv.is_owned = (arr_conv_24 & 1) || (arr_conv_24 == 0); + arg_constr.data[y] = arr_conv_24_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_HTLCOutputInCommitmentZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_MessageSendEventZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t s = 0; s < arg_constr.datalen; s++) { + long arr_conv_18 = arg_vals[s]; + LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18; + FREE((void*)arr_conv_18); + arg_constr.data[s] = arr_conv_18_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_MessageSendEventZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_MonitorEventZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t o = 0; o < arg_constr.datalen; o++) { + long arr_conv_14 = arg_vals[o]; + LDKMonitorEvent arr_conv_14_conv; + arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1)); + arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0); + arg_constr.data[o] = arr_conv_14_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_MonitorEventZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_NetAddressZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t m = 0; m < arg_constr.datalen; m++) { + long arr_conv_12 = arg_vals[m]; + LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12; + FREE((void*)arr_conv_12); + arg_constr.data[m] = arr_conv_12_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_NetAddressZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_NodeAnnouncementZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t s = 0; s < arg_constr.datalen; s++) { + long arr_conv_18 = arg_vals[s]; + LDKNodeAnnouncement arr_conv_18_conv; + arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1)); + arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0); + arg_constr.data[s] = arr_conv_18_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_NodeAnnouncementZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) { + LDKCVec_PublicKeyZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements"); + else + arg_constr.data = NULL; + for (size_t i = 0; i < arg_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i); + LDKPublicKey arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 33); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 33, arr_conv_8_ref.compressed_form); + arg_constr.data[i] = arr_conv_8_ref; + } + CVec_PublicKeyZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_RouteHintZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t l = 0; l < arg_constr.datalen; l++) { + long arr_conv_11 = arg_vals[l]; + LDKRouteHint arr_conv_11_conv; + arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1)); + arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0); + arg_constr.data[l] = arr_conv_11_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_RouteHintZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_RouteHopZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t k = 0; k < arg_constr.datalen; k++) { + long arr_conv_10 = arg_vals[k]; + LDKRouteHop arr_conv_10_conv; + arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1)); + arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0); + arg_constr.data[k] = arr_conv_10_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_RouteHopZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jobjectArray arg) { + LDKCVec_SignatureZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements"); + else + arg_constr.data = NULL; + for (size_t i = 0; i < arg_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, arg, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + arg_constr.data[i] = arr_conv_8_ref; + } + CVec_SignatureZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_SpendableOutputDescriptorZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t b = 0; b < arg_constr.datalen; b++) { + long arr_conv_27 = arg_vals[b]; + LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27; + FREE((void*)arr_conv_27); + arg_constr.data[b] = arr_conv_27_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_SpendableOutputDescriptorZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_TransactionZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t n = 0; n < arg_constr.datalen; n++) { + long arr_conv_13 = arg_vals[n]; + LDKTransaction arr_conv_13_conv = *(LDKTransaction*)arr_conv_13; + FREE((void*)arr_conv_13); + arg_constr.data[n] = arr_conv_13_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_TransactionZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_TxOutZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t h = 0; h < arg_constr.datalen; h++) { + long arr_conv_7 = arg_vals[h]; + LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7; + FREE((void*)arr_conv_7); + arg_constr.data[h] = arr_conv_7_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_TxOutZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_UpdateAddHTLCZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t p = 0; p < arg_constr.datalen; p++) { + long arr_conv_15 = arg_vals[p]; + LDKUpdateAddHTLC arr_conv_15_conv; + arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1)); + arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0); + arg_constr.data[p] = arr_conv_15_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_UpdateAddHTLCZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_UpdateFailHTLCZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t q = 0; q < arg_constr.datalen; q++) { + long arr_conv_16 = arg_vals[q]; + LDKUpdateFailHTLC arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + arg_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_UpdateFailHTLCZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_UpdateFailMalformedHTLCZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t z = 0; z < arg_constr.datalen; z++) { + long arr_conv_25 = arg_vals[z]; + LDKUpdateFailMalformedHTLC arr_conv_25_conv; + arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1)); + arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0); + arg_constr.data[z] = arr_conv_25_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_UpdateFailMalformedHTLCZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_UpdateFulfillHTLCZ arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t t = 0; t < arg_constr.datalen; t++) { + long arr_conv_19 = arg_vals[t]; + LDKUpdateFulfillHTLC arr_conv_19_conv; + arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1)); + arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0); + arg_constr.data[t] = arr_conv_19_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_UpdateFulfillHTLCZ_free(arg_constr); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlongArray arg) { + LDKCVec_u64Z arg_constr; + arg_constr.datalen = (*_env)->GetArrayLength (_env, arg); + if (arg_constr.datalen > 0) + arg_constr.data = MALLOC(arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + arg_constr.data = NULL; + long* arg_vals = (*_env)->GetLongArrayElements (_env, arg, NULL); + for (size_t g = 0; g < arg_constr.datalen; g++) { + long arr_conv_6 = arg_vals[g]; + arg_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, arg, arg_vals, 0); + CVec_u64Z_free(arg_constr); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jbyteArray arg) { @@ -4654,14 +5221,26 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlongArray b) { LDKThirtyTwoBytes a_ref; CHECK((*_env)->GetArrayLength (_env, a) == 32); (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data); - LDKCVec_TxOutZ b_conv = *(LDKCVec_TxOutZ*)b; - FREE((void*)b); + LDKCVec_TxOutZ b_constr; + b_constr.datalen = (*_env)->GetArrayLength (_env, b); + if (b_constr.datalen > 0) + b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements"); + else + b_constr.data = NULL; + long* b_vals = (*_env)->GetLongArrayElements (_env, b, NULL); + for (size_t h = 0; h < b_constr.datalen; h++) { + long arr_conv_7 = b_vals[h]; + LDKTxOut arr_conv_7_conv = *(LDKTxOut*)arr_conv_7; + FREE((void*)arr_conv_7); + b_constr.data[h] = arr_conv_7_conv; + } + (*_env)->ReleaseLongArrayElements (_env, b, b_vals, 0); LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ"); - *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_conv); + *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_constr); return (long)ret; } @@ -4671,14 +5250,25 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jobjectArray b) { LDKSignature a_ref; CHECK((*_env)->GetArrayLength (_env, a) == 64); (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form); - LDKCVec_SignatureZ b_conv = *(LDKCVec_SignatureZ*)b; - FREE((void*)b); + LDKCVec_SignatureZ b_constr; + b_constr.datalen = (*_env)->GetArrayLength (_env, b); + if (b_constr.datalen > 0) + b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements"); + else + b_constr.data = NULL; + for (size_t i = 0; i < b_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, b, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + b_constr.data[i] = arr_conv_8_ref; + } LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); - *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_conv); + *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr); return (long)ret; } @@ -5265,7 +5855,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _e ChainMonitor_free(this_ptr_conv); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); @@ -5273,9 +5863,21 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected CHECK((*_env)->GetArrayLength (_env, header) == 80); (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr); unsigned char (*header_ref)[80] = &header_arr; - LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata; - FREE((void*)txdata); - ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height); + LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr; + txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata); + if (txdata_constr.datalen > 0) + txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements"); + else + txdata_constr.data = NULL; + long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL); + for (size_t d = 0; d < txdata_constr.datalen; d++) { + long arr_conv_29 = txdata_vals[d]; + LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29; + FREE((void*)arr_conv_29); + txdata_constr.data[d] = arr_conv_29_conv; + } + (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0); + ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) { @@ -5465,35 +6067,62 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_ return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) { LDKChannelMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); - LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ"); - *ret = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv); - return (long)ret; + LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t o = 0; o < ret_var.datalen; o++) { + LDKMonitorEvent arr_conv_14_var = ret_var.data[o]; + CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_14_ref; + if (arr_conv_14_var.is_owned) { + arr_conv_14_ref = (long)arr_conv_14_var.inner | 1; + } else { + arr_conv_14_ref = (long)&arr_conv_14_var; + } + ret_arr_ptr[o] = arr_conv_14_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) { LDKChannelMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); - LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ"); - *ret = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv); - return (long)ret; + LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t h = 0; h < ret_var.datalen; h++) { + long arr_conv_7_ref = (long)&ret_var.data[h]; + ret_arr_ptr[h] = arr_conv_7_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) { LDKChannelMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); LDKLogger* logger_conv = (LDKLogger*)logger; - LDKCVec_TransactionZ* ret = MALLOC(sizeof(LDKCVec_TransactionZ), "LDKCVec_TransactionZ"); - *ret = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv); - return (long)ret; + LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t n = 0; n < ret_var.datalen; n++) { + long arr_conv_13_ref = (long)&ret_var.data[n]; + ret_arr_ptr[n] = arr_conv_13_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) { LDKChannelMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); @@ -5501,8 +6130,20 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connec CHECK((*_env)->GetArrayLength (_env, header) == 80); (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr); unsigned char (*header_ref)[80] = &header_arr; - LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata; - FREE((void*)txdata); + LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr; + txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata); + if (txdata_constr.datalen > 0) + txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements"); + else + txdata_constr.data = NULL; + long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL); + for (size_t d = 0; d < txdata_constr.datalen; d++) { + long arr_conv_29 = txdata_vals[d]; + LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29; + FREE((void*)arr_conv_29); + txdata_constr.data[d] = arr_conv_29_conv; + } + (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0); LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster; if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. @@ -5518,9 +6159,15 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connec // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_clone(logger_conv.this_arg); } - LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ"); - *ret = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height, broadcaster_conv, fee_estimator_conv, logger_conv); - return (long)ret; + LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t b = 0; b < ret_var.datalen; b++) { + long arr_conv_27_ref = (long)&ret_var.data[b]; + ret_arr_ptr[b] = arr_conv_27_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + return ret_arr; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) { @@ -6106,22 +6753,52 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1chann return (long)ret; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); - LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ"); - *ret = ChannelManager_list_channels(&this_arg_conv); - return (long)ret; + LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKChannelDetails arr_conv_16_var = ret_var.data[q]; + CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_16_ref; + if (arr_conv_16_var.is_owned) { + arr_conv_16_ref = (long)arr_conv_16_var.inner | 1; + } else { + arr_conv_16_ref = (long)&arr_conv_16_var; + } + ret_arr_ptr[q] = arr_conv_16_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); - LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ"); - *ret = ChannelManager_list_usable_channels(&this_arg_conv); - return (long)ret; + LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv); + jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); + jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKChannelDetails arr_conv_16_var = ret_var.data[q]; + CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long arr_conv_16_ref; + if (arr_conv_16_var.is_owned) { + arr_conv_16_ref = (long)arr_conv_16_var.inner | 1; + } else { + arr_conv_16_ref = (long)&arr_conv_16_var; + } + ret_arr_ptr[q] = arr_conv_16_ref; + } + (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) { @@ -6189,7 +6866,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1trans ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray rgb, jbyteArray alias, jlong addresses) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray rgb, jbyteArray alias, jlongArray addresses) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); @@ -6199,9 +6876,21 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1nod LDKThirtyTwoBytes alias_ref; CHECK((*_env)->GetArrayLength (_env, alias) == 32); (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data); - LDKCVec_NetAddressZ addresses_conv = *(LDKCVec_NetAddressZ*)addresses; - FREE((void*)addresses); - ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_conv); + LDKCVec_NetAddressZ addresses_constr; + addresses_constr.datalen = (*_env)->GetArrayLength (_env, addresses); + if (addresses_constr.datalen > 0) + addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements"); + else + addresses_constr.data = NULL; + long* addresses_vals = (*_env)->GetLongArrayElements (_env, addresses, NULL); + for (size_t m = 0; m < addresses_constr.datalen; m++) { + long arr_conv_12 = addresses_vals[m]; + LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12; + FREE((void*)arr_conv_12); + addresses_constr.data[m] = arr_conv_12_conv; + } + (*_env)->ReleaseLongArrayElements (_env, addresses, addresses_vals, 0); + ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) { @@ -6284,7 +6973,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsPro return (long)ret; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlongArray txdata, jint height) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); @@ -6292,9 +6981,21 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connect CHECK((*_env)->GetArrayLength (_env, header) == 80); (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr); unsigned char (*header_ref)[80] = &header_arr; - LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata; - FREE((void*)txdata); - ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_conv, height); + LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr; + txdata_constr.datalen = (*_env)->GetArrayLength (_env, txdata); + if (txdata_constr.datalen > 0) + txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements"); + else + txdata_constr.data = NULL; + long* txdata_vals = (*_env)->GetLongArrayElements (_env, txdata, NULL); + for (size_t d = 0; d < txdata_constr.datalen; d++) { + long arr_conv_29 = txdata_vals[d]; + LDKC2Tuple_usizeTransactionZ arr_conv_29_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_29; + FREE((void*)arr_conv_29); + txdata_constr.data[d] = arr_conv_29_conv; + } + (*_env)->ReleaseLongArrayElements (_env, txdata, txdata_vals, 0); + ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) { @@ -6444,7 +7145,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1d ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv * _env, jclass _b, jlong keys_manager, jlong fee_estimator, jlong chain_monitor, jlong tx_broadcaster, jlong logger, jlong default_config, jlong channel_monitors) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv * _env, jclass _b, jlong keys_manager, jlong fee_estimator, jlong chain_monitor, jlong tx_broadcaster, jlong logger, jlong default_config, jlongArray channel_monitors) { LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager; if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. @@ -6475,9 +7176,23 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(J default_config_conv.is_owned = (default_config & 1) || (default_config == 0); if (default_config_conv.inner != NULL) default_config_conv = UserConfig_clone(&default_config_conv); - LDKCVec_ChannelMonitorZ channel_monitors_conv = *(LDKCVec_ChannelMonitorZ*)channel_monitors; - FREE((void*)channel_monitors); - LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv); + LDKCVec_ChannelMonitorZ channel_monitors_constr; + channel_monitors_constr.datalen = (*_env)->GetArrayLength (_env, channel_monitors); + if (channel_monitors_constr.datalen > 0) + channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements"); + else + channel_monitors_constr.data = NULL; + long* channel_monitors_vals = (*_env)->GetLongArrayElements (_env, channel_monitors, NULL); + for (size_t q = 0; q < channel_monitors_constr.datalen; q++) { + long arr_conv_16 = channel_monitors_vals[q]; + LDKChannelMonitor arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + // Warning: we may need a move here but can't clone! + channel_monitors_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, channel_monitors, channel_monitors_vals, 0); + LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -6537,13 +7252,17 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id ErrorMessage_set_channel_id(&this_ptr_conv, val_ref); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) { +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) { LDKErrorMessage this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr"); - *ret = ErrorMessage_get_data(&this_ptr_conv); - return (long)ret; + LDKStr _str = ErrorMessage_get_data(&this_ptr_conv); + char* _buf = MALLOC(_str.len + 1, "str conv buf"); + memcpy(_buf, _str.chars, _str.len); + _buf[_str.len] = 0; + jstring _conv = (*_env)->NewStringUTF(_env, _str.chars); + FREE(_buf); + return _conv; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) { @@ -7942,25 +8661,47 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signatu CommitmentSigned_set_signature(&this_ptr_conv, val_ref); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) { LDKCommitmentSigned this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_SignatureZ val_conv = *(LDKCVec_SignatureZ*)val; - FREE((void*)val); - CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_conv); + LDKCVec_SignatureZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements"); + else + val_constr.data = NULL; + for (size_t i = 0; i < val_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, val, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + val_constr.data[i] = arr_conv_8_ref; + } + CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg, jlong htlc_signatures_arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg, jobjectArray htlc_signatures_arg) { LDKThirtyTwoBytes channel_id_arg_ref; CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32); (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data); LDKSignature signature_arg_ref; CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64); (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form); - LDKCVec_SignatureZ htlc_signatures_arg_conv = *(LDKCVec_SignatureZ*)htlc_signatures_arg; - FREE((void*)htlc_signatures_arg); - LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_conv); + LDKCVec_SignatureZ htlc_signatures_arg_constr; + htlc_signatures_arg_constr.datalen = (*_env)->GetArrayLength (_env, htlc_signatures_arg); + if (htlc_signatures_arg_constr.datalen > 0) + htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements"); + else + htlc_signatures_arg_constr.data = NULL; + for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) { + jobject arr_conv_8 = (*_env)->GetObjectArrayElement(_env, htlc_signatures_arg, i); + LDKSignature arr_conv_8_ref; + CHECK((*_env)->GetArrayLength (_env, arr_conv_8) == 64); + (*_env)->GetByteArrayRegion (_env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form); + htlc_signatures_arg_constr.data[i] = arr_conv_8_ref; + } + LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -8448,13 +9189,25 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_ UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKUnsignedNodeAnnouncement this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val; - FREE((void*)val); - UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_conv); + LDKCVec_NetAddressZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t m = 0; m < val_constr.datalen; m++) { + long arr_conv_12 = val_vals[m]; + LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12; + FREE((void*)arr_conv_12); + val_constr.data[m] = arr_conv_12_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) { @@ -9158,22 +9911,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1 ReplyChannelRange_set_full_information(&this_ptr_conv, val); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKReplyChannelRange this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val; - FREE((void*)val); - ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_conv); + LDKCVec_u64Z val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t g = 0; g < val_constr.datalen; g++) { + long arr_conv_6 = val_vals[g]; + val_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jint first_blocknum_arg, jint number_of_blocks_arg, jboolean full_information_arg, jlong short_channel_ids_arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jint first_blocknum_arg, jint number_of_blocks_arg, jboolean full_information_arg, jlongArray short_channel_ids_arg) { LDKThirtyTwoBytes chain_hash_arg_ref; CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32); (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data); - LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg; - FREE((void*)short_channel_ids_arg); - LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv); + LDKCVec_u64Z short_channel_ids_arg_constr; + short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg); + if (short_channel_ids_arg_constr.datalen > 0) + short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + short_channel_ids_arg_constr.data = NULL; + long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL); + for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) { + long arr_conv_6 = short_channel_ids_arg_vals[g]; + short_channel_ids_arg_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0); + LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -9211,22 +9984,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1cha QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKQueryShortChannelIds this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val; - FREE((void*)val); - QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_conv); + LDKCVec_u64Z val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t g = 0; g < val_constr.datalen; g++) { + long arr_conv_6 = val_vals[g]; + val_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlong short_channel_ids_arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlongArray short_channel_ids_arg) { LDKThirtyTwoBytes chain_hash_arg_ref; CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32); (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data); - LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg; - FREE((void*)short_channel_ids_arg); - LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_conv); + LDKCVec_u64Z short_channel_ids_arg_constr; + short_channel_ids_arg_constr.datalen = (*_env)->GetArrayLength (_env, short_channel_ids_arg); + if (short_channel_ids_arg_constr.datalen > 0) + short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + short_channel_ids_arg_constr.data = NULL; + long* short_channel_ids_arg_vals = (*_env)->GetLongArrayElements (_env, short_channel_ids_arg, NULL); + for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) { + long arr_conv_6 = short_channel_ids_arg_vals[g]; + short_channel_ids_arg_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, short_channel_ids_arg, short_channel_ids_arg_vals, 0); + LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -9372,13 +10165,17 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * LightningError_free(this_ptr_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) { +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) { LDKLightningError this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr"); - *ret = LightningError_get_err(&this_ptr_conv); - return (long)ret; + LDKStr _str = LightningError_get_err(&this_ptr_conv); + char* _buf = MALLOC(_str.len + 1, "str conv buf"); + memcpy(_buf, _str.chars, _str.len); + _buf[_str.len] = 0; + jstring _conv = (*_env)->NewStringUTF(_env, _str.chars); + FREE(_buf); + return _conv; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) { @@ -9436,40 +10233,100 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEn return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_UpdateAddHTLCZ val_conv = *(LDKCVec_UpdateAddHTLCZ*)val; - FREE((void*)val); - CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_conv); + LDKCVec_UpdateAddHTLCZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t p = 0; p < val_constr.datalen; p++) { + long arr_conv_15 = val_vals[p]; + LDKUpdateAddHTLC arr_conv_15_conv; + arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1)); + arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0); + if (arr_conv_15_conv.inner != NULL) + arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv); + val_constr.data[p] = arr_conv_15_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_UpdateFulfillHTLCZ val_conv = *(LDKCVec_UpdateFulfillHTLCZ*)val; - FREE((void*)val); - CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_conv); + LDKCVec_UpdateFulfillHTLCZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t t = 0; t < val_constr.datalen; t++) { + long arr_conv_19 = val_vals[t]; + LDKUpdateFulfillHTLC arr_conv_19_conv; + arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1)); + arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0); + if (arr_conv_19_conv.inner != NULL) + arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv); + val_constr.data[t] = arr_conv_19_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_UpdateFailHTLCZ val_conv = *(LDKCVec_UpdateFailHTLCZ*)val; - FREE((void*)val); - CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_conv); + LDKCVec_UpdateFailHTLCZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t q = 0; q < val_constr.datalen; q++) { + long arr_conv_16 = val_vals[q]; + LDKUpdateFailHTLC arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + if (arr_conv_16_conv.inner != NULL) + arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv); + val_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_UpdateFailMalformedHTLCZ val_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)val; - FREE((void*)val); - CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_conv); + LDKCVec_UpdateFailMalformedHTLCZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t z = 0; z < val_constr.datalen; z++) { + long arr_conv_25 = val_vals[z]; + LDKUpdateFailMalformedHTLC arr_conv_25_conv; + arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1)); + arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0); + if (arr_conv_25_conv.inner != NULL) + arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv); + val_constr.data[z] = arr_conv_25_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr); } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) { @@ -9512,15 +10369,75 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitm CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv * _env, jclass _b, jlong update_add_htlcs_arg, jlong update_fulfill_htlcs_arg, jlong update_fail_htlcs_arg, jlong update_fail_malformed_htlcs_arg, jlong update_fee_arg, jlong commitment_signed_arg) { - LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_conv = *(LDKCVec_UpdateAddHTLCZ*)update_add_htlcs_arg; - FREE((void*)update_add_htlcs_arg); - LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)update_fulfill_htlcs_arg; - FREE((void*)update_fulfill_htlcs_arg); - LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_conv = *(LDKCVec_UpdateFailHTLCZ*)update_fail_htlcs_arg; - FREE((void*)update_fail_htlcs_arg); - LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)update_fail_malformed_htlcs_arg; - FREE((void*)update_fail_malformed_htlcs_arg); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv * _env, jclass _b, jlongArray update_add_htlcs_arg, jlongArray update_fulfill_htlcs_arg, jlongArray update_fail_htlcs_arg, jlongArray update_fail_malformed_htlcs_arg, jlong update_fee_arg, jlong commitment_signed_arg) { + LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr; + update_add_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_add_htlcs_arg); + if (update_add_htlcs_arg_constr.datalen > 0) + update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements"); + else + update_add_htlcs_arg_constr.data = NULL; + long* update_add_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_add_htlcs_arg, NULL); + for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) { + long arr_conv_15 = update_add_htlcs_arg_vals[p]; + LDKUpdateAddHTLC arr_conv_15_conv; + arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1)); + arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0); + if (arr_conv_15_conv.inner != NULL) + arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv); + update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv; + } + (*_env)->ReleaseLongArrayElements (_env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0); + LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr; + update_fulfill_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fulfill_htlcs_arg); + if (update_fulfill_htlcs_arg_constr.datalen > 0) + update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements"); + else + update_fulfill_htlcs_arg_constr.data = NULL; + long* update_fulfill_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fulfill_htlcs_arg, NULL); + for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) { + long arr_conv_19 = update_fulfill_htlcs_arg_vals[t]; + LDKUpdateFulfillHTLC arr_conv_19_conv; + arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1)); + arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0); + if (arr_conv_19_conv.inner != NULL) + arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv); + update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv; + } + (*_env)->ReleaseLongArrayElements (_env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0); + LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr; + update_fail_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_htlcs_arg); + if (update_fail_htlcs_arg_constr.datalen > 0) + update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements"); + else + update_fail_htlcs_arg_constr.data = NULL; + long* update_fail_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_htlcs_arg, NULL); + for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) { + long arr_conv_16 = update_fail_htlcs_arg_vals[q]; + LDKUpdateFailHTLC arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + if (arr_conv_16_conv.inner != NULL) + arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv); + update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0); + LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr; + update_fail_malformed_htlcs_arg_constr.datalen = (*_env)->GetArrayLength (_env, update_fail_malformed_htlcs_arg); + if (update_fail_malformed_htlcs_arg_constr.datalen > 0) + update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements"); + else + update_fail_malformed_htlcs_arg_constr.data = NULL; + long* update_fail_malformed_htlcs_arg_vals = (*_env)->GetLongArrayElements (_env, update_fail_malformed_htlcs_arg, NULL); + for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) { + long arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z]; + LDKUpdateFailMalformedHTLC arr_conv_25_conv; + arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1)); + arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0); + if (arr_conv_25_conv.inner != NULL) + arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv); + update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv; + } + (*_env)->ReleaseLongArrayElements (_env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0); LDKUpdateFee update_fee_arg_conv; update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1)); update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0); @@ -9531,7 +10448,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0); if (commitment_signed_arg_conv.inner != NULL) commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv); - LDKCommitmentUpdate ret = CommitmentUpdate_new(update_add_htlcs_arg_conv, update_fulfill_htlcs_arg_conv, update_fail_htlcs_arg_conv, update_fail_malformed_htlcs_arg_conv, update_fee_arg_conv, commitment_signed_arg_conv); + LDKCommitmentUpdate ret = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -10265,13 +11182,17 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv * _en return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) { +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) { LDKPeerManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); - LDKCVec_PublicKeyZ* ret = MALLOC(sizeof(LDKCVec_PublicKeyZ), "LDKCVec_PublicKeyZ"); - *ret = PeerManager_get_peer_node_ids(&this_arg_conv); - return (long)ret; + LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv); + jobjectArray ret_arr = (*_env)->NewObjectArray(_env, ret_var.datalen, NULL, NULL); + for (size_t i = 0; i < ret_var.datalen; i++) { + jbyteArray arr_conv_8_arr = (*_env)->NewByteArray(_env, 33); + (*_env)->SetByteArrayRegion(_env, arr_conv_8_arr, 0, 33, ret_var.data[i].compressed_form); + (*_env)->SetObjectArrayElement(_env, ret_arr, i, arr_conv_8_arr);} + return ret_arr; } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong descriptor) { @@ -10988,16 +11909,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1s HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKHolderCommitmentTransaction this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)val; - FREE((void*)val); - HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_conv); + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t q = 0; q < val_constr.datalen; q++) { + long arr_conv_42 = val_vals[q]; + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42; + FREE((void*)arr_conv_42); + val_constr.data[q] = arr_conv_42_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_constr); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jbyteArray counterparty_sig, jbyteArray holder_funding_key, jbyteArray counterparty_funding_key, jlong keys, jint feerate_per_kw, jlong htlc_data) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jbyteArray counterparty_sig, jbyteArray holder_funding_key, jbyteArray counterparty_funding_key, jlong keys, jint feerate_per_kw, jlongArray htlc_data) { LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx; FREE((void*)unsigned_tx); LDKSignature counterparty_sig_ref; @@ -11014,9 +11947,21 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1 keys_conv.is_owned = (keys & 1) || (keys == 0); if (keys_conv.inner != NULL) keys_conv = TxCreationKeys_clone(&keys_conv); - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)htlc_data; - FREE((void*)htlc_data); - LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_ref, holder_funding_key_ref, counterparty_funding_key_ref, keys_conv, feerate_per_kw, htlc_data_conv); + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_constr; + htlc_data_constr.datalen = (*_env)->GetArrayLength (_env, htlc_data); + if (htlc_data_constr.datalen > 0) + htlc_data_constr.data = MALLOC(htlc_data_constr.datalen * sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ Elements"); + else + htlc_data_constr.data = NULL; + long* htlc_data_vals = (*_env)->GetLongArrayElements (_env, htlc_data, NULL); + for (size_t q = 0; q < htlc_data_constr.datalen; q++) { + long arr_conv_42 = htlc_data_vals[q]; + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arr_conv_42_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arr_conv_42; + FREE((void*)arr_conv_42); + htlc_data_constr.data[q] = arr_conv_42_conv; + } + (*_env)->ReleaseLongArrayElements (_env, htlc_data, htlc_data_vals, 0); + LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_ref, holder_funding_key_ref, counterparty_funding_key_ref, keys_conv, feerate_per_kw, htlc_data_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -11255,19 +12200,69 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, j return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jobjectArray val) { LDKRoute this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_CVec_RouteHopZZ val_conv = *(LDKCVec_CVec_RouteHopZZ*)val; - FREE((void*)val); - Route_set_paths(&this_ptr_conv, val_conv); -} - -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jlong paths_arg) { - LDKCVec_CVec_RouteHopZZ paths_arg_conv = *(LDKCVec_CVec_RouteHopZZ*)paths_arg; - FREE((void*)paths_arg); - LDKRoute ret = Route_new(paths_arg_conv); + LDKCVec_CVec_RouteHopZZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements"); + else + val_constr.data = NULL; + for (size_t m = 0; m < val_constr.datalen; m++) { + jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, val, m); + LDKCVec_RouteHopZ arr_conv_12_constr; + arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12); + if (arr_conv_12_constr.datalen > 0) + arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + arr_conv_12_constr.data = NULL; + long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL); + for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) { + long arr_conv_10 = arr_conv_12_vals[k]; + LDKRouteHop arr_conv_10_conv; + arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1)); + arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0); + if (arr_conv_10_conv.inner != NULL) + arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv); + arr_conv_12_constr.data[k] = arr_conv_10_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0); + val_constr.data[m] = arr_conv_12_constr; + } + Route_set_paths(&this_ptr_conv, val_constr); +} + +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jobjectArray paths_arg) { + LDKCVec_CVec_RouteHopZZ paths_arg_constr; + paths_arg_constr.datalen = (*_env)->GetArrayLength (_env, paths_arg); + if (paths_arg_constr.datalen > 0) + paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements"); + else + paths_arg_constr.data = NULL; + for (size_t m = 0; m < paths_arg_constr.datalen; m++) { + jobject arr_conv_12 = (*_env)->GetObjectArrayElement(_env, paths_arg, m); + LDKCVec_RouteHopZ arr_conv_12_constr; + arr_conv_12_constr.datalen = (*_env)->GetArrayLength (_env, arr_conv_12); + if (arr_conv_12_constr.datalen > 0) + arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + arr_conv_12_constr.data = NULL; + long* arr_conv_12_vals = (*_env)->GetLongArrayElements (_env, arr_conv_12, NULL); + for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) { + long arr_conv_10 = arr_conv_12_vals[k]; + LDKRouteHop arr_conv_10_conv; + arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1)); + arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0); + if (arr_conv_10_conv.inner != NULL) + arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv); + arr_conv_12_constr.data[k] = arr_conv_10_conv; + } + (*_env)->ReleaseLongArrayElements (_env, arr_conv_12, arr_conv_12_vals, 0); + paths_arg_constr.data[m] = arr_conv_12_constr; + } + LDKRoute ret = Route_new(paths_arg_constr); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -11402,7 +12397,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv * _env, return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jclass _b, jbyteArray our_node_id, jlong network, jbyteArray target, jlong first_hops, jlong last_hops, jlong final_value_msat, jint final_cltv, jlong logger) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jclass _b, jbyteArray our_node_id, jlong network, jbyteArray target, jlongArray first_hops, jlongArray last_hops, jlong final_value_msat, jint final_cltv, jlong logger) { LDKPublicKey our_node_id_ref; CHECK((*_env)->GetArrayLength (_env, our_node_id) == 33); (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form); @@ -11412,16 +12407,46 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jcl LDKPublicKey target_ref; CHECK((*_env)->GetArrayLength (_env, target) == 33); (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form); - LDKCVec_ChannelDetailsZ* first_hops_conv = (LDKCVec_ChannelDetailsZ*)first_hops; - LDKCVec_RouteHintZ last_hops_conv = *(LDKCVec_RouteHintZ*)last_hops; - FREE((void*)last_hops); + LDKCVec_ChannelDetailsZ first_hops_constr; + first_hops_constr.datalen = (*_env)->GetArrayLength (_env, first_hops); + if (first_hops_constr.datalen > 0) + first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + first_hops_constr.data = NULL; + long* first_hops_vals = (*_env)->GetLongArrayElements (_env, first_hops, NULL); + for (size_t q = 0; q < first_hops_constr.datalen; q++) { + long arr_conv_16 = first_hops_vals[q]; + LDKChannelDetails arr_conv_16_conv; + arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); + arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); + first_hops_constr.data[q] = arr_conv_16_conv; + } + (*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0); + LDKCVec_RouteHintZ last_hops_constr; + last_hops_constr.datalen = (*_env)->GetArrayLength (_env, last_hops); + if (last_hops_constr.datalen > 0) + last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements"); + else + last_hops_constr.data = NULL; + long* last_hops_vals = (*_env)->GetLongArrayElements (_env, last_hops, NULL); + for (size_t l = 0; l < last_hops_constr.datalen; l++) { + long arr_conv_11 = last_hops_vals[l]; + LDKRouteHint arr_conv_11_conv; + arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1)); + arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0); + if (arr_conv_11_conv.inner != NULL) + arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv); + last_hops_constr.data[l] = arr_conv_11_conv; + } + (*_env)->ReleaseLongArrayElements (_env, last_hops, last_hops_vals, 0); LDKLogger logger_conv = *(LDKLogger*)logger; if (logger_conv.free == LDKLogger_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_clone(logger_conv.this_arg); } LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ"); - *ret = get_route(our_node_id_ref, &network_conv, target_ref, first_hops_conv, last_hops_conv, final_value_msat, final_cltv, logger_conv); + *ret = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv); + FREE(first_hops_constr.data); return (long)ret; } @@ -11892,13 +12917,25 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1ali NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKNodeAnnouncementInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val; - FREE((void*)val); - NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_conv); + LDKCVec_NetAddressZ val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t m = 0; m < val_constr.datalen; m++) { + long arr_conv_12 = val_vals[m]; + LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12; + FREE((void*)arr_conv_12); + val_constr.data[m] = arr_conv_12_conv; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr); } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) { @@ -11921,7 +12958,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1ann NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv * _env, jclass _b, jlong features_arg, jint last_update_arg, jbyteArray rgb_arg, jbyteArray alias_arg, jlong addresses_arg, jlong announcement_message_arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv * _env, jclass _b, jlong features_arg, jint last_update_arg, jbyteArray rgb_arg, jbyteArray alias_arg, jlongArray addresses_arg, jlong announcement_message_arg) { LDKNodeFeatures features_arg_conv; features_arg_conv.inner = (void*)(features_arg & (~1)); features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0); @@ -11932,14 +12969,26 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNI LDKThirtyTwoBytes alias_arg_ref; CHECK((*_env)->GetArrayLength (_env, alias_arg) == 32); (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data); - LDKCVec_NetAddressZ addresses_arg_conv = *(LDKCVec_NetAddressZ*)addresses_arg; - FREE((void*)addresses_arg); + LDKCVec_NetAddressZ addresses_arg_constr; + addresses_arg_constr.datalen = (*_env)->GetArrayLength (_env, addresses_arg); + if (addresses_arg_constr.datalen > 0) + addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements"); + else + addresses_arg_constr.data = NULL; + long* addresses_arg_vals = (*_env)->GetLongArrayElements (_env, addresses_arg, NULL); + for (size_t m = 0; m < addresses_arg_constr.datalen; m++) { + long arr_conv_12 = addresses_arg_vals[m]; + LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12; + FREE((void*)arr_conv_12); + addresses_arg_constr.data[m] = arr_conv_12_conv; + } + (*_env)->ReleaseLongArrayElements (_env, addresses_arg, addresses_arg_vals, 0); LDKNodeAnnouncement announcement_message_arg_conv; announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1)); announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0); if (announcement_message_arg_conv.inner != NULL) announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv); - LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_conv, announcement_message_arg_conv); + LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } @@ -11969,13 +13018,23 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, NodeInfo_free(this_ptr_conv); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlongArray val) { LDKNodeInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val; - FREE((void*)val); - NodeInfo_set_channels(&this_ptr_conv, val_conv); + LDKCVec_u64Z val_constr; + val_constr.datalen = (*_env)->GetArrayLength (_env, val); + if (val_constr.datalen > 0) + val_constr.data = MALLOC(val_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + val_constr.data = NULL; + long* val_vals = (*_env)->GetLongArrayElements (_env, val, NULL); + for (size_t g = 0; g < val_constr.datalen; g++) { + long arr_conv_6 = val_vals[g]; + val_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, val, val_vals, 0); + NodeInfo_set_channels(&this_ptr_conv, val_constr); } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) { @@ -12017,9 +13076,19 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1i NodeInfo_set_announcement_info(&this_ptr_conv, val_conv); } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, jclass _b, jlong channels_arg, jlong lowest_inbound_channel_fees_arg, jlong announcement_info_arg) { - LDKCVec_u64Z channels_arg_conv = *(LDKCVec_u64Z*)channels_arg; - FREE((void*)channels_arg); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, jclass _b, jlongArray channels_arg, jlong lowest_inbound_channel_fees_arg, jlong announcement_info_arg) { + LDKCVec_u64Z channels_arg_constr; + channels_arg_constr.datalen = (*_env)->GetArrayLength (_env, channels_arg); + if (channels_arg_constr.datalen > 0) + channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(jlong), "LDKCVec_u64Z Elements"); + else + channels_arg_constr.data = NULL; + long* channels_arg_vals = (*_env)->GetLongArrayElements (_env, channels_arg, NULL); + for (size_t g = 0; g < channels_arg_constr.datalen; g++) { + long arr_conv_6 = channels_arg_vals[g]; + channels_arg_constr.data[g] = arr_conv_6; + } + (*_env)->ReleaseLongArrayElements (_env, channels_arg, channels_arg_vals, 0); LDKRoutingFees lowest_inbound_channel_fees_arg_conv; lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1)); lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0); @@ -12029,7 +13098,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1)); announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0); // Warning: we may need a move here but can't clone! - LDKNodeInfo ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv); + LDKNodeInfo ret = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv); return ((long)ret.inner) | (ret.is_owned ? 1 : 0); } diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index 9ba7a2c0..e1c4082e 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -111,6 +111,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1new JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1usize_1_1Transaction_1new (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_usizeTransactionZ_get_a + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_usizeTransactionZ_get_b + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok @@ -167,6 +183,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdate JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new (JNIEnv *, jclass, jlong, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_OutPointScriptZ_get_a + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_OutPointScriptZ_get_b + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCVecTempl_TxOut_arr_info @@ -186,10 +218,26 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new /* * Class: org_ldk_impl_bindings * Method: LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut_new - * Signature: ([BJ)J + * Signature: ([B[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new - (JNIEnv *, jclass, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jlongArray); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_TxidCVec_TxOutZZ_get_a + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1TxOutZZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_TxidCVec_TxOutZZ_get_b + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1TxOutZZ_1get_1b + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings @@ -199,6 +247,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoByt JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_u64u64Z_get_a + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_u64u64Z_get_b + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u64u64Z_1get_1b + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCVecTempl_Signature_arr_info @@ -210,10 +274,26 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1ar /* * Class: org_ldk_impl_bindings * Method: LDKC2TupleTempl_Signature__CVecTempl_Signature_new - * Signature: ([BJ)J + * Signature: ([B[[B)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new - (JNIEnv *, jclass, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jobjectArray); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_SignatureCVec_SignatureZZ_get_a + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_SignatureCVec_SignatureZZ_get_b + * Signature: (J)[[B + */ +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings @@ -274,9 +354,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1Signatur /* * Class: org_ldk_impl_bindings * Method: LDKCResult_CVec_SignatureZNoneZ_get_ok - * Signature: (J)J + * Signature: (J)[[B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv *, jclass, jlong); /* @@ -351,6 +431,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFa JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new (JNIEnv *, jclass, jlong, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_NonePeerHandleErrorZ_result_ok @@ -383,6 +487,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErr JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new (JNIEnv *, jclass, jlong, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_HTLCOutputInCommitmentSignatureZ_get_a + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1HTLCOutputInCommitmentSignatureZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_HTLCOutputInCommitmentSignatureZ_get_b + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1HTLCOutputInCommitmentSignatureZ_1get_1b + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKSpendableOutputDescriptor_ref_from_ptr @@ -474,9 +594,9 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvide /* * Class: org_ldk_impl_bindings * Method: MessageSendEventsProvider_get_and_clear_pending_msg_events - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events (JNIEnv *, jclass, jlong); /* @@ -514,9 +634,9 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj /* * Class: org_ldk_impl_bindings * Method: EventsProvider_get_and_clear_pending_events - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events (JNIEnv *, jclass, jlong); /* @@ -642,10 +762,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_ /* * Class: org_ldk_impl_bindings * Method: ChannelKeys_sign_counterparty_commitment - * Signature: (JIJJJ)J + * Signature: (JIJJ[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment - (JNIEnv *, jclass, jlong, jint, jlong, jlong, jlong); + (JNIEnv *, jclass, jlong, jint, jlong, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -754,9 +874,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel /* * Class: org_ldk_impl_bindings * Method: Watch_release_pending_monitor_events - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events (JNIEnv *, jclass, jlong); /* @@ -1354,17 +1474,17 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_ /* * Class: org_ldk_impl_bindings * Method: RoutingMessageHandler_get_next_channel_announcements - * Signature: (JJB)J + * Signature: (JJB)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements (JNIEnv *, jclass, jlong, jlong, jbyte); /* * Class: org_ldk_impl_bindings * Method: RoutingMessageHandler_get_next_node_announcements - * Signature: (J[BB)J + * Signature: (J[BB)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements (JNIEnv *, jclass, jlong, jbyteArray, jbyte); /* @@ -1583,14 +1703,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: LDKCVecTempl_CVecTempl_RouteHop_new - * Signature: ([J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new - (JNIEnv *, jclass, jlongArray); - /* * Class: org_ldk_impl_bindings * Method: LDKCResult_RouteLightningErrorZ_result_ok @@ -1714,10 +1826,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ /* * Class: org_ldk_impl_bindings * Method: CResult_CVec_SignatureZNoneZ_ok - * Signature: (J)J + * Signature: ([[B)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobjectArray); /* * Class: org_ldk_impl_bindings @@ -2010,202 +2122,202 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ /* * Class: org_ldk_impl_bindings * Method: CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_C2Tuple_TxidCVec_TxOutZZZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_C2Tuple_usizeTransactionZZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_CVec_RouteHopZZ_free - * Signature: (J)V + * Signature: ([[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobjectArray); /* * Class: org_ldk_impl_bindings * Method: CVec_ChannelDetailsZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_ChannelMonitorZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_EventZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_HTLCOutputInCommitmentZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_MessageSendEventZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_MonitorEventZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_NetAddressZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_NodeAnnouncementZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_PublicKeyZ_free - * Signature: (J)V + * Signature: ([[B)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobjectArray); /* * Class: org_ldk_impl_bindings * Method: CVec_RouteHintZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_RouteHopZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_SignatureZ_free - * Signature: (J)V + * Signature: ([[B)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobjectArray); /* * Class: org_ldk_impl_bindings * Method: CVec_SpendableOutputDescriptorZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_TransactionZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_TxOutZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_UpdateAddHTLCZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_UpdateFailHTLCZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_UpdateFailMalformedHTLCZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_UpdateFulfillHTLCZ_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CVec_u64Z_free - * Signature: (J)V + * Signature: ([J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jlongArray); /* * Class: org_ldk_impl_bindings @@ -2266,10 +2378,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new /* * Class: org_ldk_impl_bindings * Method: C2Tuple_TxidCVec_TxOutZZ_new - * Signature: ([BJ)J + * Signature: ([B[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new - (JNIEnv *, jclass, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jlongArray); /* * Class: org_ldk_impl_bindings @@ -2282,10 +2394,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new /* * Class: org_ldk_impl_bindings * Method: C2Tuple_SignatureCVec_SignatureZZ_new - * Signature: ([BJ)J + * Signature: ([B[[B)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new - (JNIEnv *, jclass, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jobjectArray); /* * Class: org_ldk_impl_bindings @@ -2906,10 +3018,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free /* * Class: org_ldk_impl_bindings * Method: ChainMonitor_block_connected - * Signature: (J[BJI)V + * Signature: (J[B[JI)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected - (JNIEnv *, jclass, jlong, jbyteArray, jlong, jint); + (JNIEnv *, jclass, jlong, jbyteArray, jlongArray, jint); /* * Class: org_ldk_impl_bindings @@ -3074,34 +3186,34 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_ /* * Class: org_ldk_impl_bindings * Method: ChannelMonitor_get_and_clear_pending_monitor_events - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings * Method: ChannelMonitor_get_and_clear_pending_events - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings * Method: ChannelMonitor_get_latest_holder_commitment_txn - * Signature: (JJ)J + * Signature: (JJ)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings * Method: ChannelMonitor_block_connected - * Signature: (J[BJIJJJ)J + * Signature: (J[B[JIJJJ)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected - (JNIEnv *, jclass, jlong, jbyteArray, jlong, jint, jlong, jlong, jlong); +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected + (JNIEnv *, jclass, jlong, jbyteArray, jlongArray, jint, jlong, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -3594,17 +3706,17 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1chann /* * Class: org_ldk_impl_bindings * Method: ChannelManager_list_channels - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings * Method: ChannelManager_list_usable_channels - * Signature: (J)J + * Signature: (J)[J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels (JNIEnv *, jclass, jlong); /* @@ -3650,10 +3762,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1trans /* * Class: org_ldk_impl_bindings * Method: ChannelManager_broadcast_node_announcement - * Signature: (J[B[BJ)V + * Signature: (J[B[B[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement - (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jlong); + (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jlongArray); /* * Class: org_ldk_impl_bindings @@ -3722,10 +3834,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsPro /* * Class: org_ldk_impl_bindings * Method: ChannelManager_block_connected - * Signature: (J[BJI)V + * Signature: (J[B[JI)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected - (JNIEnv *, jclass, jlong, jbyteArray, jlong, jint); + (JNIEnv *, jclass, jlong, jbyteArray, jlongArray, jint); /* * Class: org_ldk_impl_bindings @@ -3850,10 +3962,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1d /* * Class: org_ldk_impl_bindings * Method: ChannelManagerReadArgs_new - * Signature: (JJJJJJJ)J + * Signature: (JJJJJJ[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new - (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong, jlong); + (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -3914,9 +4026,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id /* * Class: org_ldk_impl_bindings * Method: ErrorMessage_get_data - * Signature: (J)J + * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data (JNIEnv *, jclass, jlong); /* @@ -5234,18 +5346,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signatu /* * Class: org_ldk_impl_bindings * Method: CommitmentSigned_set_htlc_signatures - * Signature: (JJ)V + * Signature: (J[[B)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jobjectArray); /* * Class: org_ldk_impl_bindings * Method: CommitmentSigned_new - * Signature: ([B[BJ)J + * Signature: ([B[B[[B)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new - (JNIEnv *, jclass, jbyteArray, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jbyteArray, jobjectArray); /* * Class: org_ldk_impl_bindings @@ -5690,10 +5802,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_ /* * Class: org_ldk_impl_bindings * Method: UnsignedNodeAnnouncement_set_addresses - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -6338,18 +6450,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1 /* * Class: org_ldk_impl_bindings * Method: ReplyChannelRange_set_short_channel_ids - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: ReplyChannelRange_new - * Signature: ([BIIZJ)J + * Signature: ([BIIZ[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new - (JNIEnv *, jclass, jbyteArray, jint, jint, jboolean, jlong); + (JNIEnv *, jclass, jbyteArray, jint, jint, jboolean, jlongArray); /* * Class: org_ldk_impl_bindings @@ -6386,18 +6498,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1cha /* * Class: org_ldk_impl_bindings * Method: QueryShortChannelIds_set_short_channel_ids - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: QueryShortChannelIds_new - * Signature: ([BJ)J + * Signature: ([B[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new - (JNIEnv *, jclass, jbyteArray, jlong); + (JNIEnv *, jclass, jbyteArray, jlongArray); /* * Class: org_ldk_impl_bindings @@ -6546,9 +6658,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free /* * Class: org_ldk_impl_bindings * Method: LightningError_get_err - * Signature: (J)J + * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err (JNIEnv *, jclass, jlong); /* @@ -6602,34 +6714,34 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_add_htlcs - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fulfill_htlcs - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fail_htlcs - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fail_malformed_htlcs - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -6666,10 +6778,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitm /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_new - * Signature: (JJJJJJ)J + * Signature: ([J[J[J[JJJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new - (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong); + (JNIEnv *, jclass, jlongArray, jlongArray, jlongArray, jlongArray, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -7298,9 +7410,9 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new /* * Class: org_ldk_impl_bindings * Method: PeerManager_get_peer_node_ids - * Signature: (J)J + * Signature: (J)[[B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids (JNIEnv *, jclass, jlong); /* @@ -7874,18 +7986,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1s /* * Class: org_ldk_impl_bindings * Method: HolderCommitmentTransaction_set_per_htlc - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings * Method: HolderCommitmentTransaction_new_missing_holder_sig - * Signature: (J[B[B[BJIJ)J + * Signature: (J[B[B[BJI[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig - (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jbyteArray, jlong, jint, jlong); + (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jbyteArray, jlong, jint, jlongArray); /* * Class: org_ldk_impl_bindings @@ -8098,18 +8210,18 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone /* * Class: org_ldk_impl_bindings * Method: Route_set_paths - * Signature: (JJ)V + * Signature: (J[[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jobjectArray); /* * Class: org_ldk_impl_bindings * Method: Route_new - * Signature: (J)J + * Signature: ([[J)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobjectArray); /* * Class: org_ldk_impl_bindings @@ -8234,10 +8346,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new /* * Class: org_ldk_impl_bindings * Method: get_route - * Signature: ([BJ[BJJJIJ)J + * Signature: ([BJ[B[J[JJIJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route - (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlong, jlong, jlong, jint, jlong); + (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlongArray, jlongArray, jlong, jint, jlong); /* * Class: org_ldk_impl_bindings @@ -8674,10 +8786,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1ali /* * Class: org_ldk_impl_bindings * Method: NodeAnnouncementInfo_set_addresses - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -8698,10 +8810,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1ann /* * Class: org_ldk_impl_bindings * Method: NodeAnnouncementInfo_new - * Signature: (JI[B[BJJ)J + * Signature: (JI[B[B[JJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new - (JNIEnv *, jclass, jlong, jint, jbyteArray, jbyteArray, jlong, jlong); + (JNIEnv *, jclass, jlong, jint, jbyteArray, jbyteArray, jlongArray, jlong); /* * Class: org_ldk_impl_bindings @@ -8730,10 +8842,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free /* * Class: org_ldk_impl_bindings * Method: NodeInfo_set_channels - * Signature: (JJ)V + * Signature: (J[J)V */ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels - (JNIEnv *, jclass, jlong, jlong); + (JNIEnv *, jclass, jlong, jlongArray); /* * Class: org_ldk_impl_bindings @@ -8770,10 +8882,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1i /* * Class: org_ldk_impl_bindings * Method: NodeInfo_new - * Signature: (JJJ)J + * Signature: ([JJJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new - (JNIEnv *, jclass, jlong, jlong, jlong); + (JNIEnv *, jclass, jlongArray, jlong, jlong); /* * Class: org_ldk_impl_bindings diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index 7f9e470c..5dcc7a04 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -1,6 +1,7 @@ package org.ldk; import org.bitcoinj.core.*; +import org.bitcoinj.core.Transaction; import org.bitcoinj.script.Script; import org.junit.jupiter.api.Test; import org.ldk.enums.LDKNetwork; @@ -59,14 +60,14 @@ public class HumanObjectPeerTest { } @Override - public long release_pending_monitor_events() { + public long[] release_pending_monitor_events() { synchronized (monitors) { assert monitors.size() <= 1; for (Long mon : monitors.values()) { return bindings.ChannelMonitor_get_and_clear_pending_monitor_events(mon); } } - return bindings.new_empty_slice_vec(); + return new long[0]; } }); @@ -74,41 +75,39 @@ public class HumanObjectPeerTest { for (byte i = 0; i < 32; i++) { key_seed[i] = (byte) (i ^ seed); } - this.keys = new KeysManager(key_seed, LDKNetwork.LDKNetwork_Bitcoin, System.currentTimeMillis() / 1000, (int) (System.currentTimeMillis() * 1000) & 0xffffffff); + this.keys = KeysManager.constructor_new(key_seed, LDKNetwork.LDKNetwork_Bitcoin, System.currentTimeMillis() / 1000, (int) (System.currentTimeMillis() * 1000) & 0xffffffff); this.keys_interface = keys.as_KeysInterface(); - this.chan_manager = new ChannelManager(LDKNetwork.LDKNetwork_Bitcoin, new FeeEstimator(confirmation_target -> 0), chain_monitor, + this.chan_manager = ChannelManager.constructor_new(LDKNetwork.LDKNetwork_Bitcoin, new FeeEstimator(confirmation_target -> 0), chain_monitor, new BroadcasterInterface(tx -> { - }), new Logger(log_trait), keys.as_KeysInterface(), new UserConfig(), 1); + }), new Logger(log_trait), keys.as_KeysInterface(), UserConfig.constructor_default(), 1); this.node_id = chan_manager.get_our_node_id(); this.chan_manager_events = chan_manager.as_EventsProvider(); - this.router = new NetGraphMsgHandler(null, new Logger(log_trait)); + this.router = NetGraphMsgHandler.constructor_new(null, new Logger(log_trait)); byte[] random_data = new byte[32]; for (byte i = 0; i < 32; i++) { random_data[i] = (byte) ((i ^ seed) ^ 0xf0); } - this.peer_manager = new PeerManager(chan_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, new Logger(log_trait)); + this.peer_manager = PeerManager.constructor_new(chan_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, new Logger(log_trait)); System.gc(); } void connect_block(Block b, Transaction t, int height) { byte[] header = Arrays.copyOfRange(b.bitcoinSerialize(), 0, 80); - long txn; + long[] txn; if (t != null) - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new( - new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}); + txn = new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}; else - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new(new long[0]); + txn = new long[0]; bindings.ChannelManager_block_connected(chan_manager._test_only_get_ptr(), header, txn, height); synchronized (monitors) { for (Long mon : monitors.values()) { if (t != null) - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new( - new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}); + txn = new long[]{bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}; else - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new(new long[0]); - long ret = bindings.ChannelMonitor_block_connected(mon, header, txn, height, tx_broadcaster, fee_estimator, logger); - bindings.CVec_C2Tuple_TxidCVec_TxOutZZZ_free(ret); + txn = new long[0]; + long[] ret = bindings.ChannelMonitor_block_connected(mon, header, txn, height, tx_broadcaster, fee_estimator, logger); + for (long r : ret) bindings.C2Tuple_TxidCVec_TxOutZZ_free(r); } } } @@ -125,19 +124,18 @@ public class HumanObjectPeerTest { } } - long get_route(byte[] dest_node, long our_chans) { + long get_route(byte[] dest_node, ChannelDetails[] our_chans) { try (LockedNetworkGraph netgraph = this.router.read_locked_graph()) { - //r = new WeakReference(netgraph); NetworkGraph graph = netgraph.graph(); - return bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, our_chans, - bindings.LDKCVecTempl_RouteHint_new(new long[0]), 1000, 42, this.logger); + return bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, new long[] {our_chans[0]._test_only_get_ptr()}, + new long[0], 1000, 42, this.logger); } } } class LongHolder { long val; } - java.util.LinkedList must_free_objs = new java.util.LinkedList(); + java.util.LinkedList> must_free_objs = new java.util.LinkedList(); void do_read_event(ConcurrentLinkedQueue list, PeerManager pm, long descriptor, byte[] data) { Thread thread = new Thread(() -> { long res = bindings.PeerManager_read_event(pm._test_only_get_ptr(), descriptor, data); @@ -147,7 +145,7 @@ public class HumanObjectPeerTest { }); thread.start(); list.add(thread); - must_free_objs.add(new WeakReference(data)); + must_free_objs.add(new WeakReference<>(data)); } boolean gc_ran = false; @@ -212,10 +210,9 @@ public class HumanObjectPeerTest { peer2.peer_manager.process_events(); while (!list.isEmpty()) { list.poll().join(); } - long events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events._test_only_get_ptr()); - bindings.VecOrSliceDef events_arr_info = bindings.LDKCVecTempl_Event_arr_info(events); - assert events_arr_info.datalen == 1; - bindings.LDKEvent event = bindings.LDKEvent_ref_from_ptr(events_arr_info.dataptr); + long[] events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events._test_only_get_ptr()); + assert events.length == 1; + bindings.LDKEvent event = bindings.LDKEvent_ref_from_ptr(events[0]); assert event instanceof bindings.LDKEvent.FundingGenerationReady; assert ((bindings.LDKEvent.FundingGenerationReady) event).channel_value_satoshis == 10000; assert ((bindings.LDKEvent.FundingGenerationReady) event).user_channel_id == 42; @@ -229,7 +226,7 @@ public class HumanObjectPeerTest { funding.getInputs().get(0).setWitness(new TransactionWitness(2)); // Make sure we don't complain about lack of witness funding.getInput(0).getWitness().setPush(0, new byte[]{0x1}); funding.addOutput(Coin.SATOSHI.multiply(10000), new Script(funding_spk)); - peer1.chan_manager.funding_transaction_generated(chan_id, new OutPoint(funding.getTxId().getReversedBytes(), (short) 0)); + peer1.chan_manager.funding_transaction_generated(chan_id, OutPoint.constructor_new(funding.getTxId().getReversedBytes(), (short) 0)); peer1.peer_manager.process_events(); while (!list.isEmpty()) { list.poll().join(); } @@ -237,9 +234,8 @@ public class HumanObjectPeerTest { while (!list.isEmpty()) { list.poll().join(); } events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events._test_only_get_ptr()); - events_arr_info = bindings.LDKCVecTempl_Event_arr_info(events); - assert events_arr_info.datalen == 1; - event = bindings.LDKEvent_ref_from_ptr(events_arr_info.dataptr); + assert events.length == 1; + event = bindings.LDKEvent_ref_from_ptr(events[0]); assert event instanceof bindings.LDKEvent.FundingBroadcastSafe; bindings.CVec_EventZ_free(events); @@ -257,23 +253,20 @@ public class HumanObjectPeerTest { peer2.peer_manager.process_events(); while (!list.isEmpty()) { list.poll().join(); } - long peer1_chans = bindings.ChannelManager_list_channels(peer1.chan_manager._test_only_get_ptr()); - long peer2_chans = bindings.ChannelManager_list_channels(peer2.chan_manager._test_only_get_ptr()); - assert bindings.vec_slice_len(peer1_chans) == 1; - assert bindings.vec_slice_len(peer2_chans) == 1; - long[] peer_1_chan_info = bindings.LDKCVecTempl_ChannelDetails_arr_info(peer1_chans); - assert peer_1_chan_info.length == 1; - assert bindings.ChannelDetails_get_channel_value_satoshis(peer_1_chan_info[0]) == 10000; - assert bindings.ChannelDetails_get_is_live(peer_1_chan_info[0]); - assert Arrays.equals(bindings.ChannelDetails_get_channel_id(peer_1_chan_info[0]), funding.getTxId().getReversedBytes()); - assert Arrays.equals(bindings.ChannelDetails_get_channel_id(bindings.LDKCVecTempl_ChannelDetails_arr_info(peer2_chans)[0]), funding.getTxId().getReversedBytes()); - bindings.CVec_ChannelDetailsZ_free(peer2_chans); + peer1.chan_manager.list_channels(); + ChannelDetails[] peer1_chans = peer1.chan_manager.list_channels(); + ChannelDetails[] peer2_chans = peer2.chan_manager.list_channels(); + assert peer1_chans.length == 1; + assert peer2_chans.length == 1; + assert peer1_chans[0].get_channel_value_satoshis() == 10000; + assert peer1_chans[0].get_is_live(); + assert Arrays.equals(peer1_chans[0].get_channel_id(), funding.getTxId().getReversedBytes()); + assert Arrays.equals(peer2_chans[0].get_channel_id(), funding.getTxId().getReversedBytes()); byte[] payment_preimage = new byte[32]; for (int i = 0; i < 32; i++) payment_preimage[i] = (byte) (i ^ 0x0f); byte[] payment_hash = Sha256Hash.hash(payment_preimage); long route = peer1.get_route(peer2.node_id, peer1_chans); - bindings.CVec_ChannelDetailsZ_free(peer1_chans); assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route); long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager._test_only_get_ptr(), bindings.LDKCResult_RouteLightningErrorZ_get_ok(route), payment_hash, new byte[32]); bindings.CResult_RouteLightningErrorZ_free(route); @@ -287,18 +280,16 @@ public class HumanObjectPeerTest { peer1.peer_manager.process_events(); while (!list.isEmpty()) { list.poll().join(); } - long peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events._test_only_get_ptr()); - bindings.VecOrSliceDef event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer2_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent forwardable = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + long[] peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events._test_only_get_ptr()); + assert peer2_events.length == 1; + bindings.LDKEvent forwardable = bindings.LDKEvent_ref_from_ptr(peer2_events[0]); assert forwardable instanceof bindings.LDKEvent.PendingHTLCsForwardable; bindings.CVec_EventZ_free(peer2_events); bindings.ChannelManager_process_pending_htlc_forwards(peer2.chan_manager._test_only_get_ptr()); peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events._test_only_get_ptr()); - event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer2_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent payment_recvd = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + assert peer2_events.length == 1; + bindings.LDKEvent payment_recvd = bindings.LDKEvent_ref_from_ptr(peer2_events[0]); assert payment_recvd instanceof bindings.LDKEvent.PaymentReceived; peer2.chan_manager.claim_funds(payment_preimage, new byte[32], ((bindings.LDKEvent.PaymentReceived) payment_recvd).amt); bindings.CVec_EventZ_free(peer2_events); @@ -308,10 +299,9 @@ public class HumanObjectPeerTest { peer1.peer_manager.process_events(); while (!list.isEmpty()) { list.poll().join(); } - long peer1_events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events._test_only_get_ptr()); - event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer1_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent sent = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + long[] peer1_events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events._test_only_get_ptr()); + assert peer1_events.length == 1; + bindings.LDKEvent sent = bindings.LDKEvent_ref_from_ptr(peer1_events[0]); assert sent instanceof bindings.LDKEvent.PaymentSent; assert Arrays.equals(((bindings.LDKEvent.PaymentSent) sent).payment_preimage, payment_preimage); bindings.CVec_EventZ_free(peer1_events); @@ -329,7 +319,7 @@ public class HumanObjectPeerTest { System.gc(); System.runFinalization(); } - for (WeakReference o : must_free_objs) + for (WeakReference o : must_free_objs) assert o.get() == null; } -} +} \ No newline at end of file diff --git a/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java b/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java index 04492878..223a14b8 100644 --- a/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java +++ b/src/test/java/org/ldk/ManualMsgHandlingPeerTest.java @@ -105,7 +105,7 @@ public class ManualMsgHandlingPeerTest { public void handle_error(byte[] their_node_id, long msg) { } - }, () -> 0); + }, () -> new long[0]); long route_handler = bindings.LDKRoutingMessageHandler_new(new bindings.LDKRoutingMessageHandler() { @Override public long handle_node_announcement(long msg) { return 0; @@ -119,11 +119,11 @@ public class ManualMsgHandlingPeerTest { @Override public void handle_htlc_fail_channel_update(long update) { } - @Override public long get_next_channel_announcements(long starting_point, byte batch_amount) { - return 0; + @Override public long[] get_next_channel_announcements(long starting_point, byte batch_amount) { + return new long[0]; } - @Override public long get_next_node_announcements(byte[] starting_point, byte batch_amount) { - return 0; + @Override public long[] get_next_node_announcements(byte[] starting_point, byte batch_amount) { + return new long[0]; } @Override public boolean should_request_full_sync(byte[] node_id) { return false; diff --git a/src/test/java/org/ldk/PeerTest.java b/src/test/java/org/ldk/PeerTest.java index 01e6d33a..884a0830 100644 --- a/src/test/java/org/ldk/PeerTest.java +++ b/src/test/java/org/ldk/PeerTest.java @@ -68,14 +68,14 @@ public class PeerTest { } @Override - public long release_pending_monitor_events() { + public long[] release_pending_monitor_events() { synchronized (monitors) { assert monitors.size() <= 1; for (Long mon : monitors.values()) { return bindings.ChannelMonitor_get_and_clear_pending_monitor_events(mon); } } - return bindings.new_empty_slice_vec(); + return new long[0]; } }; this.chain_monitor = bindings.LDKWatch_new(this.watcher); @@ -101,22 +101,22 @@ public class PeerTest { void connect_block(Block b, Transaction t, int height) { byte[] header = Arrays.copyOfRange(b.bitcoinSerialize(), 0, 80); - long txn; + long[] txn; if (t != null) - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new( - new long[] {bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}); + txn = new long[] {bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}; else - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new(new long[0]); + txn = new long[0]; bindings.ChannelManager_block_connected(chan_manager, header, txn, height); synchronized (monitors) { for (Long mon : monitors.values()) { if (t != null) - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new( - new long[] {bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}); + txn = new long[] {bindings.C2Tuple_usizeTransactionZ_new(1, bindings.new_txpointer_copy_data(t.bitcoinSerialize()))}; else - txn = bindings.LDKCVecTempl_C2TupleTempl_usize__Transaction_new(new long[0]); - long ret = bindings.ChannelMonitor_block_connected(mon, header, txn, height, tx_broadcaster, fee_estimator, logger); - bindings.CVec_C2Tuple_TxidCVec_TxOutZZZ_free(ret); + txn = new long[0]; + long[] ret = bindings.ChannelMonitor_block_connected(mon, header, txn, height, tx_broadcaster, fee_estimator, logger); + for (long r : ret) { + bindings.C2Tuple_TxidCVec_TxOutZZ_free(r); + } } } } @@ -212,10 +212,9 @@ public class PeerTest { bindings.PeerManager_process_events(peer2.peer_manager); while (!list.isEmpty()) { list.poll().join(); } - long events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events); - bindings.VecOrSliceDef events_arr_info = bindings.LDKCVecTempl_Event_arr_info(events); - assert events_arr_info.datalen == 1; - bindings.LDKEvent event = bindings.LDKEvent_ref_from_ptr(events_arr_info.dataptr); + long events[] = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events); + assert events.length == 1; + bindings.LDKEvent event = bindings.LDKEvent_ref_from_ptr(events[0]); assert event instanceof bindings.LDKEvent.FundingGenerationReady; assert ((bindings.LDKEvent.FundingGenerationReady)event).channel_value_satoshis == 10000; assert ((bindings.LDKEvent.FundingGenerationReady)event).user_channel_id == 42; @@ -239,9 +238,8 @@ public class PeerTest { while (!list.isEmpty()) { list.poll().join(); } events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events); - events_arr_info = bindings.LDKCVecTempl_Event_arr_info(events); - assert events_arr_info.datalen == 1; - event = bindings.LDKEvent_ref_from_ptr(events_arr_info.dataptr); + assert events.length == 1; + event = bindings.LDKEvent_ref_from_ptr(events[0]); assert event instanceof bindings.LDKEvent.FundingBroadcastSafe; bindings.CVec_EventZ_free(events); @@ -259,25 +257,23 @@ public class PeerTest { bindings.PeerManager_process_events(peer2.peer_manager); while (!list.isEmpty()) { list.poll().join(); } - long peer1_chans = bindings.ChannelManager_list_channels(peer1.chan_manager); - long peer2_chans = bindings.ChannelManager_list_channels(peer2.chan_manager); - assert bindings.vec_slice_len(peer1_chans) == 1; - assert bindings.vec_slice_len(peer2_chans) == 1; - long[] peer_1_chan_info = bindings.LDKCVecTempl_ChannelDetails_arr_info(peer1_chans); - assert peer_1_chan_info.length == 1; - assert bindings.ChannelDetails_get_channel_value_satoshis(peer_1_chan_info[0]) == 10000; - assert bindings.ChannelDetails_get_is_live(peer_1_chan_info[0]); - assert Arrays.equals(bindings.ChannelDetails_get_channel_id(peer_1_chan_info[0]), funding.getTxId().getReversedBytes()); - assert Arrays.equals(bindings.ChannelDetails_get_channel_id(bindings.LDKCVecTempl_ChannelDetails_arr_info(peer2_chans)[0]), funding.getTxId().getReversedBytes()); - bindings.CVec_ChannelDetailsZ_free(peer2_chans); + long[] peer1_chans = bindings.ChannelManager_list_channels(peer1.chan_manager); + long[] peer2_chans = bindings.ChannelManager_list_channels(peer2.chan_manager); + assert peer1_chans.length == 1; + assert peer2_chans.length == 1; + assert bindings.ChannelDetails_get_channel_value_satoshis(peer1_chans[0]) == 10000; + assert bindings.ChannelDetails_get_is_live(peer1_chans[0]); + assert Arrays.equals(bindings.ChannelDetails_get_channel_id(peer1_chans[0]), funding.getTxId().getReversedBytes()); + assert Arrays.equals(bindings.ChannelDetails_get_channel_id(peer2_chans[0]), funding.getTxId().getReversedBytes()); + for (long chan : peer2_chans) bindings.ChannelDetails_free(chan); byte[] payment_preimage = new byte[32]; for (int i = 0; i < 32; i++) payment_preimage[i] = (byte) (i ^ 0x0f); byte[] payment_hash = Sha256Hash.hash(payment_preimage); long netgraph = bindings.NetGraphMsgHandler_read_locked_graph(peer1.router); long route = bindings.get_route(peer1.node_id, bindings.LockedNetworkGraph_graph(netgraph), peer2.node_id, peer1_chans, - bindings.LDKCVecTempl_RouteHint_new(new long[0]), 1000, 42, peer1.logger); - bindings.CVec_ChannelDetailsZ_free(peer1_chans); + new long[0], 1000, 42, peer1.logger); + for (long chan : peer1_chans) bindings.ChannelDetails_free(chan); assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route); bindings.LockedNetworkGraph_free(netgraph); long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route), payment_hash, new byte[32]); @@ -292,18 +288,16 @@ public class PeerTest { bindings.PeerManager_process_events(peer1.peer_manager); while (!list.isEmpty()) { list.poll().join(); } - long peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events); - bindings.VecOrSliceDef event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer2_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent forwardable = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + long[] peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events); + assert peer2_events.length == 1; + bindings.LDKEvent forwardable = bindings.LDKEvent_ref_from_ptr(peer2_events[0]); assert forwardable instanceof bindings.LDKEvent.PendingHTLCsForwardable; bindings.CVec_EventZ_free(peer2_events); bindings.ChannelManager_process_pending_htlc_forwards(peer2.chan_manager); peer2_events = bindings.EventsProvider_get_and_clear_pending_events(peer2.chan_manager_events); - event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer2_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent payment_recvd = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + assert peer2_events.length == 1; + bindings.LDKEvent payment_recvd = bindings.LDKEvent_ref_from_ptr(peer2_events[0]); assert payment_recvd instanceof bindings.LDKEvent.PaymentReceived; assert bindings.ChannelManager_claim_funds(peer2.chan_manager, payment_preimage, new byte[32], ((bindings.LDKEvent.PaymentReceived)payment_recvd).amt); bindings.CVec_EventZ_free(peer2_events); @@ -313,10 +307,9 @@ public class PeerTest { bindings.PeerManager_process_events(peer1.peer_manager); while (!list.isEmpty()) { list.poll().join(); } - long peer1_events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events); - event_arr_info = bindings.LDKCVecTempl_Event_arr_info(peer1_events); - assert event_arr_info.datalen == 1; - bindings.LDKEvent sent = bindings.LDKEvent_ref_from_ptr(event_arr_info.dataptr); + long[] peer1_events = bindings.EventsProvider_get_and_clear_pending_events(peer1.chan_manager_events); + assert peer1_events.length == 1; + bindings.LDKEvent sent = bindings.LDKEvent_ref_from_ptr(peer1_events[0]); assert sent instanceof bindings.LDKEvent.PaymentSent; assert Arrays.equals(((bindings.LDKEvent.PaymentSent)sent).payment_preimage, payment_preimage); bindings.CVec_EventZ_free(peer1_events);