From: Matt Corallo Date: Thu, 15 Oct 2020 00:01:35 +0000 (-0400) Subject: Split get_inner into get_ok/_err so that we can map the type being returned X-Git-Tag: v0.0.1~102 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e80662baa08a88a30a31fa24c8c7410f1e5eb8f9;p=ldk-java Split get_inner into get_ok/_err so that we can map the type being returned --- diff --git a/genbindings.py b/genbindings.py index f4086f56..a2bc2a73 100755 --- a/genbindings.py +++ b/genbindings.py @@ -119,6 +119,11 @@ def java_c_types(fn_arg, ret_arr_len): assert var_is_arr_regex.match(fn_arg[8:]) rust_obj = "LDKu8slice" arr_access = "data" + if fn_arg.startswith("LDKCVecTempl_u8"): + fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]" + assert var_is_arr_regex.match(fn_arg[8:]) + rust_obj = "LDKCVecTempl_u8" + arr_access = "data" if fn_arg.startswith("void"): java_ty = "void" @@ -197,8 +202,6 @@ def java_c_types(fn_arg, ret_arr_len): return TypeInfo(rust_obj=rust_obj, java_ty=java_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) - - fn_ptr_regex = re.compile("^extern const ([A-Za-z_0-9\* ]*) \(\*(.*)\)\((.*)\);$") fn_ret_arr_regex = re.compile("(.*) \(\*(.*)\((.*)\)\)\[([0-9]*)\];$") reg_fn_regex = re.compile("([A-Za-z_0-9\* ]* \*?)([a-zA-Z_0-9]*)\((.*)\);$") @@ -1341,27 +1344,36 @@ class CommonBase { 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_java.write("\tpublic static native long " + alias_match.group(2) + "_get_inner(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_c.write("JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_" + alias_match.group(2).replace("_", "_1") + "_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {\n") - contents_ty = alias_match.group(1).replace("LDKCResultTempl", "LDKCResultPtr") - res_ty, err_ty = result_ptr_struct_items[contents_ty] + + 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("\tif (val->result_ok) {\n") - if res_ty not in opaque_structs: - out_c.write("\t\treturn (long)val->contents.result;\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("\t\treturn (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0);\n") - out_c.write("\t} else {\n") - if err_ty not in opaque_structs: - out_c.write("\t\treturn (long)val->contents.err;\n") + 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("\t\treturn (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);\n") - out_c.write("\t}\n}\n") - pass + out_c.write("return *val->contents.err") 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 37a9bc33..a6d965bb 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -36,9 +36,11 @@ public class bindings { public static native long LDKCVecTempl_u8_new(byte[] elems); public static native long LDKC2TupleTempl_usize__Transaction_new(long a, long b); public static native boolean LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(long arg); - public static native long LDKCResult_NoneChannelMonitorUpdateErrZ_get_inner(long arg); + public static native byte LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(long arg); + public static native LDKChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(long arg); public static native boolean LDKCResult_NoneMonitorUpdateErrorZ_result_ok(long arg); - public static native long LDKCResult_NoneMonitorUpdateErrorZ_get_inner(long arg); + 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, long b); public static native VecOrSliceDef LDKCVecTempl_TxOut_arr_info(long vec_ptr); public static native long LDKCVecTempl_TxOut_new(long[] elems); @@ -47,11 +49,14 @@ public class bindings { 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 boolean LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(long arg); - public static native long LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_inner(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); public static native boolean LDKCResult_SignatureNoneZ_result_ok(long arg); - public static native long LDKCResult_SignatureNoneZ_get_inner(long arg); + 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_inner(long arg); + public static native long LDKCResult_CVec_SignatureZNoneZ_get_ok(long arg); + public static native byte LDKCResult_CVec_SignatureZNoneZ_get_err(long arg); public static class LDKAPIError { private LDKAPIError() {} public final static class APIMisuseError extends LDKAPIError { @@ -78,12 +83,15 @@ public class bindings { static { LDKAPIError.init(); } public static native LDKAPIError LDKAPIError_ref_from_ptr(long ptr); public static native boolean LDKCResult_NoneAPIErrorZ_result_ok(long arg); - public static native long LDKCResult_NoneAPIErrorZ_get_inner(long arg); + public static native byte LDKCResult_NoneAPIErrorZ_get_ok(long arg); + public static native long LDKCResult_NoneAPIErrorZ_get_err(long arg); public static native boolean LDKCResult_NonePaymentSendFailureZ_result_ok(long arg); - public static native long LDKCResult_NonePaymentSendFailureZ_get_inner(long arg); + 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 boolean LDKCResult_NonePeerHandleErrorZ_result_ok(long arg); - public static native long LDKCResult_NonePeerHandleErrorZ_get_inner(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 class LDKSpendableOutputDescriptor { private LDKSpendableOutputDescriptor() {} @@ -297,7 +305,8 @@ public class bindings { public static native long LDKLogger_new(LDKLogger impl); public static native LDKLogger LDKLogger_get_obj_from_jcalls(long val); public static native boolean LDKCResult_TxOutAccessErrorZ_result_ok(long arg); - public static native long LDKCResult_TxOutAccessErrorZ_get_inner(long arg); + public static native long LDKCResult_TxOutAccessErrorZ_get_ok(long arg); + public static native LDKAccessError LDKCResult_TxOutAccessErrorZ_get_err(long arg); public interface LDKAccess { long get_utxo(byte[] genesis_hash, long short_channel_id); } @@ -514,7 +523,8 @@ public class bindings { public static native long[] LDKCVecTempl_UpdateFailMalformedHTLC_arr_info(long vec_ptr); public static native long LDKCVecTempl_UpdateFailMalformedHTLC_new(long[] elems); public static native boolean LDKCResult_boolLightningErrorZ_result_ok(long arg); - public static native long LDKCResult_boolLightningErrorZ_get_inner(long arg); + public static native boolean LDKCResult_boolLightningErrorZ_get_ok(long arg); + public static native long LDKCResult_boolLightningErrorZ_get_err(long arg); public static native VecOrSliceDef LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate_arr_info(long vec_ptr); public static native long LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate_new(long[] elems); public static native long[] LDKCVecTempl_NodeAnnouncement_arr_info(long vec_ptr); @@ -560,15 +570,20 @@ public class bindings { public static native long SocketDescriptor_hash(long this_arg); public static native VecOrSliceDef LDKCVecTempl_PublicKey_arr_info(long vec_ptr); public static native boolean LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(long arg); - public static native long LDKCResult_CVec_u8ZPeerHandleErrorZ_get_inner(long arg); + public static native byte[] LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(long arg); + public static native long LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(long arg); public static native boolean LDKCResult_boolPeerHandleErrorZ_result_ok(long arg); - public static native long LDKCResult_boolPeerHandleErrorZ_get_inner(long arg); + public static native boolean LDKCResult_boolPeerHandleErrorZ_get_ok(long arg); + public static native long LDKCResult_boolPeerHandleErrorZ_get_err(long arg); public static native boolean LDKCResult_SecretKeySecpErrorZ_result_ok(long arg); - public static native long LDKCResult_SecretKeySecpErrorZ_get_inner(long arg); + public static native byte[] LDKCResult_SecretKeySecpErrorZ_get_ok(long arg); + public static native LDKSecp256k1Error LDKCResult_SecretKeySecpErrorZ_get_err(long arg); public static native boolean LDKCResult_PublicKeySecpErrorZ_result_ok(long arg); - public static native long LDKCResult_PublicKeySecpErrorZ_get_inner(long arg); + public static native byte[] LDKCResult_PublicKeySecpErrorZ_get_ok(long arg); + public static native LDKSecp256k1Error LDKCResult_PublicKeySecpErrorZ_get_err(long arg); public static native boolean LDKCResult_TxCreationKeysSecpErrorZ_result_ok(long arg); - public static native long LDKCResult_TxCreationKeysSecpErrorZ_get_inner(long arg); + public static native long LDKCResult_TxCreationKeysSecpErrorZ_get_ok(long arg); + public static native LDKSecp256k1Error LDKCResult_TxCreationKeysSecpErrorZ_get_err(long arg); public static native VecOrSliceDef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature_arr_info(long vec_ptr); public static native long LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature_new(long[] elems); public static native long[] LDKCVecTempl_RouteHop_arr_info(long vec_ptr); @@ -576,7 +591,8 @@ public class bindings { 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_inner(long arg); + public static native long LDKCResult_RouteLightningErrorZ_get_ok(long arg); + public static native long LDKCResult_RouteLightningErrorZ_get_err(long arg); public static native long[] LDKCVecTempl_RouteHint_arr_info(long vec_ptr); public static native long LDKCVecTempl_RouteHint_new(long[] elems); // extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ); diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index e9348d51..9858f24f 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -450,24 +450,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1usize_1_1Tra JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + CHECK(val->result_ok); + return *val->contents.result; +} +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; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + return *val->contents.result; +} +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); } JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) { LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z"); @@ -539,35 +545,47 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +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; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + 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; +} +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; + CHECK(!val->result_ok); + return *val->contents.err; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_SignatureNoneZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + 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; +} +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv * _env, jclass _a, jlong arg) { + LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg; + CHECK(!val->result_ok); + return *val->contents.err; } 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_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jlong 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; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + CHECK(val->result_ok); + LDKCVecTempl_Signature* ret = MALLOC(sizeof(LDKCVecTempl_Signature), "LDKCVecTempl_Signature"); + *ret = (*val->contents.result); + return (long)ret; +} +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; + CHECK(!val->result_ok); + return *val->contents.err; } static jclass LDKAPIError_APIMisuseError_class = NULL; static jmethodID LDKAPIError_APIMisuseError_meth = NULL; @@ -634,24 +652,31 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + CHECK(val->result_ok); + return *val->contents.result; +} +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; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + return *val->contents.result; +} +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); } 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"); @@ -678,13 +703,16 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3TupleTempl_1ChannelAnnou JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + return *val->contents.result; +} +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); } 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"); @@ -1562,13 +1590,18 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + CHECK(val->result_ok); + LDKTxOut* ret = MALLOC(sizeof(LDKTxOut), "LDKTxOut"); + *ret = (*val->contents.result); + return (long)ret; +} +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; } typedef struct LDKAccess_JCalls { atomic_size_t refcnt; @@ -3479,13 +3512,16 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalfo JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + return *val->contents.result; +} +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); } 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; @@ -3872,57 +3908,80 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1ar JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +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; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + LDKCVecTempl_u8 l_u8_var = (*val->contents.result); + jbyteArray l_u8_arr = (*_env)->NewByteArray(_env, l_u8_var.datalen); + (*_env)->SetByteArrayRegion(_env, l_u8_arr, 0, l_u8_var.datalen, l_u8_var.data); + return l_u8_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); } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + return *val->contents.result; +} +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); } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + 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; +} +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; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg; - if (val->result_ok) { - return (long)val->contents.result; - } else { - return (long)val->contents.err; - } + 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; +} +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; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) { return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok; } -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg; - if (val->result_ok) { - return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0); - } else { - return (long)val->contents.err; - } + CHECK(val->result_ok); + LDKTxCreationKeys ret = (*val->contents.result); + return ((long)ret.inner) | (ret.is_owned ? 1 : 0); +} +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; } 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; @@ -4003,13 +4062,17 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1Rout 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_1inner (JNIEnv * env, jclass _a, jlong arg) { +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok (JNIEnv * _env, jclass _a, jlong arg) { LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg; - if (val->result_ok) { - return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0); - } else { - return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0); - } + CHECK(val->result_ok); + LDKRoute ret = (*val->contents.result); + return ((long)ret.inner) | (ret.is_owned ? 1 : 0); +} +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); } JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) { LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr; diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index 65a15536..c46c4c76 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -121,10 +121,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMon /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneChannelMonitorUpdateErrZ_get_inner - * Signature: (J)J + * Method: LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneChannelMonitorUpdateErrZ_get_err + * Signature: (J)Lorg/ldk/enums/LDKChannelMonitorUpdateErr; */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1inner +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -137,10 +145,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpd /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneMonitorUpdateErrorZ_get_inner + * Method: LDKCResult_NoneMonitorUpdateErrorZ_get_ok + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneMonitorUpdateErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -209,10 +225,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1Signa /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_inner + * Method: LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -225,10 +249,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_SignatureNoneZ_get_inner - * Signature: (J)J + * Method: LDKCResult_SignatureNoneZ_get_ok + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_SignatureNoneZ_get_err + * Signature: (J)B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -241,10 +273,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1Signatur /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_CVec_SignatureZNoneZ_get_inner + * Method: LDKCResult_CVec_SignatureZNoneZ_get_ok * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_CVec_SignatureZNoneZ_get_err + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -265,10 +305,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_ /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneAPIErrorZ_get_inner + * Method: LDKCResult_NoneAPIErrorZ_get_ok + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneAPIErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -281,10 +329,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSen /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_NonePaymentSendFailureZ_get_inner + * Method: LDKCResult_NonePaymentSendFailureZ_get_ok + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NonePaymentSendFailureZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -305,10 +361,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandle /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_NonePeerHandleErrorZ_get_inner + * Method: LDKCResult_NonePeerHandleErrorZ_get_ok + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NonePeerHandleErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -481,10 +545,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErr /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_TxOutAccessErrorZ_get_inner + * Method: LDKCResult_TxOutAccessErrorZ_get_ok * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_TxOutAccessErrorZ_get_err + * Signature: (J)Lorg/ldk/enums/LDKAccessError; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1185,10 +1257,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningE /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_boolLightningErrorZ_get_inner + * Method: LDKCResult_boolLightningErrorZ_get_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_boolLightningErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1353,10 +1433,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerH /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_CVec_u8ZPeerHandleErrorZ_get_inner + * Method: LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1369,10 +1457,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandle /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_boolPeerHandleErrorZ_get_inner + * Method: LDKCResult_boolPeerHandleErrorZ_get_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_boolPeerHandleErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1385,10 +1481,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpE /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_SecretKeySecpErrorZ_get_inner - * Signature: (J)J + * Method: LDKCResult_SecretKeySecpErrorZ_get_ok + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_SecretKeySecpErrorZ_get_err + * Signature: (J)Lorg/ldk/enums/LDKSecp256k1Error; */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1401,10 +1505,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpE /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_PublicKeySecpErrorZ_get_inner - * Signature: (J)J + * Method: LDKCResult_PublicKeySecpErrorZ_get_ok + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_PublicKeySecpErrorZ_get_err + * Signature: (J)Lorg/ldk/enums/LDKSecp256k1Error; */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1417,10 +1529,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeys /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_TxCreationKeysSecpErrorZ_get_inner + * Method: LDKCResult_TxCreationKeysSecpErrorZ_get_ok * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_TxCreationKeysSecpErrorZ_get_err + * Signature: (J)Lorg/ldk/enums/LDKSecp256k1Error; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* @@ -1481,10 +1601,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightning /* * Class: org_ldk_impl_bindings - * Method: LDKCResult_RouteLightningErrorZ_get_inner + * Method: LDKCResult_RouteLightningErrorZ_get_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_RouteLightningErrorZ_get_err * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err (JNIEnv *, jclass, jlong); /* diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index 8103b23c..30c94ea1 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -1,6 +1,5 @@ package org.ldk; -import com.google.j2objc.annotations.Weak; import org.bitcoinj.core.*; import org.bitcoinj.script.Script; import org.junit.jupiter.api.Test; @@ -199,7 +198,7 @@ public class HumanObjectPeerTest { long con_res = bindings.PeerManager_new_inbound_connection(peer2.peer_manager._test_only_get_ptr(), descriptor2); assert (bindings.LDKCResult_NonePeerHandleErrorZ_result_ok(con_res)); bindings.CResult_NonePeerHandleErrorZ_free(con_res); - do_read_event(list, peer2.peer_manager, descriptor2, bindings.get_u8_slice_bytes(bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_inner(init_vec))); + do_read_event(list, peer2.peer_manager, descriptor2, bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(init_vec)); bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(init_vec); while (!list.isEmpty()) { list.poll().join(); } @@ -276,7 +275,7 @@ public class HumanObjectPeerTest { 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_inner(route), payment_hash, new byte[32]); + 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); assert bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(payment_res); bindings.CResult_NonePaymentSendFailureZ_free(payment_res); diff --git a/src/test/java/org/ldk/PeerTest.java b/src/test/java/org/ldk/PeerTest.java index 508b8361..398e159e 100644 --- a/src/test/java/org/ldk/PeerTest.java +++ b/src/test/java/org/ldk/PeerTest.java @@ -198,7 +198,7 @@ public class PeerTest { long con_res = bindings.PeerManager_new_inbound_connection(peer2.peer_manager, descriptor2); assert(bindings.LDKCResult_NonePeerHandleErrorZ_result_ok(con_res)); bindings.CResult_NonePeerHandleErrorZ_free(con_res); - do_read_event(list, peer2.peer_manager, descriptor2, bindings.get_u8_slice_bytes(bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_inner(init_vec))); + do_read_event(list, peer2.peer_manager, descriptor2, bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(init_vec)); bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(init_vec); while (!list.isEmpty()) { list.poll().join(); } @@ -280,7 +280,7 @@ public class PeerTest { bindings.CVec_ChannelDetailsZ_free(peer1_chans); 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_inner(route), payment_hash, new byte[32]); + long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route), payment_hash, new byte[32]); bindings.CResult_RouteLightningErrorZ_free(route); assert bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(payment_res); bindings.CResult_NonePaymentSendFailureZ_free(payment_res);