+ return ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelReestablish 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInit 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPing 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPong 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedChannelAnnouncement 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedChannelUpdate 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKErrorMessage 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedNodeAnnouncement 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKQueryShortChannelIds 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKReplyShortChannelIdsEnd 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKQueryChannelRange 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKReplyChannelRange 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKGossipTimestampFilter 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCVec_u8Z res_var = (*val->contents.result);
+ int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
+ (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
+ return res_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray 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 clz, int64_t arg) {
+ LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 clz, int64_t arg) {
+ return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray 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 clz, int64_t arg) {
+ LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 clz, int64_t arg) {
+ return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
+ return err_conv;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKTrustedCommitmentTransaction 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
+}
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCVec_SignatureZ res_var = (*val->contents.result);
+ jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < res_var.datalen; i++) {
+ int8_tArray 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 void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKRouteHop arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = RouteHop_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
+ LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = RouteHop_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
+ LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKRouteHint arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+ LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = RouteHint_clone(&orig->data[i]);
+ }
+ return ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKRoutingFees 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeAnnouncementInfo 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeInfo 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNetworkGraph 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 = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError 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 = (long)err_var.inner & ~1;
+ return err_ref;
+}
+typedef struct LDKMessageSendEventsProvider_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_and_clear_pending_msg_events_meth;
+} LDKMessageSendEventsProvider_JCalls;
+static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
+ LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
+ LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
+ JNIEnv *env;
+ 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);
+ int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
+ 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;
+ int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
+ for (size_t s = 0; s < arg_constr.datalen; s++) {
+ int64_t arr_conv_18 = arg_vals[s];
+ LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_conv_18) & ~1);
+ FREE((void*)arr_conv_18);
+ arg_constr.data[s] = arr_conv_18_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
+ return arg_constr;
+}
+static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
+ LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
+ 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");
+ CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
+
+ LDKMessageSendEventsProvider ret = {
+ .this_arg = (void*) calls,
+ .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
+ .free = LDKMessageSendEventsProvider_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+ *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
+ return (long)res_ptr;
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
+ LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t s = 0; s < ret_var.datalen; s++) {
+ LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
+ *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
+ long arr_conv_18_ref = (long)arr_conv_18_copy;
+ ret_arr_ptr[s] = arr_conv_18_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKEventsProvider_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_and_clear_pending_events_meth;
+} LDKEventsProvider_JCalls;
+static void LDKEventsProvider_JCalls_free(void* this_arg) {
+ LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
+ LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
+ JNIEnv *env;
+ 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);
+ int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
+ 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;
+ int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
+ for (size_t h = 0; h < arg_constr.datalen; h++) {
+ int64_t arr_conv_7 = arg_vals[h];
+ LDKEvent arr_conv_7_conv = *(LDKEvent*)(((uint64_t)arr_conv_7) & ~1);
+ FREE((void*)arr_conv_7);
+ arg_constr.data[h] = arr_conv_7_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
+ return arg_constr;
+}
+static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
+ LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
+ 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");
+ CHECK(calls->get_and_clear_pending_events_meth != NULL);
+
+ LDKEventsProvider ret = {
+ .this_arg = (void*) calls,
+ .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
+ .free = LDKEventsProvider_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+ *res_ptr = LDKEventsProvider_init(env, clz, o);
+ return (long)res_ptr;
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_EventsProvider_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
+ LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t h = 0; h < ret_var.datalen; h++) {
+ LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
+ *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
+ long arr_conv_7_ref = (long)arr_conv_7_copy;
+ ret_arr_ptr[h] = arr_conv_7_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKAccess_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_utxo_meth;
+} LDKAccess_JCalls;
+static void LDKAccess_JCalls_free(void* this_arg) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
+ LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
+ return ret_conv;
+}
+static void* LDKAccess_JCalls_clone(const void* this_arg) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
+ CHECK(calls->get_utxo_meth != NULL);
+
+ LDKAccess ret = {
+ .this_arg = (void*) calls,
+ .get_utxo = get_utxo_jcall,
+ .free = LDKAccess_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
+ *res_ptr = LDKAccess_init(env, clz, o);
+ return (long)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
+ LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
+ unsigned char genesis_hash_arr[32];
+ CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
+ (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
+ unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
+ LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
+ *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
+ return (long)ret_conv;
+}
+
+typedef struct LDKFilter_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID register_tx_meth;
+ jmethodID register_output_meth;
+} LDKFilter_JCalls;
+static void LDKFilter_JCalls_free(void* this_arg) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
+ LDKu8slice script_pubkey_var = script_pubkey;
+ int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
+ (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
+}
+void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKOutPoint outpoint_var = *outpoint;
+ outpoint_var = OutPoint_clone(outpoint);
+ CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long outpoint_ref = (long)outpoint_var.inner;
+ if (outpoint_var.is_owned) {
+ outpoint_ref |= 1;
+ }
+ LDKu8slice script_pubkey_var = script_pubkey;
+ int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
+ (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
+}
+static void* LDKFilter_JCalls_clone(const void* this_arg) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
+ CHECK(calls->register_tx_meth != NULL);
+ calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
+ CHECK(calls->register_output_meth != NULL);
+
+ LDKFilter ret = {
+ .this_arg = (void*) calls,
+ .register_tx = register_tx_jcall,
+ .register_output = register_output_jcall,
+ .free = LDKFilter_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
+ *res_ptr = LDKFilter_init(env, clz, o);
+ return (long)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
+ unsigned char txid_arr[32];
+ CHECK((*env)->GetArrayLength(env, txid) == 32);
+ (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
+ unsigned char (*txid_ref)[32] = &txid_arr;
+ LDKu8slice script_pubkey_ref;
+ script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
+ script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
+ (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
+ (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t outpoint, int8_tArray script_pubkey) {
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
+ LDKOutPoint outpoint_conv;
+ outpoint_conv.inner = (void*)(outpoint & (~1));
+ outpoint_conv.is_owned = false;
+ LDKu8slice script_pubkey_ref;
+ script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
+ script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
+ (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
+ (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
+}
+
+typedef struct LDKPersist_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID persist_new_channel_meth;
+ jmethodID update_persisted_channel_meth;
+} LDKPersist_JCalls;
+static void LDKPersist_JCalls_free(void* this_arg) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKOutPoint id_var = id;
+ CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long id_ref = (long)id_var.inner;
+ if (id_var.is_owned) {
+ id_ref |= 1;
+ }
+ LDKChannelMonitor data_var = *data;
+ data_var = ChannelMonitor_clone(data);
+ CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long data_ref = (long)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKOutPoint id_var = id;
+ CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long id_ref = (long)id_var.inner;
+ if (id_var.is_owned) {
+ id_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = *update;
+ update_var = ChannelMonitorUpdate_clone(update);
+ CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long update_ref = (long)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ LDKChannelMonitor data_var = *data;
+ data_var = ChannelMonitor_clone(data);
+ CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long data_ref = (long)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
+ return ret_conv;
+}
+static void* LDKPersist_JCalls_clone(const void* this_arg) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
+ CHECK(calls->persist_new_channel_meth != NULL);
+ calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
+ CHECK(calls->update_persisted_channel_meth != NULL);
+
+ LDKPersist ret = {
+ .this_arg = (void*) calls,
+ .persist_new_channel = persist_new_channel_jcall,
+ .update_persisted_channel = update_persisted_channel_jcall,
+ .free = LDKPersist_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
+ *res_ptr = LDKPersist_init(env, clz, o);
+ return (long)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
+ LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
+ LDKOutPoint id_conv;
+ id_conv.inner = (void*)(id & (~1));
+ id_conv.is_owned = (id & 1) || (id == 0);
+ id_conv = OutPoint_clone(&id_conv);
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
+ LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
+ LDKOutPoint id_conv;
+ id_conv.inner = (void*)(id & (~1));
+ id_conv.is_owned = (id & 1) || (id == 0);
+ id_conv = OutPoint_clone(&id_conv);
+ LDKChannelMonitorUpdate update_conv;
+ update_conv.inner = (void*)(update & (~1));
+ update_conv.is_owned = false;
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+ return (long)ret_conv;
+}
+
+typedef struct LDKChannelMessageHandler_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
+ jmethodID handle_open_channel_meth;
+ jmethodID handle_accept_channel_meth;
+ jmethodID handle_funding_created_meth;
+ jmethodID handle_funding_signed_meth;
+ jmethodID handle_funding_locked_meth;
+ jmethodID handle_shutdown_meth;
+ jmethodID handle_closing_signed_meth;
+ jmethodID handle_update_add_htlc_meth;
+ jmethodID handle_update_fulfill_htlc_meth;
+ jmethodID handle_update_fail_htlc_meth;
+ jmethodID handle_update_fail_malformed_htlc_meth;
+ jmethodID handle_commitment_signed_meth;
+ jmethodID handle_revoke_and_ack_meth;
+ jmethodID handle_update_fee_meth;
+ jmethodID handle_announcement_signatures_meth;
+ jmethodID peer_disconnected_meth;
+ jmethodID peer_connected_meth;
+ jmethodID handle_channel_reestablish_meth;
+ jmethodID handle_error_meth;
+} LDKChannelMessageHandler_JCalls;
+static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKInitFeatures their_features_var = their_features;
+ CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long their_features_ref = (long)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKOpenChannel msg_var = *msg;
+ msg_var = OpenChannel_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+}
+void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKInitFeatures their_features_var = their_features;
+ CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long their_features_ref = (long)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKAcceptChannel msg_var = *msg;
+ msg_var = AcceptChannel_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+}
+void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKFundingCreated msg_var = *msg;
+ msg_var = FundingCreated_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
+}
+void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKFundingSigned msg_var = *msg;
+ msg_var = FundingSigned_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKFundingLocked msg_var = *msg;
+ msg_var = FundingLocked_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
+}
+void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKShutdown msg_var = *msg;
+ msg_var = Shutdown_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
+}
+void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKClosingSigned msg_var = *msg;
+ msg_var = ClosingSigned_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKUpdateAddHTLC msg_var = *msg;
+ msg_var = UpdateAddHTLC_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKUpdateFulfillHTLC msg_var = *msg;
+ msg_var = UpdateFulfillHTLC_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKUpdateFailHTLC msg_var = *msg;
+ msg_var = UpdateFailHTLC_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKUpdateFailMalformedHTLC msg_var = *msg;
+ msg_var = UpdateFailMalformedHTLC_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKCommitmentSigned msg_var = *msg;
+ msg_var = CommitmentSigned_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKRevokeAndACK msg_var = *msg;
+ msg_var = RevokeAndACK_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKUpdateFee msg_var = *msg;
+ msg_var = UpdateFee_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
+}
+void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKAnnouncementSignatures msg_var = *msg;
+ msg_var = AnnouncementSignatures_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
+}
+void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
+}
+void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKInit msg_var = *msg;
+ msg_var = Init_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
+}
+void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKChannelReestablish msg_var = *msg;
+ msg_var = ChannelReestablish_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
+}
+void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKErrorMessage msg_var = *msg;
+ msg_var = ErrorMessage_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
+}
+static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
+ CHECK(calls->handle_open_channel_meth != NULL);
+ calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
+ CHECK(calls->handle_accept_channel_meth != NULL);
+ calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
+ CHECK(calls->handle_funding_created_meth != NULL);
+ calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
+ CHECK(calls->handle_funding_signed_meth != NULL);
+ calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
+ CHECK(calls->handle_funding_locked_meth != NULL);
+ calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
+ CHECK(calls->handle_shutdown_meth != NULL);
+ calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
+ CHECK(calls->handle_closing_signed_meth != NULL);
+ calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
+ CHECK(calls->handle_update_add_htlc_meth != NULL);
+ calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
+ CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
+ calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
+ CHECK(calls->handle_update_fail_htlc_meth != NULL);
+ calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
+ CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
+ calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
+ CHECK(calls->handle_commitment_signed_meth != NULL);
+ calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
+ CHECK(calls->handle_revoke_and_ack_meth != NULL);
+ calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
+ CHECK(calls->handle_update_fee_meth != NULL);
+ calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
+ CHECK(calls->handle_announcement_signatures_meth != NULL);
+ calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
+ CHECK(calls->peer_disconnected_meth != NULL);
+ calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
+ CHECK(calls->peer_connected_meth != NULL);
+ calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
+ CHECK(calls->handle_channel_reestablish_meth != NULL);
+ calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
+ CHECK(calls->handle_error_meth != NULL);
+
+ LDKChannelMessageHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_open_channel = handle_open_channel_jcall,
+ .handle_accept_channel = handle_accept_channel_jcall,
+ .handle_funding_created = handle_funding_created_jcall,
+ .handle_funding_signed = handle_funding_signed_jcall,
+ .handle_funding_locked = handle_funding_locked_jcall,
+ .handle_shutdown = handle_shutdown_jcall,
+ .handle_closing_signed = handle_closing_signed_jcall,
+ .handle_update_add_htlc = handle_update_add_htlc_jcall,
+ .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
+ .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
+ .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
+ .handle_commitment_signed = handle_commitment_signed_jcall,
+ .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
+ .handle_update_fee = handle_update_fee_jcall,
+ .handle_announcement_signatures = handle_announcement_signatures_jcall,
+ .peer_disconnected = peer_disconnected_jcall,
+ .peer_connected = peer_connected_jcall,
+ .handle_channel_reestablish = handle_channel_reestablish_jcall,
+ .handle_error = handle_error_jcall,
+ .free = LDKChannelMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
+ LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+ *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
+ return (long)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKInitFeatures their_features_conv;
+ their_features_conv.inner = (void*)(their_features & (~1));
+ their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
+ // Warning: we need a move here but no clone is available for LDKInitFeatures
+ LDKOpenChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKInitFeatures their_features_conv;
+ their_features_conv.inner = (void*)(their_features & (~1));
+ their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
+ // Warning: we need a move here but no clone is available for LDKInitFeatures
+ LDKAcceptChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKFundingCreated msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKFundingSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKFundingLocked msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKShutdown msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKClosingSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKUpdateAddHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKUpdateFulfillHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKUpdateFailHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKUpdateFailMalformedHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKCommitmentSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKRevokeAndACK msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKUpdateFee msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKAnnouncementSignatures msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKInit msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKChannelReestablish msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
+ LDKPublicKey their_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
+ LDKErrorMessage msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+typedef struct LDKRoutingMessageHandler_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
+ jmethodID handle_node_announcement_meth;
+ jmethodID handle_channel_announcement_meth;
+ jmethodID handle_channel_update_meth;
+ jmethodID handle_htlc_fail_channel_update_meth;
+ jmethodID get_next_channel_announcements_meth;
+ jmethodID get_next_node_announcements_meth;
+ jmethodID sync_routing_table_meth;
+ jmethodID handle_reply_channel_range_meth;
+ jmethodID handle_reply_short_channel_ids_end_meth;
+ jmethodID handle_query_channel_range_meth;
+ jmethodID handle_query_short_channel_ids_meth;
+} LDKRoutingMessageHandler_JCalls;
+static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKNodeAnnouncement msg_var = *msg;
+ msg_var = NodeAnnouncement_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKChannelAnnouncement msg_var = *msg;
+ msg_var = ChannelAnnouncement_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKChannelUpdate msg_var = *msg;
+ msg_var = ChannelUpdate_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
+ return ret_conv;
+}
+void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ long ret_update = (long)update;
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
+}
+LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ 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);
+ int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
+ 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;
+ int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
+ for (size_t l = 0; l < arg_constr.datalen; l++) {
+ int64_t arr_conv_63 = arg_vals[l];
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_conv_63) & ~1);
+ FREE((void*)arr_conv_63);
+ arg_constr.data[l] = arr_conv_63_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
+ return arg_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;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
+ 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;
+ int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
+ for (size_t s = 0; s < arg_constr.datalen; s++) {
+ int64_t 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);
+ arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
+ arg_constr.data[s] = arr_conv_18_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
+ return arg_constr;
+}
+void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKInit init_var = *init;
+ init_var = Init_clone(init);
+ CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long init_ref = (long)init_var.inner;
+ if (init_var.is_owned) {
+ init_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ return (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
+}
+LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKReplyChannelRange msg_var = msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKReplyShortChannelIdsEnd msg_var = msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKQueryChannelRange msg_var = msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
+ LDKQueryShortChannelIds msg_var = msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
+ return ret_conv;
+}
+static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
+ CHECK(calls->handle_node_announcement_meth != NULL);
+ calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
+ CHECK(calls->handle_channel_announcement_meth != NULL);
+ calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
+ 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");
+ CHECK(calls->get_next_channel_announcements_meth != NULL);
+ 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->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
+ CHECK(calls->sync_routing_table_meth != NULL);
+ calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
+ CHECK(calls->handle_reply_channel_range_meth != NULL);
+ calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
+ CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
+ calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
+ CHECK(calls->handle_query_channel_range_meth != NULL);
+ calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
+ CHECK(calls->handle_query_short_channel_ids_meth != NULL);
+
+ LDKRoutingMessageHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_node_announcement = handle_node_announcement_jcall,
+ .handle_channel_announcement = handle_channel_announcement_jcall,
+ .handle_channel_update = handle_channel_update_jcall,
+ .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
+ .get_next_channel_announcements = get_next_channel_announcements_jcall,
+ .get_next_node_announcements = get_next_node_announcements_jcall,
+ .sync_routing_table = sync_routing_table_jcall,
+ .handle_reply_channel_range = handle_reply_channel_range_jcall,
+ .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
+ .handle_query_channel_range = handle_query_channel_range_jcall,
+ .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
+ .free = LDKRoutingMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;