+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 jclass LDKEvent_FundingGenerationReady_class = NULL;
+static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
+static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
+static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
+static jclass LDKEvent_PaymentReceived_class = NULL;
+static jmethodID LDKEvent_PaymentReceived_meth = NULL;
+static jclass LDKEvent_PaymentSent_class = NULL;
+static jmethodID LDKEvent_PaymentSent_meth = NULL;
+static jclass LDKEvent_PaymentFailed_class = NULL;
+static jmethodID LDKEvent_PaymentFailed_meth = NULL;
+static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
+static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
+static jclass LDKEvent_SpendableOutputs_class = NULL;
+static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
+ LDKEvent_FundingGenerationReady_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
+ CHECK(LDKEvent_FundingGenerationReady_class != NULL);
+ LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
+ CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
+ LDKEvent_FundingBroadcastSafe_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
+ CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
+ LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
+ CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
+ LDKEvent_PaymentReceived_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
+ CHECK(LDKEvent_PaymentReceived_class != NULL);
+ LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
+ CHECK(LDKEvent_PaymentReceived_meth != NULL);
+ LDKEvent_PaymentSent_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
+ CHECK(LDKEvent_PaymentSent_class != NULL);
+ LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
+ CHECK(LDKEvent_PaymentSent_meth != NULL);
+ LDKEvent_PaymentFailed_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
+ CHECK(LDKEvent_PaymentFailed_class != NULL);
+ LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
+ CHECK(LDKEvent_PaymentFailed_meth != NULL);
+ LDKEvent_PendingHTLCsForwardable_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
+ CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
+ LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
+ CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
+ LDKEvent_SpendableOutputs_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
+ CHECK(LDKEvent_SpendableOutputs_class != NULL);
+ LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
+ CHECK(LDKEvent_SpendableOutputs_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKEvent *obj = (LDKEvent*)ptr;
+ switch(obj->tag) {
+ case LDKEvent_FundingGenerationReady: {
+ int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
+ LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
+ int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
+ (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
+ return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
+ }
+ case LDKEvent_FundingBroadcastSafe: {
+ LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
+ CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long funding_txo_ref = (long)funding_txo_var.inner & ~1;
+ return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
+ }
+ case LDKEvent_PaymentReceived: {
+ int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
+ int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
+ return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
+ }
+ case LDKEvent_PaymentSent: {
+ int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
+ return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
+ }
+ case LDKEvent_PaymentFailed: {
+ int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
+ return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
+ }
+ case LDKEvent_PendingHTLCsForwardable: {
+ return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
+ }
+ case LDKEvent_SpendableOutputs: {
+ LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
+ int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
+ int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
+ for (size_t b = 0; b < outputs_var.datalen; b++) {
+ long arr_conv_27_ref = (long)&outputs_var.data[b];
+ outputs_arr_ptr[b] = arr_conv_27_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
+ return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
+ }
+ default: abort();
+ }
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)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;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
+ LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
+ ret->a = a;
+ LDKTransaction b_ref;
+ b_ref.datalen = (*env)->GetArrayLength(env, b);
+ b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
+ b_ref.data_is_owned = false;
+ ret->b = b_ref;
+ return (long)ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
+ return tuple->a;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
+ LDKTransaction b_var = tuple->b;
+ int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
+ (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
+ return b_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_elem;
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
+ CHECK(!val->result_ok);
+ jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
+ return err_conv;
+}
+static inline LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const LDKCResult_NoneChannelMonitorUpdateErrZ *orig) {
+ LDKCResult_NoneChannelMonitorUpdateErrZ res = { .result_ok = orig->result_ok };
+ if (orig->result_ok) {
+ res.contents.result = NULL;
+ } else {
+ LDKChannelMonitorUpdateErr* contents = MALLOC(sizeof(LDKChannelMonitorUpdateErr), "LDKChannelMonitorUpdateErr result Err clone");
+ *contents = ChannelMonitorUpdateErr_clone(orig->contents.err);
+ res.contents.err = contents;
+ }
+ return res;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKMonitorEvent arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ if (arr_elem_conv.inner != NULL)
+ arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
+ LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = MonitorEvent_clone(&orig->data[i]);
+ }
+ return ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
+ CHECK(val->result_ok);
+ LDKChannelMonitorUpdate res_var = (*val->contents.result);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKMonitorUpdateError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
+ LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
+ LDKOutPoint a_conv;
+ a_conv.inner = (void*)(a & (~1));
+ a_conv.is_owned = (a & 1) || (a == 0);
+ if (a_conv.inner != NULL)
+ a_conv = OutPoint_clone(&a_conv);
+ ret->a = a_conv;
+ LDKCVec_u8Z b_ref;
+ b_ref.datalen = (*env)->GetArrayLength(env, b);
+ b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
+ ret->b = b_ref;
+ return (long)ret;
+}
+static inline LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const LDKC2Tuple_OutPointScriptZ *orig) {
+ LDKC2Tuple_OutPointScriptZ ret = {
+ .a = OutPoint_clone(&orig->a),
+ .b = CVec_u8Z_clone(&orig->b),
+ };
+ return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
+ LDKOutPoint a_var = tuple->a;
+ CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long a_ref = (long)a_var.inner & ~1;
+ return a_ref;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
+ LDKCVec_u8Z b_var = tuple->b;
+ int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
+ (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
+ return b_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
+ LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
+ ret->a = a;
+ LDKTxOut b_conv = *(LDKTxOut*)b;
+ FREE((void*)b);
+ ret->b = b_conv;
+ return (long)ret;
+}
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
+ return tuple->a;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
+ long b_ref = (long)&tuple->b;
+ return (long)b_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)arr_elem;
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
+ LDKThirtyTwoBytes a_ref;
+ CHECK((*env)->GetArrayLength(env, a) == 32);
+ (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
+ ret->a = a_ref;
+ LDKCVec_C2Tuple_u32TxOutZZ b_constr;
+ b_constr.datalen = (*env)->GetArrayLength(env, b);
+ if (b_constr.datalen > 0)
+ b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
+ else
+ b_constr.data = NULL;
+ int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
+ for (size_t a = 0; a < b_constr.datalen; a++) {
+ int64_t arr_conv_26 = b_vals[a];
+ LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
+ FREE((void*)arr_conv_26);
+ b_constr.data[a] = arr_conv_26_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
+ ret->b = b_constr;
+ return (long)ret;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
+ int8_tArray a_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
+ return a_arr;
+}
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
+ LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
+ int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
+ int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
+ for (size_t a = 0; a < b_var.datalen; a++) {
+ long arr_conv_26_ref = (long)&b_var.data[a];
+ b_arr_ptr[a] = arr_conv_26_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
+ return b_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_elem;
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
+ LDKSignature a_ref;
+ CHECK((*env)->GetArrayLength(env, a) == 64);
+ (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
+ ret->a = a_ref;
+ LDKCVec_SignatureZ b_constr;
+ b_constr.datalen = (*env)->GetArrayLength(env, b);
+ if (b_constr.datalen > 0)
+ b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
+ else
+ b_constr.data = NULL;
+ for (size_t i = 0; i < b_constr.datalen; i++) {
+ int8_tArray arr_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
+ LDKSignature arr_conv_8_ref;
+ CHECK((*env)->GetArrayLength(env, arr_conv_8) == 64);
+ (*env)->GetByteArrayRegion(env, arr_conv_8, 0, 64, arr_conv_8_ref.compact_form);
+ b_constr.data[i] = arr_conv_8_ref;
+ }
+ ret->b = b_constr;
+ return (long)ret;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
+ int8_tArray a_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
+ return a_arr;
+}
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
+ LDKCVec_SignatureZ b_var = tuple->b;
+ jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
+ for (size_t i = 0; i < b_var.datalen; i++) {
+ int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, 64, b_var.data[i].compact_form);
+ (*env)->SetObjectArrayElement(env, b_arr, i, arr_conv_8_arr);
+ }
+ return b_arr;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
+ CHECK(val->result_ok);
+ long res_ref = (long)&(*val->contents.result);
+ return res_ref;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
+ CHECK(val->result_ok);
+ int8_tArray res_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
+ return res_arr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
+}
+JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
+ CHECK(val->result_ok);
+ LDKCVec_SignatureZ res_var = (*val->contents.result);
+ jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+ for (size_t i = 0; i < res_var.datalen; i++) {
+ int8_tArray arr_conv_8_arr = (*env)->NewByteArray(env, 64);
+ (*env)->SetByteArrayRegion(env, arr_conv_8_arr, 0, 64, res_var.data[i].compact_form);
+ (*env)->SetObjectArrayElement(env, res_arr, i, arr_conv_8_arr);
+ }
+ return res_arr;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+typedef struct LDKChannelKeys_JCalls {
+ atomic_size_t refcnt;
+ JavaVM *vm;
+ jweak o;
+ jmethodID get_per_commitment_point_meth;
+ jmethodID release_commitment_secret_meth;
+ jmethodID key_derivation_params_meth;
+ jmethodID sign_counterparty_commitment_meth;
+ jmethodID sign_holder_commitment_meth;
+ jmethodID sign_holder_commitment_htlc_transactions_meth;
+ jmethodID sign_justice_transaction_meth;
+ jmethodID sign_counterparty_htlc_transaction_meth;
+ jmethodID sign_closing_transaction_meth;
+ jmethodID sign_channel_announcement_meth;
+ jmethodID ready_channel_meth;
+ jmethodID write_meth;
+} LDKChannelKeys_JCalls;
+static void LDKChannelKeys_JCalls_free(void* this_arg) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
+ LDKPublicKey arg_ref;
+ CHECK((*env)->GetArrayLength(env, arg) == 33);
+ (*env)->GetByteArrayRegion(env, arg, 0, 33, arg_ref.compressed_form);
+ return arg_ref;
+}
+LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
+ LDKThirtyTwoBytes arg_ref;
+ CHECK((*env)->GetArrayLength(env, arg) == 32);
+ (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.data);
+ return arg_ref;
+}
+LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, obj, j_calls->key_derivation_params_meth);
+ LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+ if (commitment_tx->inner != NULL)
+ commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
+ CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long commitment_tx_ref = (long)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);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ if (commitment_tx->inner != NULL)
+ commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
+ CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long commitment_tx_ref = (long)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);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_meth, commitment_tx_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ if (commitment_tx->inner != NULL)
+ commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
+ CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long commitment_tx_ref = (long)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);
+ LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, commitment_tx_ref);
+ LDKCResult_CVec_SignatureZNoneZ ret_conv = *(LDKCResult_CVec_SignatureZNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uint64_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == 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;
+ if (htlc->inner != NULL)
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long htlc_ref = (long)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uint64_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == 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;
+ if (htlc->inner != NULL)
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long htlc_ref = (long)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKTransaction closing_tx_var = closing_tx;
+ int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
+ (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
+ Transaction_free(closing_tx_var);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKUnsignedChannelAnnouncement msg_var = *msg;
+ if (msg->inner != NULL)
+ msg_var = UnsignedChannelAnnouncement_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+ if (channel_parameters->inner != NULL)
+ channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
+ CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long channel_parameters_ref = (long)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);
+ return (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
+}
+LDKCVec_u8Z write_jcall(const void* this_arg) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int8_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
+ LDKCVec_u8Z arg_ref;
+ arg_ref.datalen = (*env)->GetArrayLength(env, arg);
+ arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
+ (*env)->GetByteArrayRegion(env, arg, 0, arg_ref.datalen, arg_ref.data);
+ return arg_ref;
+}
+static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
+ LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
+ jclass c = (*env)->GetObjectClass(env, o);
+ CHECK(c != NULL);
+ LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_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->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
+ CHECK(calls->key_derivation_params_meth != NULL);
+ calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
+ CHECK(calls->sign_counterparty_commitment_meth != NULL);
+ calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
+ CHECK(calls->sign_holder_commitment_meth != NULL);
+ calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
+ CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
+ calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
+ CHECK(calls->sign_justice_transaction_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", "([B)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);
+ 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);
+ if (pubkeys_conv.inner != NULL)
+ pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
+
+ LDKChannelKeys ret = {
+ .this_arg = (void*) calls,
+ .get_per_commitment_point = get_per_commitment_point_jcall,
+ .release_commitment_secret = release_commitment_secret_jcall,
+ .key_derivation_params = key_derivation_params_jcall,
+ .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
+ .sign_holder_commitment = sign_holder_commitment_jcall,
+ .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
+ .sign_justice_transaction = sign_justice_transaction_jcall,
+ .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
+ .sign_closing_transaction = sign_closing_transaction_jcall,
+ .sign_channel_announcement = sign_channel_announcement_jcall,
+ .ready_channel = ready_channel_jcall,
+ .clone = LDKChannelKeys_JCalls_clone,
+ .write = write_jcall,
+ .free = LDKChannelKeys_JCalls_free,
+ .pubkeys = pubkeys_conv,
+ .set_pubkeys = NULL,
+ };
+ return ret;
+}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
+ LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
+ *res_ptr = LDKChannelKeys_init(env, clz, o, pubkeys);
+ return (long)res_ptr;
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv *env, jclass clz, int64_t val) {
+ jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
+ CHECK(ret != NULL);
+ return ret;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ int8_tArray arg_arr = (*env)->NewByteArray(env, 33);
+ (*env)->SetByteArrayRegion(env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
+ return arg_arr;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ int8_tArray arg_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
+ return arg_arr;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1key_1derivation_1params(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
+ *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
+ return (long)ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ 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);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKHolderCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1holder_1commitment_1htlc_1transactions(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKHolderCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
+ *ret_conv = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1justice_1transaction(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) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ 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;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_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) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ 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;
+ 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 (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKTransaction closing_tx_ref;
+ closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
+ closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
+ (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
+ closing_tx_ref.data_is_owned = true;
+ 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_ref);
+ return (long)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKUnsignedChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (long)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKChannelTransactionParameters channel_parameters_conv;
+ channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
+ channel_parameters_conv.is_owned = false;
+ (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray arg_arr = (*env)->NewByteArray(env, arg_var.datalen);
+ (*env)->SetByteArrayRegion(env, arg_arr, 0, arg_var.datalen, arg_var.data);
+ CVec_u8Z_free(arg_var);
+ return arg_arr;
+}
+
+LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* 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_ChannelKeys_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
+ CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long ret_ref = (long)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ LDKThirtyTwoBytes a_ref;
+ CHECK((*env)->GetArrayLength(env, a) == 32);
+ (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
+ ret->a = a_ref;
+ LDKChannelMonitor b_conv;
+ b_conv.inner = (void*)(b & (~1));
+ b_conv.is_owned = (b & 1) || (b == 0);
+ // Warning: we may need a move here but can't clone!
+ ret->b = b_conv;
+ return (long)ret;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
+ int8_tArray a_arr = (*env)->NewByteArray(env, 32);
+ (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
+ return a_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
+ LDKChannelMonitor b_var = tuple->b;
+ CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long b_ref = (long)b_var.inner & ~1;
+ return b_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
+ CHECK(val->result_ok);
+ long res_ref = (long)&(*val->contents.result);
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
+ CHECK(val->result_ok);
+ long res_ref = (long)&(*val->contents.result);
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChanKeySignerDecodeErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
+ CHECK(val->result_ok);
+ LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
+ *ret = (*val->contents.result);
+ return (long)ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
+ CHECK(val->result_ok);
+ LDKInMemoryChannelKeys res_var = (*val->contents.result);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)res_var.inner & ~1;
+ return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
+ CHECK(val->result_ok);
+ long res_ref = (long)&(*val->contents.result);
+ return (long)res_ref;
+}
+JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
+ CHECK(!val->result_ok);
+ jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
+ return err_conv;
+}
+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;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
+ LDKAPIError_APIMisuseError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
+ CHECK(LDKAPIError_APIMisuseError_class != NULL);
+ LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "([B)V");
+ CHECK(LDKAPIError_APIMisuseError_meth != NULL);
+ LDKAPIError_FeeRateTooHigh_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
+ CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
+ LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "([BI)V");
+ CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
+ LDKAPIError_RouteError_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
+ CHECK(LDKAPIError_RouteError_class != NULL);
+ LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
+ CHECK(LDKAPIError_RouteError_meth != NULL);
+ LDKAPIError_ChannelUnavailable_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
+ CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
+ LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "([B)V");
+ CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
+ LDKAPIError_MonitorUpdateFailed_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/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);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv *env, jclass clz, int64_t ptr) {
+ LDKAPIError *obj = (LDKAPIError*)ptr;
+ switch(obj->tag) {
+ case LDKAPIError_APIMisuseError: {
+ LDKCVec_u8Z err_var = obj->api_misuse_error.err;
+ int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
+ (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
+ return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_arr);
+ }
+ case LDKAPIError_FeeRateTooHigh: {
+ LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
+ int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
+ (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
+ return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_arr, obj->fee_rate_too_high.feerate);
+ }
+ case LDKAPIError_RouteError: {
+ LDKStr err_str = obj->route_error.err;
+ char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
+ memcpy(err_buf, err_str.chars, err_str.len);
+ err_buf[err_str.len] = 0;
+ jstring err_conv = (*env)->NewStringUTF(env, err_str.chars);
+ FREE(err_buf);
+ return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
+ }
+ case LDKAPIError_ChannelUnavailable: {
+ LDKCVec_u8Z err_var = obj->channel_unavailable.err;
+ int8_tArray err_arr = (*env)->NewByteArray(env, err_var.datalen);
+ (*env)->SetByteArrayRegion(env, err_arr, 0, err_var.datalen, err_var.data);
+ return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_arr);
+ }
+ case LDKAPIError_MonitorUpdateFailed: {
+ return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
+ }
+ default: abort();
+ }
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
+ CHECK(!val->result_ok);
+ long err_ref = (long)&(*val->contents.err);
+ return err_ref;
+}
+static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
+ LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
+ if (orig->result_ok) {
+ res.contents.result = NULL;
+ } else {
+ LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
+ *contents = APIError_clone(orig->contents.err);
+ res.contents.err = contents;
+ }
+ return res;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKChannelDetails arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ if (arr_elem_conv.inner != NULL)
+ arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+ LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+ }
+ return ret;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
+}
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err (JNIEnv *env, jclass clz, int64_t arg) {
+ LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
+ CHECK(!val->result_ok);
+ LDKPaymentSendFailure err_var = (*val->contents.err);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_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, "Lorg/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, "Lorg/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, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
+ CHECK(LDKNetAddress_OnionV2_class != NULL);
+ LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
+ CHECK(LDKNetAddress_OnionV2_meth != NULL);
+ LDKNetAddress_OnionV3_class =
+ (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/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;
+ 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 addr_arr = (*env)->NewByteArray(env, 10);
+ (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
+ return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
+ }
+ case LDKNetAddress_OnionV3: {
+ 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();
+ }
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)ret;
+}
+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;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+ LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
+ ret->datalen = (*env)->GetArrayLength(env, elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
+ int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ int64_t arr_elem = java_elems[i];
+ LDKChannelMonitor arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ // Warning: we may need a move here but can't clone!
+ ret->data[i] = arr_elem_conv;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+ }
+ return (long)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;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ (*env)->DeleteWeakGlobalRef(env, j_calls->o);
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKOutPoint funding_txo_var = funding_txo;
+ CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long funding_txo_ref = (long)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitor monitor_var = monitor;
+ CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long monitor_ref = (long)monitor_var.inner;
+ if (monitor_var.is_owned) {
+ monitor_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ LDKOutPoint funding_txo_var = funding_txo;
+ CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long funding_txo_ref = (long)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = update;
+ CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long update_ref = (long)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
+ FREE((void*)ret);
+ return ret_conv;
+}
+LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ JNIEnv *env;
+ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
+ jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+ CHECK(obj != NULL);
+ int64_tArray arg = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
+ LDKCVec_MonitorEventZ arg_constr;
+ arg_constr.datalen = (*env)->GetArrayLength(env, arg);
+ if (arg_constr.datalen > 0)
+ arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
+ else
+ arg_constr.data = NULL;
+ int64_t* arg_vals = (*env)->GetLongArrayElements (env, arg, NULL);
+ for (size_t o = 0; o < arg_constr.datalen; o++) {
+ int64_t arr_conv_14 = arg_vals[o];
+ LDKMonitorEvent arr_conv_14_conv;
+ arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
+ arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
+ if (arr_conv_14_conv.inner != NULL)
+ arr_conv_14_conv = MonitorEvent_clone(&arr_conv_14_conv);
+ arg_constr.data[o] = arr_conv_14_conv;
+ }
+ (*env)->ReleaseLongArrayElements(env, arg, arg_vals, 0);
+ return arg_constr;
+}
+static void* LDKWatch_JCalls_clone(const void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+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_jcall,
+ .update_channel = update_channel_jcall,
+ .release_pending_monitor_events = release_pending_monitor_events_jcall,
+ .free = LDKWatch_JCalls_free,
+ };
+ return ret;
+}
+JNIEXPORT long 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 (long)res_ptr;
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv *env, jclass clz, int64_t val) {
+ jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
+ CHECK(ret != NULL);
+ return ret;
+}
+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) {
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ if (funding_txo_conv.inner != NULL)
+ 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);
+ // Warning: we may need a move here but can't clone!
+ 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 (long)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) {
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ if (funding_txo_conv.inner != NULL)
+ 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);
+ if (update_conv.inner != NULL)
+ 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 (long)ret_conv;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
+ LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
+ int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+ int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+ for (size_t o = 0; o < ret_var.datalen; o++) {
+ LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
+ CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long arr_conv_14_ref = (long)arr_conv_14_var.inner;
+ if (arr_conv_14_var.is_owned) {
+ arr_conv_14_ref |= 1;
+ }
+ ret_arr_ptr[o] = arr_conv_14_ref;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKBroadcasterInterface_JCalls {