-typedef struct LDKRouter_JCalls {
- atomic_size_t refcnt;
- JavaVM *vm;
- jweak o;
- jmethodID find_route_meth;
- jmethodID find_route_with_id_meth;
- jmethodID notify_payment_path_failed_meth;
- jmethodID notify_payment_path_successful_meth;
- jmethodID notify_payment_probe_successful_meth;
- jmethodID notify_payment_probe_failed_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, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
- 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) {
- DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
- } else {
- DO_ASSERT(get_jenv_res == JNI_OK);
- }
- int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
- (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
- LDKRouteParameters route_params_var = *route_params;
- int64_t route_params_ref = 0;
- route_params_var = RouteParameters_clone(&route_params_var);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
- route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
- LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
- int64_tArray first_hops_arr = NULL;
- if (first_hops != NULL) {
- LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
- first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
- int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
- for (size_t q = 0; q < first_hops_var.datalen; q++) {
- LDKChannelDetails first_hops_conv_16_var = first_hops_var.data[q];
- int64_t first_hops_conv_16_ref = 0;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
- first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
- first_hops_arr_ptr[q] = first_hops_conv_16_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
- }
- LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
- int64_t inflight_htlcs_ref = 0;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
- inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
- jobject obj = (*env)->NewLocalRef(env, j_calls->o);
- CHECK(obj != NULL);
- uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
- }
- void* ret_ptr = untag_ptr(ret);
- CHECK_ACCESS(ret_ptr);
- LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
- FREE(untag_ptr(ret));
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
- return ret_conv;
-}
-LDKCResult_RouteLightningErrorZ find_route_with_id_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs, LDKThirtyTwoBytes _payment_hash, LDKThirtyTwoBytes _payment_id) {
- 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) {
- DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
- } else {
- DO_ASSERT(get_jenv_res == JNI_OK);
- }
- int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
- (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
- LDKRouteParameters route_params_var = *route_params;
- int64_t route_params_ref = 0;
- route_params_var = RouteParameters_clone(&route_params_var);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
- route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
- LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
- int64_tArray first_hops_arr = NULL;
- if (first_hops != NULL) {
- LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
- first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
- int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
- for (size_t q = 0; q < first_hops_var.datalen; q++) {
- LDKChannelDetails first_hops_conv_16_var = first_hops_var.data[q];
- int64_t first_hops_conv_16_ref = 0;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
- first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
- first_hops_arr_ptr[q] = first_hops_conv_16_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
- }
- LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
- int64_t inflight_htlcs_ref = 0;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
- inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
- int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
- 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->find_route_with_id_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref, _payment_hash_arr, _payment_id_arr);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
- }
- void* ret_ptr = untag_ptr(ret);
- CHECK_ACCESS(ret_ptr);
- LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
- FREE(untag_ptr(ret));
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
- return ret_conv;
-}
-void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
- 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) {
- 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_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
- path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
- path_arr_ptr[k] = path_conv_10_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
- FREE(path_var.data);
- int64_t short_channel_id_conv = short_channel_id;
- jobject obj = (*env)->NewLocalRef(env, j_calls->o);
- CHECK(obj != NULL);
- (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
- }
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
-}
-void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
- 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) {
- 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_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
- path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
- 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->notify_payment_path_successful_meth, path_arr);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
- }
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
-}
-void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
- 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) {
- 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_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
- path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
- 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->notify_payment_probe_successful_meth, path_arr);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
- }
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
-}
-void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
- 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) {
- 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_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
- path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
- path_arr_ptr[k] = path_conv_10_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
- FREE(path_var.data);
- int64_t short_channel_id_conv = short_channel_id;
- jobject obj = (*env)->NewLocalRef(env, j_calls->o);
- CHECK(obj != NULL);
- (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
- if (UNLIKELY((*env)->ExceptionCheck(env))) {
- (*env)->ExceptionDescribe(env);
- (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
- }
- if (get_jenv_res == JNI_EDETACHED) {
- DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
- }
-}
-static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
- LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
- jclass c = (*env)->GetObjectClass(env, o);
- CHECK(c != NULL);
- LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
- atomic_init(&calls->refcnt, 1);
- DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
- calls->o = (*env)->NewWeakGlobalRef(env, o);
- calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
- CHECK(calls->find_route_meth != NULL);
- calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
- CHECK(calls->find_route_with_id_meth != NULL);
- calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
- CHECK(calls->notify_payment_path_failed_meth != NULL);
- calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
- CHECK(calls->notify_payment_path_successful_meth != NULL);
- calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
- CHECK(calls->notify_payment_probe_successful_meth != NULL);
- calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
- CHECK(calls->notify_payment_probe_failed_meth != NULL);
-
- LDKRouter ret = {
- .this_arg = (void*) calls,
- .find_route = find_route_LDKRouter_jcall,
- .find_route_with_id = find_route_with_id_LDKRouter_jcall,
- .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
- .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
- .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
- .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
- .free = LDKRouter_JCalls_free,
- };
- return ret;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
- LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
- *res_ptr = LDKRouter_init(env, clz, o);
- return tag_ptr(res_ptr, true);
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int64_tArray first_hops, int64_t inflight_htlcs) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
- LDKPublicKey payer_ref;
- CHECK((*env)->GetArrayLength(env, payer) == 33);
- (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
- LDKRouteParameters route_params_conv;
- route_params_conv.inner = untag_ptr(route_params);
- route_params_conv.is_owned = ptr_is_owned(route_params);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
- route_params_conv.is_owned = false;
- LDKCVec_ChannelDetailsZ first_hops_constr;
- LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
- if (first_hops != NULL) {
- first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
- if (first_hops_constr.datalen > 0)
- first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
- else
- first_hops_constr.data = NULL;
- int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
- for (size_t q = 0; q < first_hops_constr.datalen; q++) {
- int64_t first_hops_conv_16 = first_hops_vals[q];
- LDKChannelDetails first_hops_conv_16_conv;
- first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
- first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
- first_hops_conv_16_conv.is_owned = false;
- first_hops_constr.data[q] = first_hops_conv_16_conv;
- }
- (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
- first_hops_ptr = &first_hops_constr;
- }
- LDKInFlightHtlcs inflight_htlcs_conv;
- inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
- inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
- inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
- LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
- *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv);
- if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
- return tag_ptr(ret_conv, true);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route_1with_1id(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int64_tArray first_hops, int64_t inflight_htlcs, int8_tArray _payment_hash, int8_tArray _payment_id) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
- LDKPublicKey payer_ref;
- CHECK((*env)->GetArrayLength(env, payer) == 33);
- (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
- LDKRouteParameters route_params_conv;
- route_params_conv.inner = untag_ptr(route_params);
- route_params_conv.is_owned = ptr_is_owned(route_params);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
- route_params_conv.is_owned = false;
- LDKCVec_ChannelDetailsZ first_hops_constr;
- LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
- if (first_hops != NULL) {
- first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
- if (first_hops_constr.datalen > 0)
- first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
- else
- first_hops_constr.data = NULL;
- int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
- for (size_t q = 0; q < first_hops_constr.datalen; q++) {
- int64_t first_hops_conv_16 = first_hops_vals[q];
- LDKChannelDetails first_hops_conv_16_conv;
- first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
- first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
- first_hops_conv_16_conv.is_owned = false;
- first_hops_constr.data[q] = first_hops_conv_16_conv;
- }
- (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
- first_hops_ptr = &first_hops_constr;
- }
- LDKInFlightHtlcs inflight_htlcs_conv;
- inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
- inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
- inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_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_id_ref;
- CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
- (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
- LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
- *ret_conv = (this_arg_conv->find_route_with_id)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv, _payment_hash_ref, _payment_id_ref);
- if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
- return tag_ptr(ret_conv, true);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)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 = untag_ptr(path_conv_10);
- path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
- 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->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)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 = untag_ptr(path_conv_10);
- path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
- 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->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)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 = untag_ptr(path_conv_10);
- path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
- 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->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
- void* this_arg_ptr = untag_ptr(this_arg);
- if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
- LDKRouter* this_arg_conv = (LDKRouter*)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 = untag_ptr(path_conv_10);
- path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
- 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->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
-}
-