+static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
+static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
+static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
+static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
+static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
+static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
+static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
+static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
+static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
+static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
+static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
+static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
+static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
+static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
+static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
+static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
+static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
+static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
+static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
+static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
+static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
+static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
+static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
+static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
+static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
+static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
+static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
+static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
+static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
+static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
+static jclass LDKMessageSendEvent_HandleError_class = NULL;
+static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
+static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
+static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
+static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
+static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
+static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
+static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
+ LDKMessageSendEvent_SendAcceptChannel_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
+ CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
+ LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
+ LDKMessageSendEvent_SendOpenChannel_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
+ CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
+ LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
+ LDKMessageSendEvent_SendFundingCreated_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
+ CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
+ LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
+ LDKMessageSendEvent_SendFundingSigned_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
+ CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
+ LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
+ LDKMessageSendEvent_SendFundingLocked_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
+ CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
+ LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
+ LDKMessageSendEvent_SendAnnouncementSignatures_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
+ CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
+ LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
+ LDKMessageSendEvent_UpdateHTLCs_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
+ CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
+ LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
+ LDKMessageSendEvent_SendRevokeAndACK_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
+ CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
+ LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
+ LDKMessageSendEvent_SendClosingSigned_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
+ CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
+ LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
+ LDKMessageSendEvent_SendShutdown_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
+ CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
+ LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
+ LDKMessageSendEvent_SendChannelReestablish_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
+ CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
+ LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
+ LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
+ CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
+ LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
+ CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
+ LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
+ CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
+ LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
+ CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
+ LDKMessageSendEvent_BroadcastChannelUpdate_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
+ CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
+ LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
+ CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
+ LDKMessageSendEvent_SendChannelUpdate_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
+ CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
+ LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
+ LDKMessageSendEvent_HandleError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
+ CHECK(LDKMessageSendEvent_HandleError_class != NULL);
+ LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
+ LDKMessageSendEvent_SendChannelRangeQuery_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
+ CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
+ LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
+ LDKMessageSendEvent_SendShortIdsQuery_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
+ CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
+ LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
+ LDKMessageSendEvent_SendReplyChannelRange_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
+ CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
+ LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
+ CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKMessageSendEvent_SendAcceptChannel: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
+ LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendOpenChannel: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
+ LDKOpenChannel msg_var = obj->send_open_channel.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendFundingCreated: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
+ LDKFundingCreated msg_var = obj->send_funding_created.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendFundingSigned: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
+ LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendFundingLocked: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
+ LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendAnnouncementSignatures: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
+ LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_UpdateHTLCs: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
+ LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+ int64_t updates_ref = 0;
+ CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
+ updates_ref = (uintptr_t)updates_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
+ }
+ case LDKMessageSendEvent_SendRevokeAndACK: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
+ LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendClosingSigned: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
+ LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendShutdown: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
+ LDKShutdown msg_var = obj->send_shutdown.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendChannelReestablish: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
+ LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
+ LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+ int64_t update_msg_ref = 0;
+ CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
+ update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
+ }
+ case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
+ LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
+ }
+ case LDKMessageSendEvent_BroadcastChannelUpdate: {
+ LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
+ }
+ case LDKMessageSendEvent_SendChannelUpdate: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
+ LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_HandleError: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
+ int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
+ }
+ case LDKMessageSendEvent_SendChannelRangeQuery: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
+ LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendShortIdsQuery: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
+ LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
+ }
+ case LDKMessageSendEvent_SendReplyChannelRange: {
+ int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
+ LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner & ~1;
+ return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
+ LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return FixedPenaltyScorer_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
+ LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ScoringParameters_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
+ LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
+ LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ProbabilisticScoringParameters_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
+ LDKProbabilisticScoringParameters ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKProbabilisticScoringParameters C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
+ return ProbabilisticScoringParameters_clone(&owner->a);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
+ LDKProbabilisticScoringParameters ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNetworkGraph C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
+ return NetworkGraph_clone(&owner->b);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
+ LDKNetworkGraph ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
+ LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return InitFeatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelFeatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NodeFeatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return InvoiceFeatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelTypeFeatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return SpendableOutputDescriptor_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
+ *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
+ LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
+ return owner->a;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
+ return owner->b;
+}
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
+ LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
+ jobjectArray ret_arr = NULL;
+ ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < ret_var.datalen; i++) {
+ int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
+ (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
+ }
+
+ return ret_arr;
+}
+
+static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
+ LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
+ *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
+ return ret_arr;
+}
+
+static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
+ CResult_SignatureNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
+ return owner->a;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
+ return ret_arr;
+}
+
+static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
+ return owner->b;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
+ return ret_arr;
+}
+
+static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
+ LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
+ *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
+ CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
+ return ret_arr;
+}
+
+static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
+ CResult_SecretKeyNoneZ_get_err(owner_conv);
+}
+
+typedef struct LDKBaseSign_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_per_commitment_point_meth;
+ jmethodID release_commitment_secret_meth;
+ jmethodID validate_holder_commitment_meth;
+ jmethodID channel_keys_id_meth;
+ jmethodID sign_counterparty_commitment_meth;
+ jmethodID validate_counterparty_revocation_meth;
+ jmethodID sign_holder_commitment_and_htlcs_meth;
+ jmethodID sign_justice_revoked_output_meth;
+ jmethodID sign_justice_revoked_htlc_meth;
+ jmethodID sign_counterparty_htlc_transaction_meth;
+ jmethodID sign_closing_transaction_meth;
+ jmethodID sign_channel_announcement_meth;
+ jmethodID ready_channel_meth;
+} LDKBaseSign_JCalls;
+static void LDKBaseSign_JCalls_free(void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
+ }
+ LDKPublicKey ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 33);
+ (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
+ }
+ LDKThirtyTwoBytes ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 32);
+ (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
+ int64_t holder_tx_ref = 0;
+ holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
+ CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
+ holder_tx_ref = (uintptr_t)holder_tx_var.inner;
+ if (holder_tx_var.is_owned) {
+ holder_tx_ref |= 1;
+ }
+ LDKCVec_PaymentPreimageZ preimages_var = preimages;
+ jobjectArray preimages_arr = NULL;
+ preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < preimages_var.datalen; i++) {
+ int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
+ (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
+ }
+
+ FREE(preimages_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
+ }
+ LDKThirtyTwoBytes ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 32);
+ (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+ int64_t commitment_tx_ref = 0;
+ commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
+ CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
+ commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ LDKCVec_PaymentPreimageZ preimages_var = preimages;
+ jobjectArray preimages_arr = NULL;
+ preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < preimages_var.datalen; i++) {
+ int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
+ (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
+ }
+
+ FREE(preimages_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ int64_t commitment_tx_ref = 0;
+ commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
+ CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
+ commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
+ (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
+ (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ int64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
+ CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
+ htlc_ref = (uintptr_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKTransaction htlc_tx_var = htlc_tx;
+ int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
+ (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
+ Transaction_free(htlc_tx_var);
+ int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ int64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
+ CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
+ htlc_ref = (uintptr_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKClosingTransaction closing_tx_var = *closing_tx;
+ int64_t closing_tx_ref = 0;
+ closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
+ CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
+ closing_tx_ref = (uintptr_t)closing_tx_var.inner;
+ if (closing_tx_var.is_owned) {
+ closing_tx_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKUnsignedChannelAnnouncement msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+ int64_t channel_parameters_ref = 0;
+ channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
+ CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
+ channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
+ if (channel_parameters_var.is_owned) {
+ channel_parameters_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
+ CHECK(calls->get_per_commitment_point_meth != NULL);
+ calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
+ CHECK(calls->release_commitment_secret_meth != NULL);
+ calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
+ CHECK(calls->validate_holder_commitment_meth != NULL);
+ calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
+ CHECK(calls->channel_keys_id_meth != NULL);
+ calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
+ CHECK(calls->sign_counterparty_commitment_meth != NULL);
+ calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
+ CHECK(calls->validate_counterparty_revocation_meth != NULL);
+ calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
+ CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
+ calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
+ CHECK(calls->sign_justice_revoked_output_meth != NULL);
+ calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
+ CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
+ calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
+ CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
+ calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
+ CHECK(calls->sign_closing_transaction_meth != NULL);
+ calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
+ CHECK(calls->sign_channel_announcement_meth != NULL);
+ calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
+ CHECK(calls->ready_channel_meth != NULL);
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
+
+ LDKBaseSign ret = {
+ .this_arg = (void*) calls,
+ .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
+ .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
+ .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
+ .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
+ .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
+ .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
+ .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
+ .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
+ .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
+ .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
+ .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
+ .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
+ .ready_channel = ready_channel_LDKBaseSign_jcall,
+ .free = LDKBaseSign_JCalls_free,
+ .pubkeys = pubkeys_conv,
+ .set_pubkeys = NULL,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
+ LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+ *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
+ return ret_arr;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
+ return ret_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx, jobjectArray preimages) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction holder_tx_conv;
+ holder_tx_conv.inner = (void*)(holder_tx & (~1));
+ holder_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
+ LDKCVec_PaymentPreimageZ preimages_constr;
+ preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
+ if (preimages_constr.datalen > 0)
+ preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
+ else
+ preimages_constr.data = NULL;
+ for (size_t i = 0; i < preimages_constr.datalen; i++) {
+ int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
+ LDKThirtyTwoBytes preimages_conv_8_ref;
+ CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
+ (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
+ preimages_constr.data[i] = preimages_conv_8_ref;
+ }
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
+ return ret_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx, jobjectArray preimages) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
+ LDKCVec_PaymentPreimageZ preimages_constr;
+ preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
+ if (preimages_constr.datalen > 0)
+ preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
+ else
+ preimages_constr.data = NULL;
+ for (size_t i = 0; i < preimages_constr.datalen; i++) {
+ int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
+ LDKThirtyTwoBytes preimages_conv_8_ref;
+ CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
+ (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
+ preimages_constr.data[i] = preimages_conv_8_ref;
+ }
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ unsigned char secret_arr[32];
+ CHECK((*env)->GetArrayLength(env, secret) == 32);
+ (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
+ unsigned char (*secret_ref)[32] = &secret_arr;
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
+ (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
+ (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction htlc_tx_ref;
+ htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
+ htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
+ htlc_tx_ref.data_is_owned = true;
+ LDKPublicKey per_commitment_point_ref;
+ CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
+ (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, amount, per_commitment_point_ref, &htlc_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKClosingTransaction closing_tx_conv;
+ closing_tx_conv.inner = (void*)(closing_tx & (~1));
+ closing_tx_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKUnsignedChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
+ *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelTransactionParameters channel_parameters_conv;
+ channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
+ channel_parameters_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
+ (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
+}
+
+LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
+ if (this_arg->set_pubkeys != NULL)
+ this_arg->set_pubkeys(this_arg);
+ return this_arg->pubkeys;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+typedef struct LDKSign_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ LDKBaseSign_JCalls* BaseSign;
+ jmethodID write_meth;
+} LDKSign_JCalls;
+static void LDKSign_JCalls_free(void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
+ }
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = (*env)->GetArrayLength(env, ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
+}
+static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
+ CHECK(calls->write_meth != NULL);
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
+
+ LDKSign ret = {
+ .this_arg = (void*) calls,
+ .write = write_LDKSign_jcall,
+ .cloned = LDKSign_JCalls_cloned,
+ .free = LDKSign_JCalls_free,
+ .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
+ };
+ calls->BaseSign = ret.BaseSign.this_arg;
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
+ LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
+ *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKSign *inp = (LDKSign *)(arg & ~1);
+ uint64_t res_ptr = (uint64_t)&inp->BaseSign;
+ DO_ASSERT((res_ptr & 1) == 0);
+ return (int64_t)(res_ptr | 1);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Sign_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
+ LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
+ *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
+ return (int64_t)ret_ret;
+}
+
+static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
+ return ret_arr;
+}
+
+static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
+ CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
+}
+
+static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
+ LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
+}
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
+ LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
+ jobjectArray ret_arr = NULL;
+ ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < ret_var.datalen; i++) {
+ LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
+ int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
+ CVec_u8Z_free(ret_conv_8_var);
+ (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
+ CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return InMemorySigner_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
+ LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
+ LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = TxOut_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
+ LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ return ret_arr;
+}
+
+static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
+ CResult_TransactionNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
+ return ChannelMonitor_clone(&owner->b);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
+ LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
+ LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
+ LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t j = 0; j < ret_var.datalen; j++) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ *ret_conv_35_conv = ret_var.data[j];
+ ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static jclass LDKCOption_u16Z_Some_class = NULL;
+static jmethodID LDKCOption_u16Z_Some_meth = NULL;
+static jclass LDKCOption_u16Z_None_class = NULL;
+static jmethodID LDKCOption_u16Z_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
+ LDKCOption_u16Z_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
+ CHECK(LDKCOption_u16Z_Some_class != NULL);
+ LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
+ CHECK(LDKCOption_u16Z_Some_meth != NULL);
+ LDKCOption_u16Z_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
+ CHECK(LDKCOption_u16Z_None_class != NULL);
+ LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
+ CHECK(LDKCOption_u16Z_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_u16Z_Some: {
+ return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
+ }
+ case LDKCOption_u16Z_None: {
+ return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
+ }
+ default: abort();
+ }
+}
+static jclass LDKAPIError_APIMisuseError_class = NULL;
+static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
+static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
+static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
+static jclass LDKAPIError_RouteError_class = NULL;
+static jmethodID LDKAPIError_RouteError_meth = NULL;
+static jclass LDKAPIError_ChannelUnavailable_class = NULL;
+static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
+static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
+static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
+static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
+static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
+ LDKAPIError_APIMisuseError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
+ CHECK(LDKAPIError_APIMisuseError_class != NULL);
+ LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
+ CHECK(LDKAPIError_APIMisuseError_meth != NULL);
+ LDKAPIError_FeeRateTooHigh_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
+ CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
+ LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
+ CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
+ LDKAPIError_RouteError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
+ CHECK(LDKAPIError_RouteError_class != NULL);
+ LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
+ CHECK(LDKAPIError_RouteError_meth != NULL);
+ LDKAPIError_ChannelUnavailable_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
+ CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
+ LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
+ CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
+ LDKAPIError_MonitorUpdateFailed_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
+ CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
+ LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
+ CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
+ LDKAPIError_IncompatibleShutdownScript_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
+ CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
+ LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
+ CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKAPIError_APIMisuseError: {
+ LDKStr err_str = obj->api_misuse_error.err;
+ jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
+ return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
+ }
+ case LDKAPIError_FeeRateTooHigh: {
+ LDKStr err_str = obj->fee_rate_too_high.err;
+ jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
+ return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
+ }
+ case LDKAPIError_RouteError: {
+ LDKStr err_str = obj->route_error.err;
+ jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
+ return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
+ }
+ case LDKAPIError_ChannelUnavailable: {
+ LDKStr err_str = obj->channel_unavailable.err;
+ jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
+ return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
+ }
+ case LDKAPIError_MonitorUpdateFailed: {
+ return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
+ }
+ case LDKAPIError_IncompatibleShutdownScript: {
+ LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+ int64_t script_ref = 0;
+ CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
+ script_ref = (uintptr_t)script_var.inner & ~1;
+ return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
+ }
+ default: abort();
+ }
+}
+static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
+ CResult_NoneAPIErrorZ_get_ok(owner_conv);
+}
+
+static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return APIError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
+ LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
+ *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
+ LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
+ LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = APIError_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return APIError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
+ LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
+ *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
+static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
+static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
+static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
+static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
+static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
+static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
+static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
+ LDKPaymentSendFailure_ParameterError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
+ CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
+ LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
+ CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
+ LDKPaymentSendFailure_PathParameterError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
+ CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
+ LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
+ CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
+ LDKPaymentSendFailure_AllFailedRetrySafe_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
+ CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
+ LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
+ CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
+ LDKPaymentSendFailure_PartialFailure_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
+ CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
+ LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
+ CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentSendFailure_ParameterError: {
+ int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
+ return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
+ }
+ case LDKPaymentSendFailure_PathParameterError: {
+ LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
+ int64_tArray path_parameter_error_arr = NULL;
+ path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
+ int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
+ for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
+ LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+ *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
+ *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
+ path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
+ return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
+ }
+ case LDKPaymentSendFailure_AllFailedRetrySafe: {
+ LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
+ int64_tArray all_failed_retry_safe_arr = NULL;
+ all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
+ int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
+ for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
+ int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
+ all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
+ return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
+ }
+ case LDKPaymentSendFailure_PartialFailure: {
+ LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+ int64_tArray results_arr = NULL;
+ results_arr = (*env)->NewLongArray(env, results_var.datalen);
+ int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
+ for (size_t w = 0; w < results_var.datalen; w++) {
+ LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+ *results_conv_22_conv = results_var.data[w];
+ *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+ results_arr_ptr[w] = (int64_t)results_conv_22_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
+ LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+ int64_t failed_paths_retry_ref = 0;
+ if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
+ CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
+ failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
+ }
+ int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
+ return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PaymentSendFailure_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
+ LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
+ *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
+ CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
+}
+
+static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PaymentSendFailure_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
+ LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
+ *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->b);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
+ LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
+ *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PaymentSendFailure_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
+ LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
+ *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static jclass LDKNetAddress_IPv4_class = NULL;
+static jmethodID LDKNetAddress_IPv4_meth = NULL;
+static jclass LDKNetAddress_IPv6_class = NULL;
+static jmethodID LDKNetAddress_IPv6_meth = NULL;
+static jclass LDKNetAddress_OnionV2_class = NULL;
+static jmethodID LDKNetAddress_OnionV2_meth = NULL;
+static jclass LDKNetAddress_OnionV3_class = NULL;
+static jmethodID LDKNetAddress_OnionV3_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
+ LDKNetAddress_IPv4_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
+ CHECK(LDKNetAddress_IPv4_class != NULL);
+ LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
+ CHECK(LDKNetAddress_IPv4_meth != NULL);
+ LDKNetAddress_IPv6_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
+ CHECK(LDKNetAddress_IPv6_class != NULL);
+ LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
+ CHECK(LDKNetAddress_IPv6_meth != NULL);
+ LDKNetAddress_OnionV2_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
+ CHECK(LDKNetAddress_OnionV2_class != NULL);
+ LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
+ CHECK(LDKNetAddress_OnionV2_meth != NULL);
+ LDKNetAddress_OnionV3_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
+ CHECK(LDKNetAddress_OnionV3_class != NULL);
+ LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
+ CHECK(LDKNetAddress_OnionV3_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKNetAddress_IPv4: {
+ int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
+ (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
+ return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
+ }
+ case LDKNetAddress_IPv6: {
+ int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
+ (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
+ return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
+ }
+ case LDKNetAddress_OnionV2: {
+ int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
+ (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
+ return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
+ }
+ case LDKNetAddress_OnionV3: {
+ int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
+ return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
+ LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = NetAddress_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->b);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
+ LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
+ *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
+ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
+ LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
+ *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return APIError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
+ LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
+ *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
+ CResult_PaymentSecretNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return APIError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
+ LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
+ *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return APIError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
+ LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
+ *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CounterpartyForwardingInfo_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
+ LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelCounterparty_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
+ LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelDetails_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
+ LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return PhantomRouteHints_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
+ LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
+ LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
+ }
+ return ret;
+}
+typedef struct LDKWatch_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID watch_channel_meth;
+ jmethodID update_channel_meth;
+ jmethodID release_pending_monitor_events_meth;
+} LDKWatch_JCalls;
+static void LDKWatch_JCalls_free(void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKOutPoint funding_txo_var = funding_txo;
+ int64_t funding_txo_ref = 0;
+ CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
+ funding_txo_ref = (uintptr_t)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitor monitor_var = monitor;
+ int64_t monitor_ref = 0;
+ CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
+ monitor_ref = (uintptr_t)monitor_var.inner;
+ if (monitor_var.is_owned) {
+ monitor_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKOutPoint funding_txo_var = funding_txo;
+ int64_t funding_txo_ref = 0;
+ CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
+ funding_txo_ref = (uintptr_t)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = update;
+ int64_t update_ref = 0;
+ CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
+ update_ref = (uintptr_t)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
+ }
+ LDKCVec_MonitorEventZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t o = 0; o < ret_constr.datalen; o++) {
+ int64_t ret_conv_14 = ret_vals[o];
+ void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
+ CHECK_ACCESS(ret_conv_14_ptr);
+ LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
+ FREE((void*)ret_conv_14);
+ ret_constr.data[o] = ret_conv_14_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
+ CHECK(calls->watch_channel_meth != NULL);
+ calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
+ CHECK(calls->update_channel_meth != NULL);
+ calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
+ CHECK(calls->release_pending_monitor_events_meth != NULL);
+
+ LDKWatch ret = {
+ .this_arg = (void*) calls,
+ .watch_channel = watch_channel_LDKWatch_jcall,
+ .update_channel = update_channel_LDKWatch_jcall,
+ .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
+ .free = LDKWatch_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
+ *res_ptr = LDKWatch_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
+ funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+ LDKChannelMonitor monitor_conv;
+ monitor_conv.inner = (void*)(monitor & (~1));
+ monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
+ monitor_conv = ChannelMonitor_clone(&monitor_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
+ funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+ LDKChannelMonitorUpdate update_conv;
+ update_conv.inner = (void*)(update & (~1));
+ update_conv.is_owned = (update & 1) || (update == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
+ update_conv = ChannelMonitorUpdate_clone(&update_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t o = 0; o < ret_var.datalen; o++) {
+ LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+ *ret_conv_14_copy = ret_var.data[o];
+ int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
+ ret_arr_ptr[o] = ret_conv_14_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKBroadcasterInterface_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID broadcast_transaction_meth;
+} LDKBroadcasterInterface_JCalls;
+static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKTransaction tx_var = tx;
+ int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
+ (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
+ Transaction_free(tx_var);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
+ CHECK(calls->broadcast_transaction_meth != NULL);
+
+ LDKBroadcasterInterface ret = {
+ .this_arg = (void*) calls,
+ .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
+ .free = LDKBroadcasterInterface_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
+ *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
+ LDKTransaction tx_ref;
+ tx_ref.datalen = (*env)->GetArrayLength(env, tx);
+ tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
+ tx_ref.data_is_owned = true;
+ (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
+}
+
+typedef struct LDKKeysInterface_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_node_secret_meth;
+ jmethodID get_destination_script_meth;
+ jmethodID get_shutdown_scriptpubkey_meth;
+ jmethodID get_channel_signer_meth;
+ jmethodID get_secure_random_bytes_meth;
+ jmethodID read_chan_signer_meth;
+ jmethodID sign_invoice_meth;
+ jmethodID get_inbound_payment_key_material_meth;
+} LDKKeysInterface_JCalls;
+static void LDKKeysInterface_JCalls_free(void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jclass recipient_conv = LDKRecipient_to_java(env, recipient);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
+ }
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = (*env)->GetArrayLength(env, ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
+ }
+ LDKShutdownScript ret_conv;
+ ret_conv.inner = (void*)(ret & (~1));
+ ret_conv.is_owned = (ret & 1) || (ret == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKSign ret_conv = *(LDKSign*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
+ }
+ LDKThirtyTwoBytes ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 32);
+ (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKu8slice reader_var = reader;
+ int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
+ (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKu8slice hrp_bytes_var = hrp_bytes;
+ int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
+ (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
+ LDKCVec_u5Z invoice_data_var = invoice_data;
+ jobjectArray invoice_data_arr = NULL;
+ invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
+ int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
+ for (size_t h = 0; h < invoice_data_var.datalen; h++) {
+ uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
+ invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
+ FREE(invoice_data_var.data);
+ jclass receipient_conv = LDKRecipient_to_java(env, receipient);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
+ }
+ LDKThirtyTwoBytes ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 32);
+ (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
+ CHECK(calls->get_node_secret_meth != NULL);
+ calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
+ CHECK(calls->get_destination_script_meth != NULL);
+ calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
+ CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
+ calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
+ CHECK(calls->get_channel_signer_meth != NULL);
+ calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
+ CHECK(calls->get_secure_random_bytes_meth != NULL);
+ calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
+ CHECK(calls->read_chan_signer_meth != NULL);
+ calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
+ CHECK(calls->sign_invoice_meth != NULL);
+ calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
+ CHECK(calls->get_inbound_payment_key_material_meth != NULL);
+
+ LDKKeysInterface ret = {
+ .this_arg = (void*) calls,
+ .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
+ .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
+ .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
+ .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
+ .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
+ .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
+ .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
+ .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
+ .free = LDKKeysInterface_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+ *res_ptr = LDKKeysInterface_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
+ LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
+ *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
+ *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
+ return (int64_t)ret_ret;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
+ return ret_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKu8slice reader_ref;
+ reader_ref.datalen = (*env)->GetArrayLength(env, reader);
+ reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
+ LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
+ *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
+ (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray hrp_bytes, jobjectArray invoice_data, jclass receipient) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKu8slice hrp_bytes_ref;
+ hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
+ hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
+ LDKCVec_u5Z invoice_data_constr;
+ invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
+ if (invoice_data_constr.datalen > 0)
+ invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
+ else
+ invoice_data_constr.data = NULL;
+ int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
+ for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
+ int8_t invoice_data_conv_7 = invoice_data_vals[h];
+
+ invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
+ }
+ (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
+ LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
+ LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
+ (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
+ return ret_arr;
+}
+
+typedef struct LDKFeeEstimator_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_est_sat_per_1000_weight_meth;
+} LDKFeeEstimator_JCalls;
+static void LDKFeeEstimator_JCalls_free(void* this_arg) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
+ CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
+
+ LDKFeeEstimator ret = {
+ .this_arg = (void*) calls,
+ .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
+ .free = LDKFeeEstimator_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
+ *res_ptr = LDKFeeEstimator_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_arg, jclass confirmation_target) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
+ LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
+ int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
+ return ret_val;
+}
+
+typedef struct LDKLogger_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID log_meth;
+} LDKLogger_JCalls;
+static void LDKLogger_JCalls_free(void* this_arg) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKRecord record_var = *record;
+ int64_t record_ref = 0;
+ record_var = Record_clone(&record_var);
+ CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
+ record_ref = (uintptr_t)record_var.inner;
+ if (record_var.is_owned) {
+ record_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
+ CHECK(calls->log_meth != NULL);
+
+ LDKLogger ret = {
+ .this_arg = (void*) calls,
+ .log = log_LDKLogger_jcall,
+ .free = LDKLogger_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
+ *res_ptr = LDKLogger_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
+ return &owner->b;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
+ LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
+ int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
+ return ret_ret;
+}
+
+static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelConfig_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
+ LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return OutPoint_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
+ LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+typedef struct LDKType_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID type_id_meth;
+ jmethodID debug_str_meth;
+ jmethodID write_meth;
+} LDKType_JCalls;
+static void LDKType_JCalls_free(void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+uint16_t type_id_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+LDKStr debug_str_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
+ }
+ LDKStr ret_conv = java_to_owned_str(env, ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
+ }
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = (*env)->GetArrayLength(env, ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+static void LDKType_JCalls_cloned(LDKType* new_obj) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
+ CHECK(calls->type_id_meth != NULL);
+ calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
+ CHECK(calls->debug_str_meth != NULL);
+ calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
+ CHECK(calls->write_meth != NULL);
+
+ LDKType ret = {
+ .this_arg = (void*) calls,
+ .type_id = type_id_LDKType_jcall,
+ .debug_str = debug_str_LDKType_jcall,
+ .write = write_LDKType_jcall,
+ .cloned = LDKType_JCalls_cloned,
+ .free = LDKType_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
+ *res_ptr = LDKType_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
+ return ret_val;
+}
+
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
+ jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+ Str_free(ret_str);
+ return ret_conv;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static jclass LDKCOption_TypeZ_Some_class = NULL;
+static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
+static jclass LDKCOption_TypeZ_None_class = NULL;
+static jmethodID LDKCOption_TypeZ_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
+ LDKCOption_TypeZ_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
+ CHECK(LDKCOption_TypeZ_Some_class != NULL);
+ LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
+ CHECK(LDKCOption_TypeZ_Some_meth != NULL);
+ LDKCOption_TypeZ_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
+ CHECK(LDKCOption_TypeZ_None_class != NULL);
+ LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
+ CHECK(LDKCOption_TypeZ_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_TypeZ_Some: {
+ LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *some_ret = Type_clone(&obj->some);
+ return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
+ }
+ case LDKCOption_TypeZ_None: {
+ return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return COption_TypeZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
+ LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
+ *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static jclass LDKPaymentError_Invoice_class = NULL;
+static jmethodID LDKPaymentError_Invoice_meth = NULL;
+static jclass LDKPaymentError_Routing_class = NULL;
+static jmethodID LDKPaymentError_Routing_meth = NULL;
+static jclass LDKPaymentError_Sending_class = NULL;
+static jmethodID LDKPaymentError_Sending_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
+ LDKPaymentError_Invoice_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
+ CHECK(LDKPaymentError_Invoice_class != NULL);
+ LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
+ CHECK(LDKPaymentError_Invoice_meth != NULL);
+ LDKPaymentError_Routing_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
+ CHECK(LDKPaymentError_Routing_class != NULL);
+ LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
+ CHECK(LDKPaymentError_Routing_meth != NULL);
+ LDKPaymentError_Sending_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
+ CHECK(LDKPaymentError_Sending_class != NULL);
+ LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
+ CHECK(LDKPaymentError_Sending_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentError_Invoice: {
+ LDKStr invoice_str = obj->invoice;
+ jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
+ return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
+ }
+ case LDKPaymentError_Routing: {
+ LDKLightningError routing_var = obj->routing;
+ int64_t routing_ref = 0;
+ CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
+ routing_ref = (uintptr_t)routing_var.inner & ~1;
+ return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
+ }
+ case LDKPaymentError_Sending: {
+ int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
+ return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ThirtyTwoBytes_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PaymentError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
+ LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+ *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return SiPrefix_clone(&*owner->contents.result);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
+ jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixNoneZ_get_ok(owner_conv));
+ return ret_conv;
+}
+
+static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
+ CResult_SiPrefixNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Invoice_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
+ LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
+ CResult_InvoiceNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return SignedRawInvoice_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
+ LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
+ CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
+}
+
+static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
+ return RawInvoice_clone(&owner->a);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
+ LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->b);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
+ return InvoiceSignature_clone(&owner->c);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
+ LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return PayeePubKey_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
+ LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
+ LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = PrivateRoute_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return PositiveTimestamp_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
+ LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return CreationError_clone(&*owner->contents.err);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
+ CResult_NoneSemanticErrorZ_get_ok(owner_conv);
+}
+
+static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return SemanticError_clone(&*owner->contents.err);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Invoice_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
+ LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return SemanticError_clone(&*owner->contents.err);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Description_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
+ LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return CreationError_clone(&*owner->contents.err);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return PrivateRoute_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
+ LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return CreationError_clone(&*owner->contents.err);
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
+ LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
+ jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+ return ret_conv;
+}
+
+static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
+ jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
+ return ret_conv;
+}
+
+static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelMonitorUpdate_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
+ LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
+static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
+static jclass LDKCOption_MonitorEventZ_None_class = NULL;
+static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
+ LDKCOption_MonitorEventZ_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
+ CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
+ LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
+ CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
+ LDKCOption_MonitorEventZ_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
+ CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
+ LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
+ CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_MonitorEventZ_Some: {
+ int64_t some_ref = ((uintptr_t)&obj->some) | 1;
+ return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
+ }
+ case LDKCOption_MonitorEventZ_None: {
+ return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return COption_MonitorEventZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
+ LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
+ *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return HTLCUpdate_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
+ LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
+ return OutPoint_clone(&owner->a);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
+ LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
+ return CVec_u8Z_clone(&owner->b);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
+ return owner->a;
+}
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
+ int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
+ return CVec_u8Z_clone(&owner->b);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
+ LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
+ return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
+ LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t v = 0; v < ret_var.datalen; v++) {
+ LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
+ *ret_conv_21_conv = ret_var.data[v];
+ ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
+ LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Event_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
+ return owner->a;
+}
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
+ int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
+ return TxOut_clone(&owner->b);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
+ LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+ *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
+ return (int64_t)ret_ref;
+}
+
+static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
+ LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
+ return ThirtyTwoBytes_clone(&owner->a);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
+ return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
+ LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t u = 0; u < ret_var.datalen; u++) {
+ LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
+ *ret_conv_20_conv = ret_var.data[u];
+ ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
+static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
+static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
+static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
+static jclass LDKBalance_ContentiousClaimable_class = NULL;
+static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
+static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
+static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
+ LDKBalance_ClaimableOnChannelClose_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
+ CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
+ LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
+ CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
+ LDKBalance_ClaimableAwaitingConfirmations_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
+ CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
+ LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
+ CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
+ LDKBalance_ContentiousClaimable_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
+ CHECK(LDKBalance_ContentiousClaimable_class != NULL);
+ LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
+ CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
+ LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
+ CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
+ LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
+ CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKBalance *obj = (LDKBalance*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKBalance_ClaimableOnChannelClose: {
+ return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
+ }
+ case LDKBalance_ClaimableAwaitingConfirmations: {
+ return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
+ }
+ case LDKBalance_ContentiousClaimable: {
+ return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
+ }
+ case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
+ return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
+ }
+ default: abort();
+ }
+}
+static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
+ LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Balance_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
+ LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
+ return ((int64_t)ret_conv);
+}
+
+static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
+ CResult_NoneLightningErrorZ_get_ok(owner_conv);
+}
+
+static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return LightningError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
+ LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
+ return owner->a;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
+ return ret_arr;
+}
+
+static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
+ return Type_clone(&owner->b);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
+ LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
+ return (int64_t)ret_ret;
+}
+
+static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
+ LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
+ jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return LightningError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
+ LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
+ return ChannelAnnouncement_clone(&owner->a);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
+ LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
+ return ChannelUpdate_clone(&owner->b);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
+ LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
+ return ChannelUpdate_clone(&owner->c);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
+ LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
+ LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CVec_u8Z_clone(&*owner->contents.result);
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
+ LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PeerHandleError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
+ LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
+ CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
+}
+
+static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PeerHandleError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
+ LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return *owner->contents.result;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
+ jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
+ return ret_val;
+}
+
+static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return PeerHandleError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
+ LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NodeId_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
+ LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return COption_NetworkUpdateZ_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
+ LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
+ *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+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_LDKAccess_jcall,
+ .free = LDKAccess_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
+ 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 (int64_t)ret_conv;
+}
+
+static jclass LDKCOption_AccessZ_Some_class = NULL;
+static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
+static jclass LDKCOption_AccessZ_None_class = NULL;
+static jmethodID LDKCOption_AccessZ_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
+ LDKCOption_AccessZ_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
+ CHECK(LDKCOption_AccessZ_Some_class != NULL);
+ LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
+ CHECK(LDKCOption_AccessZ_Some_meth != NULL);
+ LDKCOption_AccessZ_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
+ CHECK(LDKCOption_AccessZ_None_class != NULL);
+ LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
+ CHECK(LDKCOption_AccessZ_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_AccessZ_Some: {
+ LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
+ *some_ret = obj->some;
+ // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
+ if ((*some_ret).free == LDKAccess_JCalls_free) {
+ // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+ LDKAccess_JCalls_cloned(&(*some_ret));
+ }
+ return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
+ }
+ case LDKCOption_AccessZ_None: {
+ return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelUpdateInfo_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
+ LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelInfo_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
+ LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RoutingFees_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
+ LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NodeAnnouncementInfo_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
+ LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
+ LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
+ memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
+ return ret;
+}
+static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NodeInfo_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
+ LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NetworkGraph_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
+ LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
+static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
+static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
+static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
+ LDKCOption_CVec_NetAddressZZ_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
+ CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
+ LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
+ CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
+ LDKCOption_CVec_NetAddressZZ_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
+ CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
+ LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
+ CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_CVec_NetAddressZZ_Some: {
+ LDKCVec_NetAddressZ some_var = obj->some;
+ int64_tArray some_arr = NULL;
+ some_arr = (*env)->NewLongArray(env, some_var.datalen);
+ int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
+ for (size_t m = 0; m < some_var.datalen; m++) {
+ int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
+ some_arr_ptr[m] = some_conv_12_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
+ return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
+ }
+ case LDKCOption_CVec_NetAddressZZ_None: {
+ return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NetAddress_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
+ LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
+ *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
+ LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
+ LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
+ LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
+ LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return AcceptChannel_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
+ LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return AnnouncementSignatures_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
+ LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelReestablish_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
+ LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ClosingSigned_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
+ LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ClosingSignedFeeRange_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
+ LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return CommitmentSigned_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
+ LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return FundingCreated_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
+ LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return FundingSigned_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
+ LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return FundingLocked_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
+ LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Init_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
+ LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return OpenChannel_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
+ LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return RevokeAndACK_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
+ LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Shutdown_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
+ LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UpdateFailHTLC_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
+ LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
+ LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UpdateFee_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
+ LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UpdateFulfillHTLC_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
+ LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UpdateAddHTLC_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
+ LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Ping_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
+ LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Pong_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
+ LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelAnnouncement_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UnsignedChannelUpdate_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
+ LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ChannelUpdate_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
+ LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ErrorMessage_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
+ LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return WarningMessage_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
+ LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return NodeAnnouncement_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return QueryShortChannelIds_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
+ LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
+ LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return QueryChannelRange_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
+ LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return ReplyChannelRange_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
+ LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return GossipTimestampFilter_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
+ LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return DecodeError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
+ LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
+ LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static jclass LDKSignOrCreationError_SignError_class = NULL;
+static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
+static jclass LDKSignOrCreationError_CreationError_class = NULL;
+static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
+ LDKSignOrCreationError_SignError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
+ CHECK(LDKSignOrCreationError_SignError_class != NULL);
+ LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
+ CHECK(LDKSignOrCreationError_SignError_meth != NULL);
+ LDKSignOrCreationError_CreationError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
+ CHECK(LDKSignOrCreationError_CreationError_class != NULL);
+ LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
+ CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKSignOrCreationError_SignError: {
+ return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
+ }
+ case LDKSignOrCreationError_CreationError: {
+ jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
+ return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return Invoice_clone(&*owner->contents.result);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
+ LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return SignOrCreationError_clone(&*owner->contents.err);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
+ LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
+ *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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);
+ (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKWatchedOutput output_var = output;
+ int64_t output_ref = 0;
+ CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
+ output_ref = (uintptr_t)output_var.inner;
+ if (output_var.is_owned) {
+ output_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+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)J");
+ CHECK(calls->register_output_meth != NULL);
+
+ LDKFilter ret = {
+ .this_arg = (void*) calls,
+ .register_tx = register_tx_LDKFilter_jcall,
+ .register_output = register_output_LDKFilter_jcall,
+ .free = LDKFilter_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
+ 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 int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
+ LDKWatchedOutput output_conv;
+ output_conv.inner = (void*)(output & (~1));
+ output_conv.is_owned = (output & 1) || (output == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
+ output_conv = WatchedOutput_clone(&output_conv);
+ LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
+ *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
+ int64_t ret_ref = (uintptr_t)ret_copy;
+ return ret_ref;
+}
+
+static jclass LDKCOption_FilterZ_Some_class = NULL;
+static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
+static jclass LDKCOption_FilterZ_None_class = NULL;
+static jmethodID LDKCOption_FilterZ_None_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
+ LDKCOption_FilterZ_Some_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
+ CHECK(LDKCOption_FilterZ_Some_class != NULL);
+ LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
+ CHECK(LDKCOption_FilterZ_Some_meth != NULL);
+ LDKCOption_FilterZ_None_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
+ CHECK(LDKCOption_FilterZ_None_class != NULL);
+ LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
+ CHECK(LDKCOption_FilterZ_None_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_FilterZ_Some: {
+ LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
+ *some_ret = obj->some;
+ // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
+ if ((*some_ret).free == LDKFilter_JCalls_free) {
+ // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+ LDKFilter_JCalls_cloned(&(*some_ret));
+ }
+ return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
+ }
+ case LDKCOption_FilterZ_None: {
+ return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
+ }
+ default: abort();
+ }
+}
+static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
+CHECK(owner->result_ok);
+ return &*owner->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
+ LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
+ int64_t ret_ref = 0;
+ CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
+ ret_ref = (uintptr_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
+CHECK(!owner->result_ok);
+ return *owner->contents.err;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
+ LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
+ CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
+}
+
+static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
+ LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = OutPoint_clone(&orig->data[i]);
+ }
+ return ret;
+}
+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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
+ LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
+ }
+ LDKCVec_MessageSendEventZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t s = 0; s < ret_constr.datalen; s++) {
+ int64_t ret_conv_18 = ret_vals[s];
+ void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
+ CHECK_ACCESS(ret_conv_18_ptr);
+ LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
+ FREE((void*)ret_conv_18);
+ ret_constr.data[s] = ret_conv_18_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
+ LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+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_LDKMessageSendEventsProvider_jcall,
+ .free = LDKMessageSendEventsProvider_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
+ LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = NULL;
+ 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 *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
+ *ret_conv_18_copy = ret_var.data[s];
+ int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
+ ret_arr_ptr[s] = ret_conv_18_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKEventHandler_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID handle_event_meth;
+} LDKEventHandler_JCalls;
+static void LDKEventHandler_JCalls_free(void* this_arg) {
+ LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
+ LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
+ *ret_event = Event_clone(event);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
+ LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
+ CHECK(calls->handle_event_meth != NULL);
+
+ LDKEventHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_event = handle_event_LDKEventHandler_jcall,
+ .free = LDKEventHandler_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+ *res_ptr = LDKEventHandler_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
+ LDKEvent* event_conv = (LDKEvent*)event;
+ (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
+}
+
+typedef struct LDKEventsProvider_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID process_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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
+ LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+ *handler_ret = handler;
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
+ LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+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->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
+ CHECK(calls->process_pending_events_meth != NULL);
+
+ LDKEventsProvider ret = {
+ .this_arg = (void*) calls,
+ .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
+ .free = LDKEventsProvider_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
+ void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
+ CHECK_ACCESS(handler_ptr);
+ LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
+ if (handler_conv.free == LDKEventHandler_JCalls_free) {
+ // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+ LDKEventHandler_JCalls_cloned(&handler_conv);
+ }
+ (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
+}
+
+typedef struct LDKListen_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID block_connected_meth;
+ jmethodID block_disconnected_meth;
+} LDKListen_JCalls;
+static void LDKListen_JCalls_free(void* this_arg) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKu8slice block_var = block;
+ int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
+ (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray header_arr = (*env)->NewByteArray(env, 80);
+ (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
+ CHECK(calls->block_connected_meth != NULL);
+ calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
+ CHECK(calls->block_disconnected_meth != NULL);
+
+ LDKListen ret = {
+ .this_arg = (void*) calls,
+ .block_connected = block_connected_LDKListen_jcall,
+ .block_disconnected = block_disconnected_LDKListen_jcall,
+ .free = LDKListen_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
+ *res_ptr = LDKListen_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
+ LDKu8slice block_ref;
+ block_ref.datalen = (*env)->GetArrayLength(env, block);
+ block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
+ (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
+ (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
+ unsigned char header_arr[80];
+ CHECK((*env)->GetArrayLength(env, header) == 80);
+ (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
+ unsigned char (*header_ref)[80] = &header_arr;
+ (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
+}
+
+typedef struct LDKConfirm_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID transactions_confirmed_meth;
+ jmethodID transaction_unconfirmed_meth;
+ jmethodID best_block_updated_meth;
+ jmethodID get_relevant_txids_meth;
+} LDKConfirm_JCalls;
+static void LDKConfirm_JCalls_free(void* this_arg) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray header_arr = (*env)->NewByteArray(env, 80);
+ (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
+ LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
+ int64_tArray txdata_arr = NULL;
+ txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
+ int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
+ for (size_t c = 0; c < txdata_var.datalen; c++) {
+ LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
+ *txdata_conv_28_conv = txdata_var.data[c];
+ txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
+ FREE(txdata_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray header_arr = (*env)->NewByteArray(env, 80);
+ (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
+ }
+ LDKCVec_TxidZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
+ else
+ ret_constr.data = NULL;
+ for (size_t i = 0; i < ret_constr.datalen; i++) {
+ int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
+ LDKThirtyTwoBytes ret_conv_8_ref;
+ CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
+ (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
+ ret_constr.data[i] = ret_conv_8_ref;
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
+ CHECK(calls->transactions_confirmed_meth != NULL);
+ calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
+ CHECK(calls->transaction_unconfirmed_meth != NULL);
+ calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
+ CHECK(calls->best_block_updated_meth != NULL);
+ calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
+ CHECK(calls->get_relevant_txids_meth != NULL);
+
+ LDKConfirm ret = {
+ .this_arg = (void*) calls,
+ .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
+ .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
+ .best_block_updated = best_block_updated_LDKConfirm_jcall,
+ .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
+ .free = LDKConfirm_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+ *res_ptr = LDKConfirm_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
+ unsigned char header_arr[80];
+ CHECK((*env)->GetArrayLength(env, header) == 80);
+ (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
+ unsigned char (*header_ref)[80] = &header_arr;
+ LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
+ txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
+ if (txdata_constr.datalen > 0)
+ txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
+ else
+ txdata_constr.data = NULL;
+ int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
+ for (size_t c = 0; c < txdata_constr.datalen; c++) {
+ int64_t txdata_conv_28 = txdata_vals[c];
+ void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
+ CHECK_ACCESS(txdata_conv_28_ptr);
+ LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
+ txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
+ txdata_constr.data[c] = txdata_conv_28_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
+ (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
+ 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;
+ (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
+ unsigned char header_arr[80];
+ CHECK((*env)->GetArrayLength(env, header) == 80);
+ (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
+ unsigned char (*header_ref)[80] = &header_arr;
+ (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
+}
+
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
+ LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
+ jobjectArray ret_arr = NULL;
+ ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+ ;
+ for (size_t i = 0; i < ret_var.datalen; i++) {
+ int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
+ (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKOutPoint channel_id_var = channel_id;
+ int64_t channel_id_ref = 0;
+ CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
+ channel_id_ref = (uintptr_t)channel_id_var.inner;
+ if (channel_id_var.is_owned) {
+ channel_id_ref |= 1;
+ }
+ LDKChannelMonitor data_var = *data;
+ int64_t data_ref = 0;
+ data_var = ChannelMonitor_clone(&data_var);
+ CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
+ data_ref = (uintptr_t)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ LDKMonitorUpdateId update_id_var = update_id;
+ int64_t update_id_ref = 0;
+ CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
+ update_id_ref = (uintptr_t)update_id_var.inner;
+ if (update_id_var.is_owned) {
+ update_id_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKOutPoint channel_id_var = channel_id;
+ int64_t channel_id_ref = 0;
+ CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
+ channel_id_ref = (uintptr_t)channel_id_var.inner;
+ if (channel_id_var.is_owned) {
+ channel_id_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = *update;
+ int64_t update_ref = 0;
+ if ((uintptr_t)update_var.inner > 4096) {
+ update_var = ChannelMonitorUpdate_clone(&update_var);
+ CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
+ update_ref = (uintptr_t)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ }
+ LDKChannelMonitor data_var = *data;
+ int64_t data_ref = 0;
+ data_var = ChannelMonitor_clone(&data_var);
+ CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
+ data_ref = (uintptr_t)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ LDKMonitorUpdateId update_id_var = update_id;
+ int64_t update_id_ref = 0;
+ CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
+ update_id_ref = (uintptr_t)update_id_var.inner;
+ if (update_id_var.is_owned) {
+ update_id_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+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", "(JJJ)J");
+ CHECK(calls->persist_new_channel_meth != NULL);
+ calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
+ CHECK(calls->update_persisted_channel_meth != NULL);
+
+ LDKPersist ret = {
+ .this_arg = (void*) calls,
+ .persist_new_channel = persist_new_channel_LDKPersist_jcall,
+ .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
+ .free = LDKPersist_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)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 channel_id, int64_t data, int64_t update_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+ LDKOutPoint channel_id_conv;
+ channel_id_conv.inner = (void*)(channel_id & (~1));
+ channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
+ channel_id_conv = OutPoint_clone(&channel_id_conv);
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
+ LDKMonitorUpdateId update_id_conv;
+ update_id_conv.inner = (void*)(update_id & (~1));
+ update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
+ update_id_conv = MonitorUpdateId_clone(&update_id_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
+ return (int64_t)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 channel_id, int64_t update, int64_t data, int64_t update_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+ LDKOutPoint channel_id_conv;
+ channel_id_conv.inner = (void*)(channel_id & (~1));
+ channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
+ channel_id_conv = OutPoint_clone(&channel_id_conv);
+ LDKChannelMonitorUpdate update_conv;
+ update_conv.inner = (void*)(update & (~1));
+ update_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
+ LDKMonitorUpdateId update_id_conv;
+ update_id_conv.inner = (void*)(update_id & (~1));
+ update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
+ update_id_conv = MonitorUpdateId_clone(&update_id_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
+ return (int64_t)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_channel_update_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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+void handle_open_channel_LDKChannelMessageHandler_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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t their_features_ref = 0;
+ CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
+ their_features_ref = (uintptr_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKOpenChannel msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = OpenChannel_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_accept_channel_LDKChannelMessageHandler_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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t their_features_ref = 0;
+ CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
+ their_features_ref = (uintptr_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKAcceptChannel msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = AcceptChannel_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = FundingCreated_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = FundingSigned_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = FundingLocked_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t their_features_ref = 0;
+ their_features_var = InitFeatures_clone(&their_features_var);
+ CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
+ their_features_ref = (uintptr_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKShutdown msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = Shutdown_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = ClosingSigned_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = UpdateAddHTLC_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = UpdateFulfillHTLC_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = UpdateFailHTLC_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = CommitmentSigned_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = RevokeAndACK_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = UpdateFee_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = AnnouncementSignatures_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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);
+ (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = Init_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = ChannelReestablish_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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);
+ LDKChannelUpdate msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = ChannelUpdate_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ msg_var = ErrorMessage_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->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);
+}
+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", "([BJJ)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_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
+ CHECK(calls->handle_channel_update_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_LDKChannelMessageHandler_jcall,
+ .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
+ .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
+ .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
+ .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
+ .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
+ .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
+ .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
+ .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
+ .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
+ .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
+ .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
+ .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
+ .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
+ .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
+ .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
+ .handle_error = handle_error_LDKChannelMessageHandler_jcall,
+ .free = LDKChannelMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;
+}
+JNIEXPORT int64_t 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 (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
+ uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
+ DO_ASSERT((res_ptr & 1) == 0);
+ return (int64_t)(res_ptr | 1);
+}
+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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
+ their_features_conv = InitFeatures_clone(&their_features_conv);
+ LDKOpenChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
+ their_features_conv = InitFeatures_clone(&their_features_conv);
+ LDKAcceptChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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 their_features, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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 = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
+ LDKShutdown msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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);
+ LDKChannelUpdate msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (this_arg_conv->handle_channel_update)(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) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
+ 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;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ (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 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;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKNodeAnnouncement msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = NodeAnnouncement_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKChannelAnnouncement msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = ChannelAnnouncement_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKChannelUpdate msg_var = *msg;
+ int64_t msg_ref = 0;
+ msg_var = ChannelUpdate_clone(&msg_var);
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t h = 0; h < ret_constr.datalen; h++) {
+ int64_t ret_conv_59 = ret_vals[h];
+ void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
+ CHECK_ACCESS(ret_conv_59_ptr);
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
+ FREE((void*)ret_conv_59);
+ ret_constr.data[h] = ret_conv_59_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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 ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ LDKCVec_NodeAnnouncementZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t s = 0; s < ret_constr.datalen; s++) {
+ int64_t ret_conv_18 = ret_vals[s];
+ LDKNodeAnnouncement ret_conv_18_conv;
+ ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
+ ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
+ ret_constr.data[s] = ret_conv_18_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t init_ref = 0;
+ init_var = Init_clone(&init_var);
+ CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
+ init_ref = (uintptr_t)init_var.inner;
+ if (init_var.is_owned) {
+ init_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == 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;
+ int64_t msg_ref = 0;
+ CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uintptr_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->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);
+}
+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->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_LDKRoutingMessageHandler_jcall,
+ .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
+ .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
+ .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
+ .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
+ .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
+ .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
+ .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
+ .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
+ .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
+ .free = LDKRoutingMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
+ LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+ *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
+ uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
+ DO_ASSERT((res_ptr & 1) == 0);
+ return (int64_t)(res_ptr | 1);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ LDKNodeAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ LDKChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ LDKChannelUpdate msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
+ int64_tArray ret_arr = NULL;
+ 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++) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
+ *ret_conv_59_conv = ret_var.data[h];
+ ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ LDKPublicKey starting_point_ref;
+ CHECK((*env)->GetArrayLength(env, starting_point) == 33);
+ (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
+ LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
+ int64_tArray ret_arr = NULL;
+ 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++) {
+ LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
+ int64_t ret_conv_18_ref = 0;
+ CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
+ ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
+ if (ret_conv_18_var.is_owned) {
+ ret_conv_18_ref |= 1;
+ }
+ ret_arr_ptr[s] = ret_conv_18_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ 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 init_conv;
+ init_conv.inner = (void*)(init & (~1));
+ init_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
+ (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ 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);
+ LDKReplyChannelRange msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ msg_conv = ReplyChannelRange_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ 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);
+ LDKReplyShortChannelIdsEnd msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ 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);
+ LDKQueryChannelRange msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ msg_conv = QueryChannelRange_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
+ 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);
+ LDKQueryShortChannelIds msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
+ msg_conv = QueryShortChannelIds_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (int64_t)ret_conv;
+}
+
+typedef struct LDKCustomMessageReader_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID read_meth;
+} LDKCustomMessageReader_JCalls;
+static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
+ LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
+ LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKu8slice buffer_var = buffer;
+ int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
+ (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
+ LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
+ CHECK(calls->read_meth != NULL);
+
+ LDKCustomMessageReader ret = {
+ .this_arg = (void*) calls,
+ .read = read_LDKCustomMessageReader_jcall,
+ .free = LDKCustomMessageReader_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
+ *res_ptr = LDKCustomMessageReader_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
+ LDKu8slice buffer_ref;
+ buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
+ buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
+ LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
+ *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
+ (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
+ return (int64_t)ret_conv;
+}
+
+typedef struct LDKCustomMessageHandler_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ LDKCustomMessageReader_JCalls* CustomMessageReader;
+ jmethodID handle_custom_message_meth;
+ jmethodID get_and_clear_pending_msg_meth;
+} LDKCustomMessageHandler_JCalls;
+static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
+ LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
+ LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *msg_ret = msg;
+ int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
+ LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
+ }
+ LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t z = 0; z < ret_constr.datalen; z++) {
+ int64_t ret_conv_25 = ret_vals[z];
+ void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
+ CHECK_ACCESS(ret_conv_25_ptr);
+ LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
+ FREE((void*)ret_conv_25);
+ ret_constr.data[z] = ret_conv_25_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
+ LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
+}
+static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
+ CHECK(calls->handle_custom_message_meth != NULL);
+ calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
+ CHECK(calls->get_and_clear_pending_msg_meth != NULL);
+
+ LDKCustomMessageHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
+ .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
+ .free = LDKCustomMessageHandler_JCalls_free,
+ .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
+ };
+ calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
+ LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
+ *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
+ uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
+ DO_ASSERT((res_ptr & 1) == 0);
+ return (int64_t)(res_ptr | 1);
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+ void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
+ CHECK_ACCESS(msg_ptr);
+ LDKType msg_conv = *(LDKType*)(msg_ptr);
+ if (msg_conv.free == LDKType_JCalls_free) {
+ // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+ LDKType_JCalls_cloned(&msg_conv);
+ }
+ LDKPublicKey sender_node_id_ref;
+ CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
+ (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+ LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t z = 0; z < ret_var.datalen; z++) {
+ LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
+ *ret_conv_25_conv = ret_var.data[z];
+ ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKSocketDescriptor_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID send_data_meth;
+ jmethodID disconnect_socket_meth;
+ jmethodID eq_meth;
+ jmethodID hash_meth;
+} LDKSocketDescriptor_JCalls;
+static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKu8slice data_var = data;
+ int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
+ (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+ *other_arg_clone = SocketDescriptor_clone(other_arg);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
+ CHECK(calls->send_data_meth != NULL);
+ calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
+ CHECK(calls->disconnect_socket_meth != NULL);
+ calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
+ CHECK(calls->eq_meth != NULL);
+ calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
+ CHECK(calls->hash_meth != NULL);
+
+ LDKSocketDescriptor ret = {
+ .this_arg = (void*) calls,
+ .send_data = send_data_LDKSocketDescriptor_jcall,
+ .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
+ .eq = eq_LDKSocketDescriptor_jcall,
+ .hash = hash_LDKSocketDescriptor_jcall,
+ .cloned = LDKSocketDescriptor_JCalls_cloned,
+ .free = LDKSocketDescriptor_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+ *res_ptr = LDKSocketDescriptor_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
+ LDKu8slice data_ref;
+ data_ref.datalen = (*env)->GetArrayLength(env, data);
+ data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
+ int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
+ (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
+ return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
+ (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
+ int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
+ return ret_val;
+}
+
+static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
+static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
+static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
+static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
+static jclass LDKEffectiveCapacity_Total_class = NULL;
+static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
+static jclass LDKEffectiveCapacity_Infinite_class = NULL;
+static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
+static jclass LDKEffectiveCapacity_Unknown_class = NULL;
+static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
+ LDKEffectiveCapacity_ExactLiquidity_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
+ CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
+ LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
+ CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
+ LDKEffectiveCapacity_MaximumHTLC_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
+ CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
+ LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
+ CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
+ LDKEffectiveCapacity_Total_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
+ CHECK(LDKEffectiveCapacity_Total_class != NULL);
+ LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
+ CHECK(LDKEffectiveCapacity_Total_meth != NULL);
+ LDKEffectiveCapacity_Infinite_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
+ CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
+ LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
+ CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
+ LDKEffectiveCapacity_Unknown_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
+ CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
+ LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
+ CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKEffectiveCapacity_ExactLiquidity: {
+ return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, obj->exact_liquidity.liquidity_msat);
+ }
+ case LDKEffectiveCapacity_MaximumHTLC: {
+ return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, obj->maximum_htlc.amount_msat);
+ }
+ case LDKEffectiveCapacity_Total: {
+ return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, obj->total.capacity_msat);
+ }
+ case LDKEffectiveCapacity_Infinite: {
+ return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
+ }
+ case LDKEffectiveCapacity_Unknown: {
+ return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
+ }
+ default: abort();
+ }
+}
+typedef struct LDKScore_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID channel_penalty_msat_meth;
+ jmethodID payment_path_failed_meth;
+ jmethodID payment_path_successful_meth;
+ jmethodID write_meth;
+} LDKScore_JCalls;
+static void LDKScore_JCalls_free(void* this_arg) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKNodeId source_var = *source;
+ int64_t source_ref = 0;
+ source_var = NodeId_clone(&source_var);
+ CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
+ source_ref = (uintptr_t)source_var.inner;
+ if (source_var.is_owned) {
+ source_ref |= 1;
+ }
+ LDKNodeId target_var = *target;
+ int64_t target_ref = 0;
+ target_var = NodeId_clone(&target_var);
+ CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
+ target_ref = (uintptr_t)target_var.inner;
+ if (target_var.is_owned) {
+ target_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, capacity_msat, source_ref, target_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret;
+}
+void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKCVec_RouteHopZ path_var = path;
+ int64_tArray path_arr = NULL;
+ path_arr = (*env)->NewLongArray(env, path_var.datalen);
+ int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
+ for (size_t k = 0; k < path_var.datalen; k++) {
+ LDKRouteHop path_conv_10_var = path_var.data[k];
+ int64_t path_conv_10_ref = 0;
+ CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
+ path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
+ if (path_conv_10_var.is_owned) {
+ path_conv_10_ref |= 1;
+ }
+ path_arr_ptr[k] = path_conv_10_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
+ FREE(path_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKCVec_RouteHopZ path_var = path;
+ int64_tArray path_arr = NULL;
+ path_arr = (*env)->NewLongArray(env, path_var.datalen);
+ int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
+ for (size_t k = 0; k < path_var.datalen; k++) {
+ LDKRouteHop path_conv_10_var = path_var.data[k];
+ int64_t path_conv_10_ref = 0;
+ CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
+ path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
+ if (path_conv_10_var.is_owned) {
+ path_conv_10_ref |= 1;
+ }
+ path_arr_ptr[k] = path_conv_10_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
+ FREE(path_var.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
+ }
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = (*env)->GetArrayLength(env, ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
+ LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
+ CHECK(calls->channel_penalty_msat_meth != NULL);
+ calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
+ CHECK(calls->payment_path_failed_meth != NULL);
+ calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
+ CHECK(calls->payment_path_successful_meth != NULL);
+ calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
+ CHECK(calls->write_meth != NULL);
+
+ LDKScore ret = {
+ .this_arg = (void*) calls,
+ .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
+ .payment_path_failed = payment_path_failed_LDKScore_jcall,
+ .payment_path_successful = payment_path_successful_LDKScore_jcall,
+ .write = write_LDKScore_jcall,
+ .free = LDKScore_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
+ *res_ptr = LDKScore_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+ LDKNodeId source_conv;
+ source_conv.inner = (void*)(source & (~1));
+ source_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
+ LDKNodeId target_conv;
+ target_conv.inner = (void*)(target & (~1));
+ target_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
+ int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
+ return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+ LDKCVec_RouteHopZ path_constr;
+ path_constr.datalen = (*env)->GetArrayLength(env, path);
+ if (path_constr.datalen > 0)
+ path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
+ else
+ path_constr.data = NULL;
+ int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
+ for (size_t k = 0; k < path_constr.datalen; k++) {
+ int64_t path_conv_10 = path_vals[k];
+ LDKRouteHop path_conv_10_conv;
+ path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
+ path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
+ path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
+ path_constr.data[k] = path_conv_10_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
+ (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+ LDKCVec_RouteHopZ path_constr;
+ path_constr.datalen = (*env)->GetArrayLength(env, path);
+ if (path_constr.datalen > 0)
+ path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
+ else
+ path_constr.data = NULL;
+ int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
+ for (size_t k = 0; k < path_constr.datalen; k++) {
+ int64_t path_conv_10 = path_vals[k];
+ LDKRouteHop path_conv_10_conv;
+ path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
+ path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
+ path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
+ path_constr.data[k] = path_conv_10_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
+ (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+typedef struct LDKLockableScore_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID lock_meth;
+} LDKLockableScore_JCalls;
+static void LDKLockableScore_JCalls_free(void* this_arg) {
+ LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
+ LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKScore ret_conv = *(LDKScore*)(ret_ptr);
+ if (ret_conv.free == LDKScore_JCalls_free) {
+ // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+ LDKScore_JCalls_cloned(&ret_conv);
+ }// WARNING: we may need a move here but no clone is available for LDKScore
+
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
+ LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
+ CHECK(calls->lock_meth != NULL);
+
+ LDKLockableScore ret = {
+ .this_arg = (void*) calls,
+ .lock = lock_LDKLockableScore_jcall,
+ .free = LDKLockableScore_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
+ *res_ptr = LDKLockableScore_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
+ LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
+ *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
+ return (int64_t)ret_ret;
+}
+
+typedef struct LDKChannelManagerPersister_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID persist_manager_meth;
+} LDKChannelManagerPersister_JCalls;
+static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKChannelManager channel_manager_var = *channel_manager;
+ int64_t channel_manager_ref = 0;
+ // WARNING: we may need a move here but no clone is available for LDKChannelManager
+ CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
+ channel_manager_ref = (uintptr_t)channel_manager_var.inner;
+ if (channel_manager_var.is_owned) {
+ channel_manager_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
+ CHECK(calls->persist_manager_meth != NULL);
+
+ LDKChannelManagerPersister ret = {
+ .this_arg = (void*) calls,
+ .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
+ .free = LDKChannelManagerPersister_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
+ *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
+ LDKChannelManager channel_manager_conv;
+ channel_manager_conv.inner = (void*)(channel_manager & (~1));
+ channel_manager_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
+ LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
+ *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
+ return (int64_t)ret_conv;
+}
+
+static jclass LDKFallback_SegWitProgram_class = NULL;
+static jmethodID LDKFallback_SegWitProgram_meth = NULL;
+static jclass LDKFallback_PubKeyHash_class = NULL;
+static jmethodID LDKFallback_PubKeyHash_meth = NULL;
+static jclass LDKFallback_ScriptHash_class = NULL;
+static jmethodID LDKFallback_ScriptHash_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
+ LDKFallback_SegWitProgram_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
+ CHECK(LDKFallback_SegWitProgram_class != NULL);
+ LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
+ CHECK(LDKFallback_SegWitProgram_meth != NULL);
+ LDKFallback_PubKeyHash_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
+ CHECK(LDKFallback_PubKeyHash_class != NULL);
+ LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
+ CHECK(LDKFallback_PubKeyHash_meth != NULL);
+ LDKFallback_ScriptHash_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
+ CHECK(LDKFallback_ScriptHash_class != NULL);
+ LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
+ CHECK(LDKFallback_ScriptHash_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKFallback *obj = (LDKFallback*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKFallback_SegWitProgram: {
+ uint8_t version_val = obj->seg_wit_program.version._0;
+ LDKCVec_u8Z program_var = obj->seg_wit_program.program;
+ int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
+ (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
+ return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
+ }
+ case LDKFallback_PubKeyHash: {
+ int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
+ (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
+ return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
+ }
+ case LDKFallback_ScriptHash: {
+ int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
+ (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
+ return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
+ }
+ default: abort();
+ }
+}
+typedef struct LDKPayer_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID node_id_meth;
+ jmethodID first_hops_meth;
+ jmethodID send_payment_meth;
+ jmethodID send_spontaneous_payment_meth;
+ jmethodID retry_payment_meth;
+ jmethodID abandon_payment_meth;
+} LDKPayer_JCalls;
+static void LDKPayer_JCalls_free(void* this_arg) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
+ }
+ LDKPublicKey ret_ref;
+ CHECK((*env)->GetArrayLength(env, ret) == 33);
+ (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_ref;
+}
+LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
+ }
+ LDKCVec_ChannelDetailsZ ret_constr;
+ ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+ else
+ ret_constr.data = NULL;
+ int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+ for (size_t q = 0; q < ret_constr.datalen; q++) {
+ int64_t ret_conv_16 = ret_vals[q];
+ LDKChannelDetails ret_conv_16_conv;
+ ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
+ ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
+ ret_constr.data[q] = ret_conv_16_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_constr;
+}
+LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKRoute route_var = *route;
+ int64_t route_ref = 0;
+ route_var = Route_clone(&route_var);
+ CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
+ route_ref = (uintptr_t)route_var.inner;
+ if (route_var.is_owned) {
+ route_ref |= 1;
+ }
+ int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
+ int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKRoute route_var = *route;
+ int64_t route_ref = 0;
+ route_var = Route_clone(&route_var);
+ CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
+ route_ref = (uintptr_t)route_var.inner;
+ if (route_var.is_owned) {
+ route_ref |= 1;
+ }
+ int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ LDKRoute route_var = *route;
+ int64_t route_ref = 0;
+ route_var = Route_clone(&route_var);
+ CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
+ route_ref = (uintptr_t)route_var.inner;
+ if (route_var.is_owned) {
+ route_ref |= 1;
+ }
+ int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
+ }
+ void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
+ FREE((void*)ret);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ return ret_conv;
+}
+void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
+ if (UNLIKELY((*env)->ExceptionCheck(env))) {
+ (*env)->ExceptionDescribe(env);
+ (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
+ }
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+}
+static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
+ LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+ calls->o = (*env)->NewWeakGlobalRef(env, o);
+ calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
+ CHECK(calls->node_id_meth != NULL);
+ calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
+ CHECK(calls->first_hops_meth != NULL);
+ calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
+ CHECK(calls->send_payment_meth != NULL);
+ calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
+ CHECK(calls->send_spontaneous_payment_meth != NULL);
+ calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
+ CHECK(calls->retry_payment_meth != NULL);
+ calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
+ CHECK(calls->abandon_payment_meth != NULL);
+
+ LDKPayer ret = {
+ .this_arg = (void*) calls,
+ .node_id = node_id_LDKPayer_jcall,
+ .first_hops = first_hops_LDKPayer_jcall,
+ .send_payment = send_payment_LDKPayer_jcall,
+ .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
+ .retry_payment = retry_payment_LDKPayer_jcall,
+ .abandon_payment = abandon_payment_LDKPayer_jcall,
+ .free = LDKPayer_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
+ LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
+ *res_ptr = LDKPayer_init(env, clz, o);
+ return (uint64_t)res_ptr;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
+ return ret_arr;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = NULL;
+ ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t q = 0; q < ret_var.datalen; q++) {
+ LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+ int64_t ret_conv_16_ref = 0;
+ CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
+ ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
+ if (ret_conv_16_var.is_owned) {
+ ret_conv_16_ref |= 1;
+ }
+ ret_arr_ptr[q] = ret_conv_16_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ LDKRoute route_conv;
+ route_conv.inner = (void*)(route & (~1));
+ route_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
+ LDKThirtyTwoBytes payment_hash_ref;
+ CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
+ (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
+ LDKThirtyTwoBytes payment_secret_ref;
+ CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
+ (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
+ LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+ *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ LDKRoute route_conv;
+ route_conv.inner = (void*)(route & (~1));
+ route_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
+ LDKThirtyTwoBytes payment_preimage_ref;
+ CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
+ (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
+ LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+ *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ LDKRoute route_conv;
+ route_conv.inner = (void*)(route & (~1));
+ route_conv.is_owned = false;
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
+ LDKThirtyTwoBytes payment_id_ref;
+ CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+ (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
+ LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
+ *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
+ return (int64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
+ void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+ LDKThirtyTwoBytes payment_id_ref;
+ CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+ (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
+ (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
+}
+
+typedef struct LDKRouter_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID find_route_meth;
+} LDKRouter_JCalls;
+static void LDKRouter_JCalls_free(void* this_arg) {
+ LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
+ } else {
+ DO_ASSERT(get_jenv_res == JNI_OK);
+ }
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ if (get_jenv_res == JNI_EDETACHED) {
+ DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+ }
+ FREE(j_calls);
+ }
+}
+LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
+ LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+ JNIEnv *env;
+ jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
+ if (get_jenv_res == JNI_EDETACHED) {