2e829e6b95943ae1498edc071508c0d50cccacda
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define LIKELY(v) __builtin_expect(!!(v), 1)
11 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
12
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define MALLOC(a, _) malloc(a)
15 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
16 #define CHECK_ACCESS(p)
17 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
18 #define DO_ASSERT(a) (void)(a)
19 #define CHECK(a)
20
21 static jmethodID ordinal_meth = NULL;
22 static jmethodID slicedef_meth = NULL;
23 static jclass slicedef_cls = NULL;
24 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
25         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
26         CHECK(ordinal_meth != NULL);
27         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
28         CHECK(slicedef_meth != NULL);
29         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
30         CHECK(slicedef_cls != NULL);
31 }
32
33 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((bool*)ptr);
35 }
36 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
37         return *((long*)ptr);
38 }
39 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
40         FREE((void*)ptr);
41 }
42 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
43         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
44         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
45         return ret_arr;
46 }
47 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
48         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
49         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
50         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
51         return ret_arr;
52 }
53 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
54         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
55         vec->datalen = (*env)->GetArrayLength(env, bytes);
56         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
57         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
58         return (uint64_t)vec;
59 }
60 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
61         LDKTransaction *txdata = (LDKTransaction*)ptr;
62         LDKu8slice slice;
63         slice.data = txdata->data;
64         slice.datalen = txdata->datalen;
65         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
66 }
67 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
68         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
69         txdata->datalen = (*env)->GetArrayLength(env, bytes);
70         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
71         txdata->data_is_owned = false;
72         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
73         return (uint64_t)txdata;
74 }
75 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
76         LDKTransaction *tx = (LDKTransaction*)ptr;
77         tx->data_is_owned = true;
78         Transaction_free(*tx);
79         FREE((void*)ptr);
80 }
81 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
82         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
84         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
87         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
88         return (uint64_t)vec->datalen;
89 }
90 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
91         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
93         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
96         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
97         vec->data = NULL;
98         vec->datalen = 0;
99         return (uint64_t)vec;
100 }
101
102 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
103 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
104 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
105 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
106
107 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
108 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
109 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
110
111 typedef jlongArray int64_tArray;
112 typedef jbyteArray int8_tArray;
113
114 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
115         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
116         char* conv_buf = MALLOC(len + 1, "str conv buf");
117         memcpy(conv_buf, chars, len);
118         conv_buf[len] = 0;
119         jstring ret = (*env)->NewStringUTF(env, conv_buf);
120         FREE(conv_buf);
121         return ret;
122 }
123 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
124         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
125         char* newchars = MALLOC(str_len + 1, "String chars");
126         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
127         memcpy(newchars, jchars, str_len);
128         newchars[str_len] = 0;
129         (*env)->ReleaseStringUTFChars(env, str, jchars);
130         LDKStr res = {
131                 .chars = newchars,
132                 .len = str_len,
133                 .chars_is_owned = true
134         };
135         return res;
136 }
137
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
140 }
141 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
142         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
143 }
144 #include "version.c"
145 static jclass arr_of_B_clz = NULL;
146 static jclass arr_of_J_clz = NULL;
147 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
148         arr_of_B_clz = (*env)->FindClass(env, "[B");
149         CHECK(arr_of_B_clz != NULL);
150         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
151         arr_of_J_clz = (*env)->FindClass(env, "[J");
152         CHECK(arr_of_J_clz != NULL);
153         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
154 }
155 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
156
157 static inline void* untag_ptr(uint64_t ptr) {
158         if (ptr < 4096) return (void*)ptr;
159         if (sizeof(void*) == 4) {
160                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
161                 return (void*)(uintptr_t)ptr;
162         } else {
163                 // For 64-bit systems, assume the top byte is used for tagging, then
164                 // use bit 9 ^ bit 10.
165                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
166                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
167 #ifdef LDK_DEBUG_BUILD
168                 // On debug builds we also use the 11th bit as a debug flag
169                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
170                 CHECK(tenth_bit != eleventh_bit);
171                 p ^= 1ULL << 53;
172 #endif
173                 return (void*)p;
174         }
175 }
176 static inline bool ptr_is_owned(uint64_t ptr) {
177         if(ptr < 4096) return true;
178         if (sizeof(void*) == 4) {
179                 return ptr & (1ULL << 32);
180         } else {
181                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
182                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
183 #ifdef LDK_DEBUG_BUILD
184                 // On debug builds we also use the 11th bit as a debug flag
185                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
186                 CHECK(tenth_bit != eleventh_bit);
187 #endif
188                 return (ninth_bit ^ tenth_bit) ? true : false;
189         }
190 }
191 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
192         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
193         if (sizeof(void*) == 4) {
194                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
195         } else {
196                 CHECK(sizeof(uintptr_t) == 8);
197                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
198                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
199 #ifdef LDK_DEBUG_BUILD
200                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
201                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
202                 CHECK(ninth_bit == tenth_bit);
203                 CHECK(ninth_bit == eleventh_bit);
204                 t ^= 1ULL << 53;
205 #endif
206                 CHECK(ptr_is_owned(t) == is_owned);
207                 CHECK(untag_ptr(t) == ptr);
208                 return t;
209         }
210 }
211
212 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
213         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
214         if (UNLIKELY((*env)->ExceptionCheck(env))) {
215                 (*env)->ExceptionDescribe(env);
216                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
217         }
218         switch (ord) {
219                 case 0: return LDKAccessError_UnknownChain;
220                 case 1: return LDKAccessError_UnknownTx;
221         }
222         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
223         abort(); // Unreachable, but will let the compiler know we don't return here
224 }
225 static jclass AccessError_class = NULL;
226 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
227 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
228 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
229         AccessError_class = (*env)->NewGlobalRef(env, clz);
230         CHECK(AccessError_class != NULL);
231         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
232         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
233         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
234         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
235 }
236 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
237         switch (val) {
238                 case LDKAccessError_UnknownChain:
239                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
240                 case LDKAccessError_UnknownTx:
241                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
242                 default: abort();
243         }
244 }
245
246 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
247         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
248         if (UNLIKELY((*env)->ExceptionCheck(env))) {
249                 (*env)->ExceptionDescribe(env);
250                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
251         }
252         switch (ord) {
253                 case 0: return LDKCOption_NoneZ_Some;
254                 case 1: return LDKCOption_NoneZ_None;
255         }
256         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
257         abort(); // Unreachable, but will let the compiler know we don't return here
258 }
259 static jclass COption_NoneZ_class = NULL;
260 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
261 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
262 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
263         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
264         CHECK(COption_NoneZ_class != NULL);
265         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
266         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
267         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
268         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
269 }
270 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
271         switch (val) {
272                 case LDKCOption_NoneZ_Some:
273                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
274                 case LDKCOption_NoneZ_None:
275                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
276                 default: abort();
277         }
278 }
279
280 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_java(JNIEnv *env, jclass clz) {
281         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
282         if (UNLIKELY((*env)->ExceptionCheck(env))) {
283                 (*env)->ExceptionDescribe(env);
284                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
285         }
286         switch (ord) {
287                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
288                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
289                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
290         }
291         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
292         abort(); // Unreachable, but will let the compiler know we don't return here
293 }
294 static jclass ChannelMonitorUpdateStatus_class = NULL;
295 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
296 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
297 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
298 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
299         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
300         CHECK(ChannelMonitorUpdateStatus_class != NULL);
301         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
302         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
303         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
304         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
305         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
306         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
307 }
308 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
309         switch (val) {
310                 case LDKChannelMonitorUpdateStatus_Completed:
311                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
312                 case LDKChannelMonitorUpdateStatus_InProgress:
313                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
314                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
315                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
316                 default: abort();
317         }
318 }
319
320 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
321         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
322         if (UNLIKELY((*env)->ExceptionCheck(env))) {
323                 (*env)->ExceptionDescribe(env);
324                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
325         }
326         switch (ord) {
327                 case 0: return LDKConfirmationTarget_Background;
328                 case 1: return LDKConfirmationTarget_Normal;
329                 case 2: return LDKConfirmationTarget_HighPriority;
330         }
331         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
332         abort(); // Unreachable, but will let the compiler know we don't return here
333 }
334 static jclass ConfirmationTarget_class = NULL;
335 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
336 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
337 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
338 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
339         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
340         CHECK(ConfirmationTarget_class != NULL);
341         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
342         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
343         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
344         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
345         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
346         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
347 }
348 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
349         switch (val) {
350                 case LDKConfirmationTarget_Background:
351                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
352                 case LDKConfirmationTarget_Normal:
353                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
354                 case LDKConfirmationTarget_HighPriority:
355                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
356                 default: abort();
357         }
358 }
359
360 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
361         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
362         if (UNLIKELY((*env)->ExceptionCheck(env))) {
363                 (*env)->ExceptionDescribe(env);
364                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
365         }
366         switch (ord) {
367                 case 0: return LDKCreationError_DescriptionTooLong;
368                 case 1: return LDKCreationError_RouteTooLong;
369                 case 2: return LDKCreationError_TimestampOutOfBounds;
370                 case 3: return LDKCreationError_InvalidAmount;
371                 case 4: return LDKCreationError_MissingRouteHints;
372         }
373         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
374         abort(); // Unreachable, but will let the compiler know we don't return here
375 }
376 static jclass CreationError_class = NULL;
377 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
378 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
379 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
380 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
381 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
382 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
383         CreationError_class = (*env)->NewGlobalRef(env, clz);
384         CHECK(CreationError_class != NULL);
385         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
386         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
387         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
388         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
389         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
390         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
391         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
392         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
393         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
394         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
395 }
396 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
397         switch (val) {
398                 case LDKCreationError_DescriptionTooLong:
399                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
400                 case LDKCreationError_RouteTooLong:
401                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
402                 case LDKCreationError_TimestampOutOfBounds:
403                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
404                 case LDKCreationError_InvalidAmount:
405                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
406                 case LDKCreationError_MissingRouteHints:
407                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
408                 default: abort();
409         }
410 }
411
412 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
413         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
414         if (UNLIKELY((*env)->ExceptionCheck(env))) {
415                 (*env)->ExceptionDescribe(env);
416                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
417         }
418         switch (ord) {
419                 case 0: return LDKCurrency_Bitcoin;
420                 case 1: return LDKCurrency_BitcoinTestnet;
421                 case 2: return LDKCurrency_Regtest;
422                 case 3: return LDKCurrency_Simnet;
423                 case 4: return LDKCurrency_Signet;
424         }
425         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
426         abort(); // Unreachable, but will let the compiler know we don't return here
427 }
428 static jclass Currency_class = NULL;
429 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
430 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
431 static jfieldID Currency_LDKCurrency_Regtest = NULL;
432 static jfieldID Currency_LDKCurrency_Simnet = NULL;
433 static jfieldID Currency_LDKCurrency_Signet = NULL;
434 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
435         Currency_class = (*env)->NewGlobalRef(env, clz);
436         CHECK(Currency_class != NULL);
437         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
438         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
439         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
440         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
441         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
442         CHECK(Currency_LDKCurrency_Regtest != NULL);
443         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
444         CHECK(Currency_LDKCurrency_Simnet != NULL);
445         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
446         CHECK(Currency_LDKCurrency_Signet != NULL);
447 }
448 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
449         switch (val) {
450                 case LDKCurrency_Bitcoin:
451                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
452                 case LDKCurrency_BitcoinTestnet:
453                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
454                 case LDKCurrency_Regtest:
455                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
456                 case LDKCurrency_Simnet:
457                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
458                 case LDKCurrency_Signet:
459                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
460                 default: abort();
461         }
462 }
463
464 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
465         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
466         if (UNLIKELY((*env)->ExceptionCheck(env))) {
467                 (*env)->ExceptionDescribe(env);
468                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
469         }
470         switch (ord) {
471                 case 0: return LDKIOError_NotFound;
472                 case 1: return LDKIOError_PermissionDenied;
473                 case 2: return LDKIOError_ConnectionRefused;
474                 case 3: return LDKIOError_ConnectionReset;
475                 case 4: return LDKIOError_ConnectionAborted;
476                 case 5: return LDKIOError_NotConnected;
477                 case 6: return LDKIOError_AddrInUse;
478                 case 7: return LDKIOError_AddrNotAvailable;
479                 case 8: return LDKIOError_BrokenPipe;
480                 case 9: return LDKIOError_AlreadyExists;
481                 case 10: return LDKIOError_WouldBlock;
482                 case 11: return LDKIOError_InvalidInput;
483                 case 12: return LDKIOError_InvalidData;
484                 case 13: return LDKIOError_TimedOut;
485                 case 14: return LDKIOError_WriteZero;
486                 case 15: return LDKIOError_Interrupted;
487                 case 16: return LDKIOError_Other;
488                 case 17: return LDKIOError_UnexpectedEof;
489         }
490         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
491         abort(); // Unreachable, but will let the compiler know we don't return here
492 }
493 static jclass IOError_class = NULL;
494 static jfieldID IOError_LDKIOError_NotFound = NULL;
495 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
496 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
497 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
498 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
499 static jfieldID IOError_LDKIOError_NotConnected = NULL;
500 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
501 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
502 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
503 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
504 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
505 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
506 static jfieldID IOError_LDKIOError_InvalidData = NULL;
507 static jfieldID IOError_LDKIOError_TimedOut = NULL;
508 static jfieldID IOError_LDKIOError_WriteZero = NULL;
509 static jfieldID IOError_LDKIOError_Interrupted = NULL;
510 static jfieldID IOError_LDKIOError_Other = NULL;
511 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
512 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
513         IOError_class = (*env)->NewGlobalRef(env, clz);
514         CHECK(IOError_class != NULL);
515         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
516         CHECK(IOError_LDKIOError_NotFound != NULL);
517         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
518         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
519         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
520         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
521         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
522         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
523         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
524         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
525         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
526         CHECK(IOError_LDKIOError_NotConnected != NULL);
527         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
528         CHECK(IOError_LDKIOError_AddrInUse != NULL);
529         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
530         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
531         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
532         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
533         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
534         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
535         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
536         CHECK(IOError_LDKIOError_WouldBlock != NULL);
537         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
538         CHECK(IOError_LDKIOError_InvalidInput != NULL);
539         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
540         CHECK(IOError_LDKIOError_InvalidData != NULL);
541         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
542         CHECK(IOError_LDKIOError_TimedOut != NULL);
543         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
544         CHECK(IOError_LDKIOError_WriteZero != NULL);
545         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
546         CHECK(IOError_LDKIOError_Interrupted != NULL);
547         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
548         CHECK(IOError_LDKIOError_Other != NULL);
549         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
550         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
551 }
552 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
553         switch (val) {
554                 case LDKIOError_NotFound:
555                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
556                 case LDKIOError_PermissionDenied:
557                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
558                 case LDKIOError_ConnectionRefused:
559                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
560                 case LDKIOError_ConnectionReset:
561                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
562                 case LDKIOError_ConnectionAborted:
563                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
564                 case LDKIOError_NotConnected:
565                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
566                 case LDKIOError_AddrInUse:
567                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
568                 case LDKIOError_AddrNotAvailable:
569                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
570                 case LDKIOError_BrokenPipe:
571                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
572                 case LDKIOError_AlreadyExists:
573                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
574                 case LDKIOError_WouldBlock:
575                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
576                 case LDKIOError_InvalidInput:
577                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
578                 case LDKIOError_InvalidData:
579                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
580                 case LDKIOError_TimedOut:
581                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
582                 case LDKIOError_WriteZero:
583                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
584                 case LDKIOError_Interrupted:
585                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
586                 case LDKIOError_Other:
587                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
588                 case LDKIOError_UnexpectedEof:
589                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
590                 default: abort();
591         }
592 }
593
594 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
595         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
596         if (UNLIKELY((*env)->ExceptionCheck(env))) {
597                 (*env)->ExceptionDescribe(env);
598                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
599         }
600         switch (ord) {
601                 case 0: return LDKLevel_Gossip;
602                 case 1: return LDKLevel_Trace;
603                 case 2: return LDKLevel_Debug;
604                 case 3: return LDKLevel_Info;
605                 case 4: return LDKLevel_Warn;
606                 case 5: return LDKLevel_Error;
607         }
608         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
609         abort(); // Unreachable, but will let the compiler know we don't return here
610 }
611 static jclass Level_class = NULL;
612 static jfieldID Level_LDKLevel_Gossip = NULL;
613 static jfieldID Level_LDKLevel_Trace = NULL;
614 static jfieldID Level_LDKLevel_Debug = NULL;
615 static jfieldID Level_LDKLevel_Info = NULL;
616 static jfieldID Level_LDKLevel_Warn = NULL;
617 static jfieldID Level_LDKLevel_Error = NULL;
618 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
619         Level_class = (*env)->NewGlobalRef(env, clz);
620         CHECK(Level_class != NULL);
621         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
622         CHECK(Level_LDKLevel_Gossip != NULL);
623         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
624         CHECK(Level_LDKLevel_Trace != NULL);
625         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
626         CHECK(Level_LDKLevel_Debug != NULL);
627         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
628         CHECK(Level_LDKLevel_Info != NULL);
629         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
630         CHECK(Level_LDKLevel_Warn != NULL);
631         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
632         CHECK(Level_LDKLevel_Error != NULL);
633 }
634 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
635         switch (val) {
636                 case LDKLevel_Gossip:
637                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
638                 case LDKLevel_Trace:
639                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
640                 case LDKLevel_Debug:
641                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
642                 case LDKLevel_Info:
643                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
644                 case LDKLevel_Warn:
645                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
646                 case LDKLevel_Error:
647                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
648                 default: abort();
649         }
650 }
651
652 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
653         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
654         if (UNLIKELY((*env)->ExceptionCheck(env))) {
655                 (*env)->ExceptionDescribe(env);
656                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
657         }
658         switch (ord) {
659                 case 0: return LDKNetwork_Bitcoin;
660                 case 1: return LDKNetwork_Testnet;
661                 case 2: return LDKNetwork_Regtest;
662                 case 3: return LDKNetwork_Signet;
663         }
664         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
665         abort(); // Unreachable, but will let the compiler know we don't return here
666 }
667 static jclass Network_class = NULL;
668 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
669 static jfieldID Network_LDKNetwork_Testnet = NULL;
670 static jfieldID Network_LDKNetwork_Regtest = NULL;
671 static jfieldID Network_LDKNetwork_Signet = NULL;
672 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
673         Network_class = (*env)->NewGlobalRef(env, clz);
674         CHECK(Network_class != NULL);
675         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
676         CHECK(Network_LDKNetwork_Bitcoin != NULL);
677         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
678         CHECK(Network_LDKNetwork_Testnet != NULL);
679         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
680         CHECK(Network_LDKNetwork_Regtest != NULL);
681         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
682         CHECK(Network_LDKNetwork_Signet != NULL);
683 }
684 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
685         switch (val) {
686                 case LDKNetwork_Bitcoin:
687                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
688                 case LDKNetwork_Testnet:
689                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
690                 case LDKNetwork_Regtest:
691                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
692                 case LDKNetwork_Signet:
693                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
694                 default: abort();
695         }
696 }
697
698 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
699         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
701                 (*env)->ExceptionDescribe(env);
702                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
703         }
704         switch (ord) {
705                 case 0: return LDKRecipient_Node;
706                 case 1: return LDKRecipient_PhantomNode;
707         }
708         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
709         abort(); // Unreachable, but will let the compiler know we don't return here
710 }
711 static jclass Recipient_class = NULL;
712 static jfieldID Recipient_LDKRecipient_Node = NULL;
713 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
714 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
715         Recipient_class = (*env)->NewGlobalRef(env, clz);
716         CHECK(Recipient_class != NULL);
717         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
718         CHECK(Recipient_LDKRecipient_Node != NULL);
719         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
720         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
721 }
722 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
723         switch (val) {
724                 case LDKRecipient_Node:
725                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
726                 case LDKRecipient_PhantomNode:
727                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
728                 default: abort();
729         }
730 }
731
732 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
733         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
734         if (UNLIKELY((*env)->ExceptionCheck(env))) {
735                 (*env)->ExceptionDescribe(env);
736                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
737         }
738         switch (ord) {
739                 case 0: return LDKSecp256k1Error_IncorrectSignature;
740                 case 1: return LDKSecp256k1Error_InvalidMessage;
741                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
742                 case 3: return LDKSecp256k1Error_InvalidSignature;
743                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
744                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
745                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
746                 case 7: return LDKSecp256k1Error_InvalidTweak;
747                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
748                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
749                 case 10: return LDKSecp256k1Error_InvalidParityValue;
750         }
751         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
752         abort(); // Unreachable, but will let the compiler know we don't return here
753 }
754 static jclass Secp256k1Error_class = NULL;
755 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
756 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
757 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
758 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
759 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
760 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
761 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
762 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
763 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
764 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
765 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
766 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
767         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
768         CHECK(Secp256k1Error_class != NULL);
769         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
770         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
771         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
772         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
773         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
774         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
775         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
776         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
777         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
778         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
779         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
780         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
781         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
782         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
783         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
784         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
785         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
786         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
787         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
788         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
789         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
790         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
791 }
792 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
793         switch (val) {
794                 case LDKSecp256k1Error_IncorrectSignature:
795                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
796                 case LDKSecp256k1Error_InvalidMessage:
797                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
798                 case LDKSecp256k1Error_InvalidPublicKey:
799                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
800                 case LDKSecp256k1Error_InvalidSignature:
801                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
802                 case LDKSecp256k1Error_InvalidSecretKey:
803                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
804                 case LDKSecp256k1Error_InvalidSharedSecret:
805                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
806                 case LDKSecp256k1Error_InvalidRecoveryId:
807                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
808                 case LDKSecp256k1Error_InvalidTweak:
809                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
810                 case LDKSecp256k1Error_NotEnoughMemory:
811                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
812                 case LDKSecp256k1Error_InvalidPublicKeySum:
813                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
814                 case LDKSecp256k1Error_InvalidParityValue:
815                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
816                 default: abort();
817         }
818 }
819
820 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
821         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
822         if (UNLIKELY((*env)->ExceptionCheck(env))) {
823                 (*env)->ExceptionDescribe(env);
824                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
825         }
826         switch (ord) {
827                 case 0: return LDKSemanticError_NoPaymentHash;
828                 case 1: return LDKSemanticError_MultiplePaymentHashes;
829                 case 2: return LDKSemanticError_NoDescription;
830                 case 3: return LDKSemanticError_MultipleDescriptions;
831                 case 4: return LDKSemanticError_NoPaymentSecret;
832                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
833                 case 6: return LDKSemanticError_InvalidFeatures;
834                 case 7: return LDKSemanticError_InvalidRecoveryId;
835                 case 8: return LDKSemanticError_InvalidSignature;
836                 case 9: return LDKSemanticError_ImpreciseAmount;
837         }
838         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
839         abort(); // Unreachable, but will let the compiler know we don't return here
840 }
841 static jclass SemanticError_class = NULL;
842 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
843 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
844 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
845 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
846 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
847 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
848 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
849 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
850 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
851 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
852 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
853         SemanticError_class = (*env)->NewGlobalRef(env, clz);
854         CHECK(SemanticError_class != NULL);
855         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
856         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
857         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
858         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
859         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
860         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
861         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
862         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
863         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
864         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
865         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
866         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
867         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
868         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
869         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
870         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
871         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
872         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
873         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
874         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
875 }
876 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
877         switch (val) {
878                 case LDKSemanticError_NoPaymentHash:
879                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
880                 case LDKSemanticError_MultiplePaymentHashes:
881                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
882                 case LDKSemanticError_NoDescription:
883                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
884                 case LDKSemanticError_MultipleDescriptions:
885                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
886                 case LDKSemanticError_NoPaymentSecret:
887                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
888                 case LDKSemanticError_MultiplePaymentSecrets:
889                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
890                 case LDKSemanticError_InvalidFeatures:
891                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
892                 case LDKSemanticError_InvalidRecoveryId:
893                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
894                 case LDKSemanticError_InvalidSignature:
895                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
896                 case LDKSemanticError_ImpreciseAmount:
897                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
898                 default: abort();
899         }
900 }
901
902 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
903         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
904         if (UNLIKELY((*env)->ExceptionCheck(env))) {
905                 (*env)->ExceptionDescribe(env);
906                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
907         }
908         switch (ord) {
909                 case 0: return LDKSiPrefix_Milli;
910                 case 1: return LDKSiPrefix_Micro;
911                 case 2: return LDKSiPrefix_Nano;
912                 case 3: return LDKSiPrefix_Pico;
913         }
914         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
915         abort(); // Unreachable, but will let the compiler know we don't return here
916 }
917 static jclass SiPrefix_class = NULL;
918 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
919 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
920 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
921 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
922 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
923         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
924         CHECK(SiPrefix_class != NULL);
925         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
926         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
927         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
928         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
929         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
930         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
931         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
932         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
933 }
934 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
935         switch (val) {
936                 case LDKSiPrefix_Milli:
937                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
938                 case LDKSiPrefix_Micro:
939                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
940                 case LDKSiPrefix_Nano:
941                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
942                 case LDKSiPrefix_Pico:
943                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
944                 default: abort();
945         }
946 }
947
948 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
949         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
950         return ret;
951 }
952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
953         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
954         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
956         return ret_arr;
957 }
958
959 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
961         if (!ptr_is_owned(thing)) return;
962         void* thing_ptr = untag_ptr(thing);
963         CHECK_ACCESS(thing_ptr);
964         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
965         FREE(untag_ptr(thing));
966         BigEndianScalar_free(thing_conv);
967 }
968
969 static jclass LDKBech32Error_MissingSeparator_class = NULL;
970 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
971 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
972 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
973 static jclass LDKBech32Error_InvalidLength_class = NULL;
974 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
975 static jclass LDKBech32Error_InvalidChar_class = NULL;
976 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
977 static jclass LDKBech32Error_InvalidData_class = NULL;
978 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
979 static jclass LDKBech32Error_InvalidPadding_class = NULL;
980 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
981 static jclass LDKBech32Error_MixedCase_class = NULL;
982 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
984         LDKBech32Error_MissingSeparator_class =
985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
986         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
987         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
988         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
989         LDKBech32Error_InvalidChecksum_class =
990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
991         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
992         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
993         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
994         LDKBech32Error_InvalidLength_class =
995                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
996         CHECK(LDKBech32Error_InvalidLength_class != NULL);
997         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
998         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
999         LDKBech32Error_InvalidChar_class =
1000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
1001         CHECK(LDKBech32Error_InvalidChar_class != NULL);
1002         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
1003         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1004         LDKBech32Error_InvalidData_class =
1005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1006         CHECK(LDKBech32Error_InvalidData_class != NULL);
1007         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1008         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1009         LDKBech32Error_InvalidPadding_class =
1010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1011         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1012         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1013         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1014         LDKBech32Error_MixedCase_class =
1015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1016         CHECK(LDKBech32Error_MixedCase_class != NULL);
1017         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1018         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1019 }
1020 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1021         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1022         switch(obj->tag) {
1023                 case LDKBech32Error_MissingSeparator: {
1024                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1025                 }
1026                 case LDKBech32Error_InvalidChecksum: {
1027                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1028                 }
1029                 case LDKBech32Error_InvalidLength: {
1030                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1031                 }
1032                 case LDKBech32Error_InvalidChar: {
1033                         int32_t invalid_char_conv = obj->invalid_char;
1034                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1035                 }
1036                 case LDKBech32Error_InvalidData: {
1037                         int8_t invalid_data_conv = obj->invalid_data;
1038                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1039                 }
1040                 case LDKBech32Error_InvalidPadding: {
1041                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1042                 }
1043                 case LDKBech32Error_MixedCase: {
1044                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1045                 }
1046                 default: abort();
1047         }
1048 }
1049 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1050         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1051         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1052         return ret;
1053 }
1054 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
1055         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1056         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1057         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1058         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1059         CVec_u8Z_free(ret_var);
1060         return ret_arr;
1061 }
1062
1063 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
1064         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1065         int64_t ret_conv = TxOut_get_value(thing_conv);
1066         return ret_conv;
1067 }
1068
1069 static inline struct LDKBlindedRoute CResult_BlindedRouteNoneZ_get_ok(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1070         LDKBlindedRoute ret = *owner->contents.result;
1071         ret.is_owned = false;
1072         return ret;
1073 }
1074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1075         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1076         LDKBlindedRoute ret_var = CResult_BlindedRouteNoneZ_get_ok(owner_conv);
1077         int64_t ret_ref = 0;
1078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1080         return ret_ref;
1081 }
1082
1083 static inline void CResult_BlindedRouteNoneZ_get_err(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1084 CHECK(!owner->result_ok);
1085         return *owner->contents.err;
1086 }
1087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1088         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1089         CResult_BlindedRouteNoneZ_get_err(owner_conv);
1090 }
1091
1092 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1093 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1094 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1095 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1096 static jclass LDKDecodeError_InvalidValue_class = NULL;
1097 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1098 static jclass LDKDecodeError_ShortRead_class = NULL;
1099 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1100 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1101 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1102 static jclass LDKDecodeError_Io_class = NULL;
1103 static jmethodID LDKDecodeError_Io_meth = NULL;
1104 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1105 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1107         LDKDecodeError_UnknownVersion_class =
1108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1109         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1110         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1111         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1112         LDKDecodeError_UnknownRequiredFeature_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1114         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1115         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1116         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1117         LDKDecodeError_InvalidValue_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1119         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1120         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1121         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1122         LDKDecodeError_ShortRead_class =
1123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1124         CHECK(LDKDecodeError_ShortRead_class != NULL);
1125         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1126         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1127         LDKDecodeError_BadLengthDescriptor_class =
1128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1129         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1130         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1131         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1132         LDKDecodeError_Io_class =
1133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1134         CHECK(LDKDecodeError_Io_class != NULL);
1135         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1136         CHECK(LDKDecodeError_Io_meth != NULL);
1137         LDKDecodeError_UnsupportedCompression_class =
1138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1139         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1140         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1141         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1142 }
1143 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1144         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1145         switch(obj->tag) {
1146                 case LDKDecodeError_UnknownVersion: {
1147                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1148                 }
1149                 case LDKDecodeError_UnknownRequiredFeature: {
1150                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1151                 }
1152                 case LDKDecodeError_InvalidValue: {
1153                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1154                 }
1155                 case LDKDecodeError_ShortRead: {
1156                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1157                 }
1158                 case LDKDecodeError_BadLengthDescriptor: {
1159                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1160                 }
1161                 case LDKDecodeError_Io: {
1162                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1163                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1164                 }
1165                 case LDKDecodeError_UnsupportedCompression: {
1166                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1167                 }
1168                 default: abort();
1169         }
1170 }
1171 static inline struct LDKBlindedRoute CResult_BlindedRouteDecodeErrorZ_get_ok(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1172         LDKBlindedRoute ret = *owner->contents.result;
1173         ret.is_owned = false;
1174         return ret;
1175 }
1176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1177         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1178         LDKBlindedRoute ret_var = CResult_BlindedRouteDecodeErrorZ_get_ok(owner_conv);
1179         int64_t ret_ref = 0;
1180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1182         return ret_ref;
1183 }
1184
1185 static inline struct LDKDecodeError CResult_BlindedRouteDecodeErrorZ_get_err(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1186 CHECK(!owner->result_ok);
1187         return DecodeError_clone(&*owner->contents.err);
1188 }
1189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1190         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1191         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1192         *ret_copy = CResult_BlindedRouteDecodeErrorZ_get_err(owner_conv);
1193         int64_t ret_ref = tag_ptr(ret_copy, true);
1194         return ret_ref;
1195 }
1196
1197 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1198         LDKBlindedHop ret = *owner->contents.result;
1199         ret.is_owned = false;
1200         return ret;
1201 }
1202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1203         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1204         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
1205         int64_t ret_ref = 0;
1206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1208         return ret_ref;
1209 }
1210
1211 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1212 CHECK(!owner->result_ok);
1213         return DecodeError_clone(&*owner->contents.err);
1214 }
1215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1216         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1217         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1218         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1219         int64_t ret_ref = tag_ptr(ret_copy, true);
1220         return ret_ref;
1221 }
1222
1223 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1224 CHECK(owner->result_ok);
1225         return *owner->contents.result;
1226 }
1227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1228         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1229         CResult_NoneNoneZ_get_ok(owner_conv);
1230 }
1231
1232 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1233 CHECK(!owner->result_ok);
1234         return *owner->contents.err;
1235 }
1236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1237         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1238         CResult_NoneNoneZ_get_err(owner_conv);
1239 }
1240
1241 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1242         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1243         ret.is_owned = false;
1244         return ret;
1245 }
1246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1247         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1248         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1249         int64_t ret_ref = 0;
1250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1251         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1252         return ret_ref;
1253 }
1254
1255 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1256 CHECK(!owner->result_ok);
1257         return DecodeError_clone(&*owner->contents.err);
1258 }
1259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1260         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1261         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1262         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1263         int64_t ret_ref = tag_ptr(ret_copy, true);
1264         return ret_ref;
1265 }
1266
1267 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1268 CHECK(owner->result_ok);
1269         return *owner->contents.result;
1270 }
1271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1272         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1273         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1274         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1275         return ret_arr;
1276 }
1277
1278 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1279 CHECK(!owner->result_ok);
1280         return *owner->contents.err;
1281 }
1282 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1283         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1284         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1285         return ret_conv;
1286 }
1287
1288 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1289 CHECK(owner->result_ok);
1290         return *owner->contents.result;
1291 }
1292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1293         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1294         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1295         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1296         return ret_arr;
1297 }
1298
1299 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1300 CHECK(!owner->result_ok);
1301         return *owner->contents.err;
1302 }
1303 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1304         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1305         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1306         return ret_conv;
1307 }
1308
1309 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1310         LDKTxCreationKeys ret = *owner->contents.result;
1311         ret.is_owned = false;
1312         return ret;
1313 }
1314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1315         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1316         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1317         int64_t ret_ref = 0;
1318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1320         return ret_ref;
1321 }
1322
1323 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1324 CHECK(!owner->result_ok);
1325         return DecodeError_clone(&*owner->contents.err);
1326 }
1327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1328         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1329         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1330         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1331         int64_t ret_ref = tag_ptr(ret_copy, true);
1332         return ret_ref;
1333 }
1334
1335 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1336         LDKChannelPublicKeys ret = *owner->contents.result;
1337         ret.is_owned = false;
1338         return ret;
1339 }
1340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1341         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1342         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1343         int64_t ret_ref = 0;
1344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1346         return ret_ref;
1347 }
1348
1349 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1350 CHECK(!owner->result_ok);
1351         return DecodeError_clone(&*owner->contents.err);
1352 }
1353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1354         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1355         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1356         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1357         int64_t ret_ref = tag_ptr(ret_copy, true);
1358         return ret_ref;
1359 }
1360
1361 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1362         LDKTxCreationKeys ret = *owner->contents.result;
1363         ret.is_owned = false;
1364         return ret;
1365 }
1366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1367         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1368         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1369         int64_t ret_ref = 0;
1370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1372         return ret_ref;
1373 }
1374
1375 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return *owner->contents.err;
1378 }
1379 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1381         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1382         return ret_conv;
1383 }
1384
1385 static jclass LDKCOption_u32Z_Some_class = NULL;
1386 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1387 static jclass LDKCOption_u32Z_None_class = NULL;
1388 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1390         LDKCOption_u32Z_Some_class =
1391                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1392         CHECK(LDKCOption_u32Z_Some_class != NULL);
1393         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1394         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1395         LDKCOption_u32Z_None_class =
1396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1397         CHECK(LDKCOption_u32Z_None_class != NULL);
1398         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1399         CHECK(LDKCOption_u32Z_None_meth != NULL);
1400 }
1401 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1402         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1403         switch(obj->tag) {
1404                 case LDKCOption_u32Z_Some: {
1405                         int32_t some_conv = obj->some;
1406                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1407                 }
1408                 case LDKCOption_u32Z_None: {
1409                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1410                 }
1411                 default: abort();
1412         }
1413 }
1414 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1415         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1416         ret.is_owned = false;
1417         return ret;
1418 }
1419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1420         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1421         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1422         int64_t ret_ref = 0;
1423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1425         return ret_ref;
1426 }
1427
1428 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1429 CHECK(!owner->result_ok);
1430         return DecodeError_clone(&*owner->contents.err);
1431 }
1432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1433         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1434         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1435         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1436         int64_t ret_ref = tag_ptr(ret_copy, true);
1437         return ret_ref;
1438 }
1439
1440 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1441         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1442         ret.is_owned = false;
1443         return ret;
1444 }
1445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1446         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1447         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1448         int64_t ret_ref = 0;
1449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1451         return ret_ref;
1452 }
1453
1454 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1455 CHECK(!owner->result_ok);
1456         return DecodeError_clone(&*owner->contents.err);
1457 }
1458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1459         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1460         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1461         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1462         int64_t ret_ref = tag_ptr(ret_copy, true);
1463         return ret_ref;
1464 }
1465
1466 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1467         LDKChannelTransactionParameters ret = *owner->contents.result;
1468         ret.is_owned = false;
1469         return ret;
1470 }
1471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1472         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1473         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1474         int64_t ret_ref = 0;
1475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1477         return ret_ref;
1478 }
1479
1480 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1481 CHECK(!owner->result_ok);
1482         return DecodeError_clone(&*owner->contents.err);
1483 }
1484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1485         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1486         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1487         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1488         int64_t ret_ref = tag_ptr(ret_copy, true);
1489         return ret_ref;
1490 }
1491
1492 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1493         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1494         ret.is_owned = false;
1495         return ret;
1496 }
1497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1498         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1499         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1500         int64_t ret_ref = 0;
1501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1503         return ret_ref;
1504 }
1505
1506 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1507 CHECK(!owner->result_ok);
1508         return DecodeError_clone(&*owner->contents.err);
1509 }
1510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1511         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1512         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1513         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1514         int64_t ret_ref = tag_ptr(ret_copy, true);
1515         return ret_ref;
1516 }
1517
1518 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1519         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1520         ret.is_owned = false;
1521         return ret;
1522 }
1523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1524         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1525         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1526         int64_t ret_ref = 0;
1527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1529         return ret_ref;
1530 }
1531
1532 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1533 CHECK(!owner->result_ok);
1534         return DecodeError_clone(&*owner->contents.err);
1535 }
1536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1537         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1538         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1539         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1540         int64_t ret_ref = tag_ptr(ret_copy, true);
1541         return ret_ref;
1542 }
1543
1544 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1545         LDKTrustedClosingTransaction ret = *owner->contents.result;
1546         ret.is_owned = false;
1547         return ret;
1548 }
1549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1550         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1551         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1552         int64_t ret_ref = 0;
1553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1555         return ret_ref;
1556 }
1557
1558 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1559 CHECK(!owner->result_ok);
1560         return *owner->contents.err;
1561 }
1562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1563         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1564         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1565 }
1566
1567 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1568         LDKCommitmentTransaction ret = *owner->contents.result;
1569         ret.is_owned = false;
1570         return ret;
1571 }
1572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1573         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1574         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1575         int64_t ret_ref = 0;
1576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1578         return ret_ref;
1579 }
1580
1581 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1582 CHECK(!owner->result_ok);
1583         return DecodeError_clone(&*owner->contents.err);
1584 }
1585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1586         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1587         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1588         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1589         int64_t ret_ref = tag_ptr(ret_copy, true);
1590         return ret_ref;
1591 }
1592
1593 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1594         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1595         ret.is_owned = false;
1596         return ret;
1597 }
1598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1599         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1600         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1601         int64_t ret_ref = 0;
1602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1604         return ret_ref;
1605 }
1606
1607 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1608 CHECK(!owner->result_ok);
1609         return *owner->contents.err;
1610 }
1611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1612         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1613         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1614 }
1615
1616 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1617 CHECK(owner->result_ok);
1618         return *owner->contents.result;
1619 }
1620 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1621         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1622         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1623         jobjectArray ret_arr = NULL;
1624         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1625         ;
1626         for (size_t i = 0; i < ret_var.datalen; i++) {
1627                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1628                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1629                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1630         }
1631         
1632         return ret_arr;
1633 }
1634
1635 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1636 CHECK(!owner->result_ok);
1637         return *owner->contents.err;
1638 }
1639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1640         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1641         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1642 }
1643
1644 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1645         LDKShutdownScript ret = *owner->contents.result;
1646         ret.is_owned = false;
1647         return ret;
1648 }
1649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1650         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1651         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1652         int64_t ret_ref = 0;
1653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1655         return ret_ref;
1656 }
1657
1658 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1659 CHECK(!owner->result_ok);
1660         return DecodeError_clone(&*owner->contents.err);
1661 }
1662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1663         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1664         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1665         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1666         int64_t ret_ref = tag_ptr(ret_copy, true);
1667         return ret_ref;
1668 }
1669
1670 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1671         LDKShutdownScript ret = *owner->contents.result;
1672         ret.is_owned = false;
1673         return ret;
1674 }
1675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1676         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1677         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1678         int64_t ret_ref = 0;
1679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1681         return ret_ref;
1682 }
1683
1684 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1685         LDKInvalidShutdownScript ret = *owner->contents.err;
1686         ret.is_owned = false;
1687         return ret;
1688 }
1689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1690         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1691         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1692         int64_t ret_ref = 0;
1693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1694         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1695         return ret_ref;
1696 }
1697
1698 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1699         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1700         for (size_t i = 0; i < ret.datalen; i++) {
1701                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1702         }
1703         return ret;
1704 }
1705 typedef struct LDKScore_JCalls {
1706         atomic_size_t refcnt;
1707         JavaVM *vm;
1708         jweak o;
1709         jmethodID channel_penalty_msat_meth;
1710         jmethodID payment_path_failed_meth;
1711         jmethodID payment_path_successful_meth;
1712         jmethodID probe_failed_meth;
1713         jmethodID probe_successful_meth;
1714         jmethodID write_meth;
1715 } LDKScore_JCalls;
1716 static void LDKScore_JCalls_free(void* this_arg) {
1717         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1719                 JNIEnv *env;
1720                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1721                 if (get_jenv_res == JNI_EDETACHED) {
1722                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1723                 } else {
1724                         DO_ASSERT(get_jenv_res == JNI_OK);
1725                 }
1726                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1727                 if (get_jenv_res == JNI_EDETACHED) {
1728                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1729                 }
1730                 FREE(j_calls);
1731         }
1732 }
1733 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1734         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1735         JNIEnv *env;
1736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1737         if (get_jenv_res == JNI_EDETACHED) {
1738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1739         } else {
1740                 DO_ASSERT(get_jenv_res == JNI_OK);
1741         }
1742         int64_t short_channel_id_conv = short_channel_id;
1743         LDKNodeId source_var = *source;
1744         int64_t source_ref = 0;
1745         source_var = NodeId_clone(&source_var);
1746         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1747         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1748         LDKNodeId target_var = *target;
1749         int64_t target_ref = 0;
1750         target_var = NodeId_clone(&target_var);
1751         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1752         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1753         LDKChannelUsage usage_var = usage;
1754         int64_t usage_ref = 0;
1755         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1756         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1757         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1758         CHECK(obj != NULL);
1759         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1760         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1761                 (*env)->ExceptionDescribe(env);
1762                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1763         }
1764         if (get_jenv_res == JNI_EDETACHED) {
1765                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1766         }
1767         return ret;
1768 }
1769 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1770         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1771         JNIEnv *env;
1772         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1773         if (get_jenv_res == JNI_EDETACHED) {
1774                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1775         } else {
1776                 DO_ASSERT(get_jenv_res == JNI_OK);
1777         }
1778         LDKCVec_RouteHopZ path_var = path;
1779         int64_tArray path_arr = NULL;
1780         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1781         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1782         for (size_t k = 0; k < path_var.datalen; k++) {
1783                 LDKRouteHop path_conv_10_var = path_var.data[k];
1784                 int64_t path_conv_10_ref = 0;
1785                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1786                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1787                 path_arr_ptr[k] = path_conv_10_ref;
1788         }
1789         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1790         FREE(path_var.data);
1791         int64_t short_channel_id_conv = short_channel_id;
1792         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1793         CHECK(obj != NULL);
1794         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1795         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1796                 (*env)->ExceptionDescribe(env);
1797                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1798         }
1799         if (get_jenv_res == JNI_EDETACHED) {
1800                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1801         }
1802 }
1803 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1804         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1805         JNIEnv *env;
1806         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1807         if (get_jenv_res == JNI_EDETACHED) {
1808                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1809         } else {
1810                 DO_ASSERT(get_jenv_res == JNI_OK);
1811         }
1812         LDKCVec_RouteHopZ path_var = path;
1813         int64_tArray path_arr = NULL;
1814         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1815         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1816         for (size_t k = 0; k < path_var.datalen; k++) {
1817                 LDKRouteHop path_conv_10_var = path_var.data[k];
1818                 int64_t path_conv_10_ref = 0;
1819                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1820                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1821                 path_arr_ptr[k] = path_conv_10_ref;
1822         }
1823         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1824         FREE(path_var.data);
1825         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1826         CHECK(obj != NULL);
1827         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1828         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1829                 (*env)->ExceptionDescribe(env);
1830                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1831         }
1832         if (get_jenv_res == JNI_EDETACHED) {
1833                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1834         }
1835 }
1836 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1837         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1838         JNIEnv *env;
1839         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1840         if (get_jenv_res == JNI_EDETACHED) {
1841                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1842         } else {
1843                 DO_ASSERT(get_jenv_res == JNI_OK);
1844         }
1845         LDKCVec_RouteHopZ path_var = path;
1846         int64_tArray path_arr = NULL;
1847         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1848         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1849         for (size_t k = 0; k < path_var.datalen; k++) {
1850                 LDKRouteHop path_conv_10_var = path_var.data[k];
1851                 int64_t path_conv_10_ref = 0;
1852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1853                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1854                 path_arr_ptr[k] = path_conv_10_ref;
1855         }
1856         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1857         FREE(path_var.data);
1858         int64_t short_channel_id_conv = short_channel_id;
1859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1860         CHECK(obj != NULL);
1861         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
1862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1863                 (*env)->ExceptionDescribe(env);
1864                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
1865         }
1866         if (get_jenv_res == JNI_EDETACHED) {
1867                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1868         }
1869 }
1870 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1871         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1872         JNIEnv *env;
1873         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1874         if (get_jenv_res == JNI_EDETACHED) {
1875                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1876         } else {
1877                 DO_ASSERT(get_jenv_res == JNI_OK);
1878         }
1879         LDKCVec_RouteHopZ path_var = path;
1880         int64_tArray path_arr = NULL;
1881         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1882         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1883         for (size_t k = 0; k < path_var.datalen; k++) {
1884                 LDKRouteHop path_conv_10_var = path_var.data[k];
1885                 int64_t path_conv_10_ref = 0;
1886                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1887                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1888                 path_arr_ptr[k] = path_conv_10_ref;
1889         }
1890         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1891         FREE(path_var.data);
1892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1893         CHECK(obj != NULL);
1894         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
1895         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1896                 (*env)->ExceptionDescribe(env);
1897                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
1898         }
1899         if (get_jenv_res == JNI_EDETACHED) {
1900                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1901         }
1902 }
1903 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
1904         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1905         JNIEnv *env;
1906         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1907         if (get_jenv_res == JNI_EDETACHED) {
1908                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1909         } else {
1910                 DO_ASSERT(get_jenv_res == JNI_OK);
1911         }
1912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1913         CHECK(obj != NULL);
1914         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1915         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1916                 (*env)->ExceptionDescribe(env);
1917                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
1918         }
1919         LDKCVec_u8Z ret_ref;
1920         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1921         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1922         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1923         if (get_jenv_res == JNI_EDETACHED) {
1924                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1925         }
1926         return ret_ref;
1927 }
1928 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
1929         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
1930         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1931 }
1932 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
1933         jclass c = (*env)->GetObjectClass(env, o);
1934         CHECK(c != NULL);
1935         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
1936         atomic_init(&calls->refcnt, 1);
1937         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1938         calls->o = (*env)->NewWeakGlobalRef(env, o);
1939         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
1940         CHECK(calls->channel_penalty_msat_meth != NULL);
1941         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
1942         CHECK(calls->payment_path_failed_meth != NULL);
1943         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
1944         CHECK(calls->payment_path_successful_meth != NULL);
1945         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
1946         CHECK(calls->probe_failed_meth != NULL);
1947         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
1948         CHECK(calls->probe_successful_meth != NULL);
1949         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1950         CHECK(calls->write_meth != NULL);
1951
1952         LDKScore ret = {
1953                 .this_arg = (void*) calls,
1954                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
1955                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
1956                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
1957                 .probe_failed = probe_failed_LDKScore_jcall,
1958                 .probe_successful = probe_successful_LDKScore_jcall,
1959                 .write = write_LDKScore_jcall,
1960                 .free = LDKScore_JCalls_free,
1961         };
1962         return ret;
1963 }
1964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
1965         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
1966         *res_ptr = LDKScore_init(env, clz, o);
1967         return tag_ptr(res_ptr, true);
1968 }
1969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage) {
1970         void* this_arg_ptr = untag_ptr(this_arg);
1971         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1972         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1973         LDKNodeId source_conv;
1974         source_conv.inner = untag_ptr(source);
1975         source_conv.is_owned = ptr_is_owned(source);
1976         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
1977         source_conv.is_owned = false;
1978         LDKNodeId target_conv;
1979         target_conv.inner = untag_ptr(target);
1980         target_conv.is_owned = ptr_is_owned(target);
1981         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
1982         target_conv.is_owned = false;
1983         LDKChannelUsage usage_conv;
1984         usage_conv.inner = untag_ptr(usage);
1985         usage_conv.is_owned = ptr_is_owned(usage);
1986         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
1987         usage_conv = ChannelUsage_clone(&usage_conv);
1988         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
1989         return ret_conv;
1990 }
1991
1992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
1993         void* this_arg_ptr = untag_ptr(this_arg);
1994         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1995         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1996         LDKCVec_RouteHopZ path_constr;
1997         path_constr.datalen = (*env)->GetArrayLength(env, path);
1998         if (path_constr.datalen > 0)
1999                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2000         else
2001                 path_constr.data = NULL;
2002         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2003         for (size_t k = 0; k < path_constr.datalen; k++) {
2004                 int64_t path_conv_10 = path_vals[k];
2005                 LDKRouteHop path_conv_10_conv;
2006                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2007                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2008                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2009                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2010                 path_constr.data[k] = path_conv_10_conv;
2011         }
2012         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2013         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2014 }
2015
2016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2017         void* this_arg_ptr = untag_ptr(this_arg);
2018         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2019         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2020         LDKCVec_RouteHopZ path_constr;
2021         path_constr.datalen = (*env)->GetArrayLength(env, path);
2022         if (path_constr.datalen > 0)
2023                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2024         else
2025                 path_constr.data = NULL;
2026         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2027         for (size_t k = 0; k < path_constr.datalen; k++) {
2028                 int64_t path_conv_10 = path_vals[k];
2029                 LDKRouteHop path_conv_10_conv;
2030                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2031                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2032                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2033                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2034                 path_constr.data[k] = path_conv_10_conv;
2035         }
2036         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2037         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
2038 }
2039
2040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
2041         void* this_arg_ptr = untag_ptr(this_arg);
2042         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2043         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2044         LDKCVec_RouteHopZ path_constr;
2045         path_constr.datalen = (*env)->GetArrayLength(env, path);
2046         if (path_constr.datalen > 0)
2047                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2048         else
2049                 path_constr.data = NULL;
2050         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2051         for (size_t k = 0; k < path_constr.datalen; k++) {
2052                 int64_t path_conv_10 = path_vals[k];
2053                 LDKRouteHop path_conv_10_conv;
2054                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2055                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2056                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2057                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2058                 path_constr.data[k] = path_conv_10_conv;
2059         }
2060         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2061         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2062 }
2063
2064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2065         void* this_arg_ptr = untag_ptr(this_arg);
2066         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2067         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2068         LDKCVec_RouteHopZ path_constr;
2069         path_constr.datalen = (*env)->GetArrayLength(env, path);
2070         if (path_constr.datalen > 0)
2071                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2072         else
2073                 path_constr.data = NULL;
2074         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2075         for (size_t k = 0; k < path_constr.datalen; k++) {
2076                 int64_t path_conv_10 = path_vals[k];
2077                 LDKRouteHop path_conv_10_conv;
2078                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2079                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2080                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2081                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2082                 path_constr.data[k] = path_conv_10_conv;
2083         }
2084         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2085         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2086 }
2087
2088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2089         void* this_arg_ptr = untag_ptr(this_arg);
2090         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2091         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2092         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2095         CVec_u8Z_free(ret_var);
2096         return ret_arr;
2097 }
2098
2099 typedef struct LDKLockableScore_JCalls {
2100         atomic_size_t refcnt;
2101         JavaVM *vm;
2102         jweak o;
2103         jmethodID lock_meth;
2104 } LDKLockableScore_JCalls;
2105 static void LDKLockableScore_JCalls_free(void* this_arg) {
2106         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2107         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2108                 JNIEnv *env;
2109                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2110                 if (get_jenv_res == JNI_EDETACHED) {
2111                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2112                 } else {
2113                         DO_ASSERT(get_jenv_res == JNI_OK);
2114                 }
2115                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2116                 if (get_jenv_res == JNI_EDETACHED) {
2117                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2118                 }
2119                 FREE(j_calls);
2120         }
2121 }
2122 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2123         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2124         JNIEnv *env;
2125         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2126         if (get_jenv_res == JNI_EDETACHED) {
2127                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2128         } else {
2129                 DO_ASSERT(get_jenv_res == JNI_OK);
2130         }
2131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2132         CHECK(obj != NULL);
2133         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2134         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2135                 (*env)->ExceptionDescribe(env);
2136                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2137         }
2138         void* ret_ptr = untag_ptr(ret);
2139         CHECK_ACCESS(ret_ptr);
2140         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2141         if (ret_conv.free == LDKScore_JCalls_free) {
2142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2143                 LDKScore_JCalls_cloned(&ret_conv);
2144         }// WARNING: we may need a move here but no clone is available for LDKScore
2145         
2146         if (get_jenv_res == JNI_EDETACHED) {
2147                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2148         }
2149         return ret_conv;
2150 }
2151 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2152         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2153         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2154 }
2155 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2156         jclass c = (*env)->GetObjectClass(env, o);
2157         CHECK(c != NULL);
2158         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2159         atomic_init(&calls->refcnt, 1);
2160         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2161         calls->o = (*env)->NewWeakGlobalRef(env, o);
2162         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2163         CHECK(calls->lock_meth != NULL);
2164
2165         LDKLockableScore ret = {
2166                 .this_arg = (void*) calls,
2167                 .lock = lock_LDKLockableScore_jcall,
2168                 .free = LDKLockableScore_JCalls_free,
2169         };
2170         return ret;
2171 }
2172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2173         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2174         *res_ptr = LDKLockableScore_init(env, clz, o);
2175         return tag_ptr(res_ptr, true);
2176 }
2177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2178         void* this_arg_ptr = untag_ptr(this_arg);
2179         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2180         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2181         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2182         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2183         return tag_ptr(ret_ret, true);
2184 }
2185
2186 typedef struct LDKWriteableScore_JCalls {
2187         atomic_size_t refcnt;
2188         JavaVM *vm;
2189         jweak o;
2190         LDKLockableScore_JCalls* LockableScore;
2191         jmethodID write_meth;
2192 } LDKWriteableScore_JCalls;
2193 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2194         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2195         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2196                 JNIEnv *env;
2197                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2198                 if (get_jenv_res == JNI_EDETACHED) {
2199                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2200                 } else {
2201                         DO_ASSERT(get_jenv_res == JNI_OK);
2202                 }
2203                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2204                 if (get_jenv_res == JNI_EDETACHED) {
2205                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2206                 }
2207                 FREE(j_calls);
2208         }
2209 }
2210 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2211         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2212         JNIEnv *env;
2213         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2214         if (get_jenv_res == JNI_EDETACHED) {
2215                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2216         } else {
2217                 DO_ASSERT(get_jenv_res == JNI_OK);
2218         }
2219         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2220         CHECK(obj != NULL);
2221         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2222         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2223                 (*env)->ExceptionDescribe(env);
2224                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2225         }
2226         LDKCVec_u8Z ret_ref;
2227         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2228         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2229         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2230         if (get_jenv_res == JNI_EDETACHED) {
2231                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2232         }
2233         return ret_ref;
2234 }
2235 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2236         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2237         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2238         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2239 }
2240 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2241         jclass c = (*env)->GetObjectClass(env, o);
2242         CHECK(c != NULL);
2243         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2244         atomic_init(&calls->refcnt, 1);
2245         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2246         calls->o = (*env)->NewWeakGlobalRef(env, o);
2247         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2248         CHECK(calls->write_meth != NULL);
2249
2250         LDKWriteableScore ret = {
2251                 .this_arg = (void*) calls,
2252                 .write = write_LDKWriteableScore_jcall,
2253                 .free = LDKWriteableScore_JCalls_free,
2254                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2255         };
2256         calls->LockableScore = ret.LockableScore.this_arg;
2257         return ret;
2258 }
2259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2260         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2261         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2262         return tag_ptr(res_ptr, true);
2263 }
2264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2265         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2266         return tag_ptr(&inp->LockableScore, false);
2267 }
2268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2269         void* this_arg_ptr = untag_ptr(this_arg);
2270         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2271         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2272         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2275         CVec_u8Z_free(ret_var);
2276         return ret_arr;
2277 }
2278
2279 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2280 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2281 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2282 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2284         LDKCOption_WriteableScoreZ_Some_class =
2285                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2286         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2287         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2288         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2289         LDKCOption_WriteableScoreZ_None_class =
2290                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2291         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2292         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2293         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2294 }
2295 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2296         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2297         switch(obj->tag) {
2298                 case LDKCOption_WriteableScoreZ_Some: {
2299                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2300                         *some_ret = obj->some;
2301                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2302                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2303                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2304                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2305                         }
2306                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2307                 }
2308                 case LDKCOption_WriteableScoreZ_None: {
2309                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2310                 }
2311                 default: abort();
2312         }
2313 }
2314 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2315 CHECK(owner->result_ok);
2316         return *owner->contents.result;
2317 }
2318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2319         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2320         CResult_NoneErrorZ_get_ok(owner_conv);
2321 }
2322
2323 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2324 CHECK(!owner->result_ok);
2325         return *owner->contents.err;
2326 }
2327 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2328         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2329         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2330         return ret_conv;
2331 }
2332
2333 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2334         LDKRouteHop ret = *owner->contents.result;
2335         ret.is_owned = false;
2336         return ret;
2337 }
2338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2339         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2340         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2341         int64_t ret_ref = 0;
2342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2344         return ret_ref;
2345 }
2346
2347 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2348 CHECK(!owner->result_ok);
2349         return DecodeError_clone(&*owner->contents.err);
2350 }
2351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2352         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2353         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2354         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2355         int64_t ret_ref = tag_ptr(ret_copy, true);
2356         return ret_ref;
2357 }
2358
2359 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2360         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2361         for (size_t i = 0; i < ret.datalen; i++) {
2362                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2363         }
2364         return ret;
2365 }
2366 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2367         LDKRoute ret = *owner->contents.result;
2368         ret.is_owned = false;
2369         return ret;
2370 }
2371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2372         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2373         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2374         int64_t ret_ref = 0;
2375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2376         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2377         return ret_ref;
2378 }
2379
2380 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2381 CHECK(!owner->result_ok);
2382         return DecodeError_clone(&*owner->contents.err);
2383 }
2384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2385         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2386         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2387         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2388         int64_t ret_ref = tag_ptr(ret_copy, true);
2389         return ret_ref;
2390 }
2391
2392 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2393         LDKRouteParameters ret = *owner->contents.result;
2394         ret.is_owned = false;
2395         return ret;
2396 }
2397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2398         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2399         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2400         int64_t ret_ref = 0;
2401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2403         return ret_ref;
2404 }
2405
2406 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2407 CHECK(!owner->result_ok);
2408         return DecodeError_clone(&*owner->contents.err);
2409 }
2410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2411         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2412         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2413         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2414         int64_t ret_ref = tag_ptr(ret_copy, true);
2415         return ret_ref;
2416 }
2417
2418 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2419         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2420         for (size_t i = 0; i < ret.datalen; i++) {
2421                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2422         }
2423         return ret;
2424 }
2425 static jclass LDKCOption_u64Z_Some_class = NULL;
2426 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2427 static jclass LDKCOption_u64Z_None_class = NULL;
2428 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2430         LDKCOption_u64Z_Some_class =
2431                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2432         CHECK(LDKCOption_u64Z_Some_class != NULL);
2433         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2434         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2435         LDKCOption_u64Z_None_class =
2436                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2437         CHECK(LDKCOption_u64Z_None_class != NULL);
2438         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2439         CHECK(LDKCOption_u64Z_None_meth != NULL);
2440 }
2441 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2442         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2443         switch(obj->tag) {
2444                 case LDKCOption_u64Z_Some: {
2445                         int64_t some_conv = obj->some;
2446                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2447                 }
2448                 case LDKCOption_u64Z_None: {
2449                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2450                 }
2451                 default: abort();
2452         }
2453 }
2454 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2455         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2456         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2457         return ret;
2458 }
2459 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2460         LDKPaymentParameters ret = *owner->contents.result;
2461         ret.is_owned = false;
2462         return ret;
2463 }
2464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2465         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2466         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2467         int64_t ret_ref = 0;
2468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2470         return ret_ref;
2471 }
2472
2473 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2474 CHECK(!owner->result_ok);
2475         return DecodeError_clone(&*owner->contents.err);
2476 }
2477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2478         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2479         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2480         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2481         int64_t ret_ref = tag_ptr(ret_copy, true);
2482         return ret_ref;
2483 }
2484
2485 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2486         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2487         for (size_t i = 0; i < ret.datalen; i++) {
2488                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2489         }
2490         return ret;
2491 }
2492 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2493         LDKRouteHint ret = *owner->contents.result;
2494         ret.is_owned = false;
2495         return ret;
2496 }
2497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2498         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2499         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2500         int64_t ret_ref = 0;
2501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2503         return ret_ref;
2504 }
2505
2506 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2507 CHECK(!owner->result_ok);
2508         return DecodeError_clone(&*owner->contents.err);
2509 }
2510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2511         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2512         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2513         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2514         int64_t ret_ref = tag_ptr(ret_copy, true);
2515         return ret_ref;
2516 }
2517
2518 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2519         LDKRouteHintHop ret = *owner->contents.result;
2520         ret.is_owned = false;
2521         return ret;
2522 }
2523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2524         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2525         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2526         int64_t ret_ref = 0;
2527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2529         return ret_ref;
2530 }
2531
2532 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2533 CHECK(!owner->result_ok);
2534         return DecodeError_clone(&*owner->contents.err);
2535 }
2536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2537         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2538         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2539         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2540         int64_t ret_ref = tag_ptr(ret_copy, true);
2541         return ret_ref;
2542 }
2543
2544 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2545         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2546         for (size_t i = 0; i < ret.datalen; i++) {
2547                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2548         }
2549         return ret;
2550 }
2551 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2552         LDKRoute ret = *owner->contents.result;
2553         ret.is_owned = false;
2554         return ret;
2555 }
2556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2557         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2558         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2559         int64_t ret_ref = 0;
2560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2562         return ret_ref;
2563 }
2564
2565 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2566         LDKLightningError ret = *owner->contents.err;
2567         ret.is_owned = false;
2568         return ret;
2569 }
2570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2571         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2572         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2573         int64_t ret_ref = 0;
2574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2576         return ret_ref;
2577 }
2578
2579 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2580 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2581 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2582 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2584         LDKPaymentPurpose_InvoicePayment_class =
2585                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2586         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2587         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2588         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2589         LDKPaymentPurpose_SpontaneousPayment_class =
2590                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2591         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2592         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2593         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2594 }
2595 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2596         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2597         switch(obj->tag) {
2598                 case LDKPaymentPurpose_InvoicePayment: {
2599                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2600                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2601                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2602                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2603                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2604                 }
2605                 case LDKPaymentPurpose_SpontaneousPayment: {
2606                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2607                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2608                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2609                 }
2610                 default: abort();
2611         }
2612 }
2613 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2614 CHECK(owner->result_ok);
2615         return PaymentPurpose_clone(&*owner->contents.result);
2616 }
2617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2618         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2619         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2620         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2621         int64_t ret_ref = tag_ptr(ret_copy, true);
2622         return ret_ref;
2623 }
2624
2625 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2626 CHECK(!owner->result_ok);
2627         return DecodeError_clone(&*owner->contents.err);
2628 }
2629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2630         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2631         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2632         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2633         int64_t ret_ref = tag_ptr(ret_copy, true);
2634         return ret_ref;
2635 }
2636
2637 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2638 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2639 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2640 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2641 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2642 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2643 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2644 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2645 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2646 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2647 static jclass LDKClosureReason_ProcessingError_class = NULL;
2648 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2649 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2650 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2651 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2652 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2654         LDKClosureReason_CounterpartyForceClosed_class =
2655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2656         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2657         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2658         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2659         LDKClosureReason_HolderForceClosed_class =
2660                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2661         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2662         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2663         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2664         LDKClosureReason_CooperativeClosure_class =
2665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2666         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2667         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2668         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2669         LDKClosureReason_CommitmentTxConfirmed_class =
2670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2671         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2672         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2673         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2674         LDKClosureReason_FundingTimedOut_class =
2675                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2676         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2677         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2678         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2679         LDKClosureReason_ProcessingError_class =
2680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2681         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2682         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2683         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2684         LDKClosureReason_DisconnectedPeer_class =
2685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2686         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2687         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2688         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2689         LDKClosureReason_OutdatedChannelManager_class =
2690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2691         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2692         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2693         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2694 }
2695 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2696         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
2697         switch(obj->tag) {
2698                 case LDKClosureReason_CounterpartyForceClosed: {
2699                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2700                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2701                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2702                 }
2703                 case LDKClosureReason_HolderForceClosed: {
2704                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2705                 }
2706                 case LDKClosureReason_CooperativeClosure: {
2707                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2708                 }
2709                 case LDKClosureReason_CommitmentTxConfirmed: {
2710                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2711                 }
2712                 case LDKClosureReason_FundingTimedOut: {
2713                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2714                 }
2715                 case LDKClosureReason_ProcessingError: {
2716                         LDKStr err_str = obj->processing_error.err;
2717                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2718                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2719                 }
2720                 case LDKClosureReason_DisconnectedPeer: {
2721                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2722                 }
2723                 case LDKClosureReason_OutdatedChannelManager: {
2724                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2725                 }
2726                 default: abort();
2727         }
2728 }
2729 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2730 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2731 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2732 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2734         LDKCOption_ClosureReasonZ_Some_class =
2735                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2736         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2737         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2738         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2739         LDKCOption_ClosureReasonZ_None_class =
2740                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2741         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2742         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2743         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2744 }
2745 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2746         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
2747         switch(obj->tag) {
2748                 case LDKCOption_ClosureReasonZ_Some: {
2749                         int64_t some_ref = tag_ptr(&obj->some, false);
2750                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2751                 }
2752                 case LDKCOption_ClosureReasonZ_None: {
2753                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2754                 }
2755                 default: abort();
2756         }
2757 }
2758 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2759 CHECK(owner->result_ok);
2760         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2761 }
2762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2763         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2764         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2765         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2766         int64_t ret_ref = tag_ptr(ret_copy, true);
2767         return ret_ref;
2768 }
2769
2770 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2771 CHECK(!owner->result_ok);
2772         return DecodeError_clone(&*owner->contents.err);
2773 }
2774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2775         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2776         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2777         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2778         int64_t ret_ref = tag_ptr(ret_copy, true);
2779         return ret_ref;
2780 }
2781
2782 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2783 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2784 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2785 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2786 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2787 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2789         LDKHTLCDestination_NextHopChannel_class =
2790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2791         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2792         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2793         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2794         LDKHTLCDestination_UnknownNextHop_class =
2795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2796         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2797         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2798         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2799         LDKHTLCDestination_FailedPayment_class =
2800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2801         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2802         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2803         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2804 }
2805 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2806         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2807         switch(obj->tag) {
2808                 case LDKHTLCDestination_NextHopChannel: {
2809                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2810                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2811                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2812                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2813                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2814                 }
2815                 case LDKHTLCDestination_UnknownNextHop: {
2816                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2817                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2818                 }
2819                 case LDKHTLCDestination_FailedPayment: {
2820                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2821                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2822                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2823                 }
2824                 default: abort();
2825         }
2826 }
2827 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2828 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2829 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2830 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2832         LDKCOption_HTLCDestinationZ_Some_class =
2833                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2834         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2835         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2836         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2837         LDKCOption_HTLCDestinationZ_None_class =
2838                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2839         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2840         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2841         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2842 }
2843 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2844         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2845         switch(obj->tag) {
2846                 case LDKCOption_HTLCDestinationZ_Some: {
2847                         int64_t some_ref = tag_ptr(&obj->some, false);
2848                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2849                 }
2850                 case LDKCOption_HTLCDestinationZ_None: {
2851                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2852                 }
2853                 default: abort();
2854         }
2855 }
2856 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2857 CHECK(owner->result_ok);
2858         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2859 }
2860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2861         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2862         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2863         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2864         int64_t ret_ref = tag_ptr(ret_copy, true);
2865         return ret_ref;
2866 }
2867
2868 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2869 CHECK(!owner->result_ok);
2870         return DecodeError_clone(&*owner->contents.err);
2871 }
2872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2873         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2874         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2875         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2876         int64_t ret_ref = tag_ptr(ret_copy, true);
2877         return ret_ref;
2878 }
2879
2880 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2881 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2882 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2883 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2884 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2885 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2887         LDKNetworkUpdate_ChannelUpdateMessage_class =
2888                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2889         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2890         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2891         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2892         LDKNetworkUpdate_ChannelFailure_class =
2893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2894         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2895         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2896         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2897         LDKNetworkUpdate_NodeFailure_class =
2898                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2899         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2900         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2901         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2902 }
2903 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2904         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2905         switch(obj->tag) {
2906                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2907                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2908                         int64_t msg_ref = 0;
2909                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2910                         msg_ref = tag_ptr(msg_var.inner, false);
2911                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2912                 }
2913                 case LDKNetworkUpdate_ChannelFailure: {
2914                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2915                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2916                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2917                 }
2918                 case LDKNetworkUpdate_NodeFailure: {
2919                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2920                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2921                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2922                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2923                 }
2924                 default: abort();
2925         }
2926 }
2927 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2928 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2929 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2930 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2932         LDKCOption_NetworkUpdateZ_Some_class =
2933                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2934         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2935         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2936         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2937         LDKCOption_NetworkUpdateZ_None_class =
2938                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2939         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2940         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2941         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2942 }
2943 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2944         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2945         switch(obj->tag) {
2946                 case LDKCOption_NetworkUpdateZ_Some: {
2947                         int64_t some_ref = tag_ptr(&obj->some, false);
2948                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2949                 }
2950                 case LDKCOption_NetworkUpdateZ_None: {
2951                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2952                 }
2953                 default: abort();
2954         }
2955 }
2956 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2957 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2958 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2959 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2960 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2961 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2963         LDKSpendableOutputDescriptor_StaticOutput_class =
2964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2965         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2966         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2967         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2968         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2970         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2971         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2972         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2973         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2975         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2976         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2977         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2978 }
2979 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2980         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2981         switch(obj->tag) {
2982                 case LDKSpendableOutputDescriptor_StaticOutput: {
2983                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2984                         int64_t outpoint_ref = 0;
2985                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2986                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2987                         LDKTxOut* output_ref = &obj->static_output.output;
2988                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2989                 }
2990                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2991                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2992                         int64_t delayed_payment_output_ref = 0;
2993                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2994                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
2995                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2996                 }
2997                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2998                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2999                         int64_t static_payment_output_ref = 0;
3000                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
3001                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
3002                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
3003                 }
3004                 default: abort();
3005         }
3006 }
3007 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
3008         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
3009         for (size_t i = 0; i < ret.datalen; i++) {
3010                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
3011         }
3012         return ret;
3013 }
3014 static jclass LDKEvent_FundingGenerationReady_class = NULL;
3015 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
3016 static jclass LDKEvent_PaymentReceived_class = NULL;
3017 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
3018 static jclass LDKEvent_PaymentClaimed_class = NULL;
3019 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
3020 static jclass LDKEvent_PaymentSent_class = NULL;
3021 static jmethodID LDKEvent_PaymentSent_meth = NULL;
3022 static jclass LDKEvent_PaymentFailed_class = NULL;
3023 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
3024 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
3025 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
3026 static jclass LDKEvent_PaymentPathFailed_class = NULL;
3027 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
3028 static jclass LDKEvent_ProbeSuccessful_class = NULL;
3029 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
3030 static jclass LDKEvent_ProbeFailed_class = NULL;
3031 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
3032 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
3033 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
3034 static jclass LDKEvent_SpendableOutputs_class = NULL;
3035 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
3036 static jclass LDKEvent_PaymentForwarded_class = NULL;
3037 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
3038 static jclass LDKEvent_ChannelClosed_class = NULL;
3039 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
3040 static jclass LDKEvent_DiscardFunding_class = NULL;
3041 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3042 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3043 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3044 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3045 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3047         LDKEvent_FundingGenerationReady_class =
3048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3049         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3050         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
3051         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3052         LDKEvent_PaymentReceived_class =
3053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
3054         CHECK(LDKEvent_PaymentReceived_class != NULL);
3055         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
3056         CHECK(LDKEvent_PaymentReceived_meth != NULL);
3057         LDKEvent_PaymentClaimed_class =
3058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3059         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3060         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
3061         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3062         LDKEvent_PaymentSent_class =
3063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3064         CHECK(LDKEvent_PaymentSent_class != NULL);
3065         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3066         CHECK(LDKEvent_PaymentSent_meth != NULL);
3067         LDKEvent_PaymentFailed_class =
3068                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3069         CHECK(LDKEvent_PaymentFailed_class != NULL);
3070         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3071         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3072         LDKEvent_PaymentPathSuccessful_class =
3073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3074         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3075         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3076         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3077         LDKEvent_PaymentPathFailed_class =
3078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3079         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3080         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
3081         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3082         LDKEvent_ProbeSuccessful_class =
3083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3084         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3085         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3086         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3087         LDKEvent_ProbeFailed_class =
3088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3089         CHECK(LDKEvent_ProbeFailed_class != NULL);
3090         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3091         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3092         LDKEvent_PendingHTLCsForwardable_class =
3093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3094         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3095         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3096         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3097         LDKEvent_SpendableOutputs_class =
3098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3099         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3100         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3101         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3102         LDKEvent_PaymentForwarded_class =
3103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3104         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3105         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3106         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3107         LDKEvent_ChannelClosed_class =
3108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3109         CHECK(LDKEvent_ChannelClosed_class != NULL);
3110         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
3111         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3112         LDKEvent_DiscardFunding_class =
3113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3114         CHECK(LDKEvent_DiscardFunding_class != NULL);
3115         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3116         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3117         LDKEvent_OpenChannelRequest_class =
3118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3119         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3120         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3121         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3122         LDKEvent_HTLCHandlingFailed_class =
3123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3124         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3125         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3126         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3127 }
3128 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3129         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3130         switch(obj->tag) {
3131                 case LDKEvent_FundingGenerationReady: {
3132                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3133                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3134                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3135                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3136                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3137                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3138                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3139                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3140                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
3141                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
3142                 }
3143                 case LDKEvent_PaymentReceived: {
3144                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3145                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
3146                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
3147                         int64_t purpose_ref = tag_ptr(&obj->payment_received.purpose, false);
3148                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3149                 }
3150                 case LDKEvent_PaymentClaimed: {
3151                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3152                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3153                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3154                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3155                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3156                 }
3157                 case LDKEvent_PaymentSent: {
3158                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3159                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3160                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3161                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3162                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3163                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3164                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3165                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3166                 }
3167                 case LDKEvent_PaymentFailed: {
3168                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3169                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3170                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3171                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3172                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3173                 }
3174                 case LDKEvent_PaymentPathSuccessful: {
3175                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3176                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3177                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3178                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3179                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3180                         int64_tArray path_arr = NULL;
3181                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3182                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3183                         for (size_t k = 0; k < path_var.datalen; k++) {
3184                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3185                                 int64_t path_conv_10_ref = 0;
3186                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3187                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3188                                 path_arr_ptr[k] = path_conv_10_ref;
3189                         }
3190                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3191                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3192                 }
3193                 case LDKEvent_PaymentPathFailed: {
3194                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3195                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3196                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3197                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3198                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3199                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
3200                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
3201                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3202                         int64_tArray path_arr = NULL;
3203                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3204                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3205                         for (size_t k = 0; k < path_var.datalen; k++) {
3206                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3207                                 int64_t path_conv_10_ref = 0;
3208                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3209                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3210                                 path_arr_ptr[k] = path_conv_10_ref;
3211                         }
3212                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3213                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3214                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3215                         int64_t retry_ref = 0;
3216                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3217                         retry_ref = tag_ptr(retry_var.inner, false);
3218                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
3219                 }
3220                 case LDKEvent_ProbeSuccessful: {
3221                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3222                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3223                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3224                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3225                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3226                         int64_tArray path_arr = NULL;
3227                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3228                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3229                         for (size_t k = 0; k < path_var.datalen; k++) {
3230                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3231                                 int64_t path_conv_10_ref = 0;
3232                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3233                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3234                                 path_arr_ptr[k] = path_conv_10_ref;
3235                         }
3236                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3237                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3238                 }
3239                 case LDKEvent_ProbeFailed: {
3240                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3241                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3242                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3243                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3244                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3245                         int64_tArray path_arr = NULL;
3246                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3247                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3248                         for (size_t k = 0; k < path_var.datalen; k++) {
3249                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3250                                 int64_t path_conv_10_ref = 0;
3251                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3252                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3253                                 path_arr_ptr[k] = path_conv_10_ref;
3254                         }
3255                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3256                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3257                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3258                 }
3259                 case LDKEvent_PendingHTLCsForwardable: {
3260                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3261                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3262                 }
3263                 case LDKEvent_SpendableOutputs: {
3264                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3265                         int64_tArray outputs_arr = NULL;
3266                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3267                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3268                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3269                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3270                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3271                         }
3272                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3273                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3274                 }
3275                 case LDKEvent_PaymentForwarded: {
3276                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3277                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3278                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3279                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3280                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3281                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3282                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
3283                 }
3284                 case LDKEvent_ChannelClosed: {
3285                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3286                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3287                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
3288                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3289                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
3290                 }
3291                 case LDKEvent_DiscardFunding: {
3292                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3293                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3294                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3295                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3296                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3297                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3298                 }
3299                 case LDKEvent_OpenChannelRequest: {
3300                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3301                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3302                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3303                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3304                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3305                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3306                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3307                         int64_t channel_type_ref = 0;
3308                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3309                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3310                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
3311                 }
3312                 case LDKEvent_HTLCHandlingFailed: {
3313                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3314                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3315                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3316                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3317                 }
3318                 default: abort();
3319         }
3320 }
3321 static jclass LDKCOption_EventZ_Some_class = NULL;
3322 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3323 static jclass LDKCOption_EventZ_None_class = NULL;
3324 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3326         LDKCOption_EventZ_Some_class =
3327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3328         CHECK(LDKCOption_EventZ_Some_class != NULL);
3329         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3330         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3331         LDKCOption_EventZ_None_class =
3332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3333         CHECK(LDKCOption_EventZ_None_class != NULL);
3334         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3335         CHECK(LDKCOption_EventZ_None_meth != NULL);
3336 }
3337 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3338         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3339         switch(obj->tag) {
3340                 case LDKCOption_EventZ_Some: {
3341                         int64_t some_ref = tag_ptr(&obj->some, false);
3342                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3343                 }
3344                 case LDKCOption_EventZ_None: {
3345                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3346                 }
3347                 default: abort();
3348         }
3349 }
3350 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3351 CHECK(owner->result_ok);
3352         return COption_EventZ_clone(&*owner->contents.result);
3353 }
3354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3355         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3356         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3357         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3358         int64_t ret_ref = tag_ptr(ret_copy, true);
3359         return ret_ref;
3360 }
3361
3362 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3363 CHECK(!owner->result_ok);
3364         return DecodeError_clone(&*owner->contents.err);
3365 }
3366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3367         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3368         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3369         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3370         int64_t ret_ref = tag_ptr(ret_copy, true);
3371         return ret_ref;
3372 }
3373
3374 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3375 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3376 static jclass LDKErrorAction_IgnoreError_class = NULL;
3377 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3378 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3379 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3380 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3381 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3382 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3383 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3384 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3385 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3387         LDKErrorAction_DisconnectPeer_class =
3388                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3389         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3390         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3391         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3392         LDKErrorAction_IgnoreError_class =
3393                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3394         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3395         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3396         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3397         LDKErrorAction_IgnoreAndLog_class =
3398                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3399         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3400         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3401         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3402         LDKErrorAction_IgnoreDuplicateGossip_class =
3403                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3404         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3405         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3406         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3407         LDKErrorAction_SendErrorMessage_class =
3408                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3409         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3410         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3411         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3412         LDKErrorAction_SendWarningMessage_class =
3413                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3414         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3415         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3416         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3417 }
3418 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3419         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3420         switch(obj->tag) {
3421                 case LDKErrorAction_DisconnectPeer: {
3422                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3423                         int64_t msg_ref = 0;
3424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3425                         msg_ref = tag_ptr(msg_var.inner, false);
3426                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3427                 }
3428                 case LDKErrorAction_IgnoreError: {
3429                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3430                 }
3431                 case LDKErrorAction_IgnoreAndLog: {
3432                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3433                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3434                 }
3435                 case LDKErrorAction_IgnoreDuplicateGossip: {
3436                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3437                 }
3438                 case LDKErrorAction_SendErrorMessage: {
3439                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3440                         int64_t msg_ref = 0;
3441                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3442                         msg_ref = tag_ptr(msg_var.inner, false);
3443                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3444                 }
3445                 case LDKErrorAction_SendWarningMessage: {
3446                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3447                         int64_t msg_ref = 0;
3448                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3449                         msg_ref = tag_ptr(msg_var.inner, false);
3450                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3451                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3452                 }
3453                 default: abort();
3454         }
3455 }
3456 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3457 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3458 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3459 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3460 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3461 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3462 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3463 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3464 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3465 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3466 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3467 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3468 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3469 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3470 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3471 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3472 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3473 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3474 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3475 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3476 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3477 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3478 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3479 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3480 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3481 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3482 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3483 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3484 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3485 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3486 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3487 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3488 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3489 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3490 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3491 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3492 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3493 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3494 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3495 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3497         LDKMessageSendEvent_SendAcceptChannel_class =
3498                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3499         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3500         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3501         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3502         LDKMessageSendEvent_SendOpenChannel_class =
3503                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3504         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3505         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3506         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3507         LDKMessageSendEvent_SendFundingCreated_class =
3508                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3509         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3510         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3511         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3512         LDKMessageSendEvent_SendFundingSigned_class =
3513                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3514         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3515         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3516         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3517         LDKMessageSendEvent_SendChannelReady_class =
3518                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3519         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3520         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3521         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3522         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3523                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3524         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3525         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3526         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3527         LDKMessageSendEvent_UpdateHTLCs_class =
3528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3529         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3530         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3531         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3532         LDKMessageSendEvent_SendRevokeAndACK_class =
3533                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3534         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3535         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3536         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3537         LDKMessageSendEvent_SendClosingSigned_class =
3538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3539         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3540         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3541         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3542         LDKMessageSendEvent_SendShutdown_class =
3543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3544         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3545         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3546         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3547         LDKMessageSendEvent_SendChannelReestablish_class =
3548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3549         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3550         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3551         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3552         LDKMessageSendEvent_SendChannelAnnouncement_class =
3553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3554         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3555         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3556         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3557         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3559         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3560         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3561         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3562         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3563                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3564         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3565         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3566         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3567         LDKMessageSendEvent_SendChannelUpdate_class =
3568                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3569         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3570         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3571         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3572         LDKMessageSendEvent_HandleError_class =
3573                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3574         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3575         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3576         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3577         LDKMessageSendEvent_SendChannelRangeQuery_class =
3578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3579         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3580         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3581         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3582         LDKMessageSendEvent_SendShortIdsQuery_class =
3583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3584         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3585         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3586         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3587         LDKMessageSendEvent_SendReplyChannelRange_class =
3588                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3589         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3590         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3591         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3592         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3594         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3595         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3596         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3597 }
3598 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3599         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3600         switch(obj->tag) {
3601                 case LDKMessageSendEvent_SendAcceptChannel: {
3602                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3603                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3604                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3605                         int64_t msg_ref = 0;
3606                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3607                         msg_ref = tag_ptr(msg_var.inner, false);
3608                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3609                 }
3610                 case LDKMessageSendEvent_SendOpenChannel: {
3611                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3612                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3613                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3614                         int64_t msg_ref = 0;
3615                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3616                         msg_ref = tag_ptr(msg_var.inner, false);
3617                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3618                 }
3619                 case LDKMessageSendEvent_SendFundingCreated: {
3620                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3621                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3622                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3623                         int64_t msg_ref = 0;
3624                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3625                         msg_ref = tag_ptr(msg_var.inner, false);
3626                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3627                 }
3628                 case LDKMessageSendEvent_SendFundingSigned: {
3629                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3630                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3631                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3632                         int64_t msg_ref = 0;
3633                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3634                         msg_ref = tag_ptr(msg_var.inner, false);
3635                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3636                 }
3637                 case LDKMessageSendEvent_SendChannelReady: {
3638                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3639                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3640                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3641                         int64_t msg_ref = 0;
3642                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3643                         msg_ref = tag_ptr(msg_var.inner, false);
3644                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3645                 }
3646                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3647                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3648                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3649                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3650                         int64_t msg_ref = 0;
3651                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3652                         msg_ref = tag_ptr(msg_var.inner, false);
3653                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3654                 }
3655                 case LDKMessageSendEvent_UpdateHTLCs: {
3656                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3657                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3658                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3659                         int64_t updates_ref = 0;
3660                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3661                         updates_ref = tag_ptr(updates_var.inner, false);
3662                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3663                 }
3664                 case LDKMessageSendEvent_SendRevokeAndACK: {
3665                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3666                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3667                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3668                         int64_t msg_ref = 0;
3669                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3670                         msg_ref = tag_ptr(msg_var.inner, false);
3671                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3672                 }
3673                 case LDKMessageSendEvent_SendClosingSigned: {
3674                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3675                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3676                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3677                         int64_t msg_ref = 0;
3678                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3679                         msg_ref = tag_ptr(msg_var.inner, false);
3680                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3681                 }
3682                 case LDKMessageSendEvent_SendShutdown: {
3683                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3684                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3685                         LDKShutdown msg_var = obj->send_shutdown.msg;
3686                         int64_t msg_ref = 0;
3687                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3688                         msg_ref = tag_ptr(msg_var.inner, false);
3689                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3690                 }
3691                 case LDKMessageSendEvent_SendChannelReestablish: {
3692                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3693                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3694                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3695                         int64_t msg_ref = 0;
3696                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3697                         msg_ref = tag_ptr(msg_var.inner, false);
3698                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3699                 }
3700                 case LDKMessageSendEvent_SendChannelAnnouncement: {
3701                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3702                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
3703                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
3704                         int64_t msg_ref = 0;
3705                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3706                         msg_ref = tag_ptr(msg_var.inner, false);
3707                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
3708                         int64_t update_msg_ref = 0;
3709                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3710                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3711                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
3712                 }
3713                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3714                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3715                         int64_t msg_ref = 0;
3716                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3717                         msg_ref = tag_ptr(msg_var.inner, false);
3718                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3719                         int64_t update_msg_ref = 0;
3720                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3721                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3722                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3723                 }
3724                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3725                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3726                         int64_t msg_ref = 0;
3727                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3728                         msg_ref = tag_ptr(msg_var.inner, false);
3729                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3730                 }
3731                 case LDKMessageSendEvent_SendChannelUpdate: {
3732                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3733                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3734                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3735                         int64_t msg_ref = 0;
3736                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3737                         msg_ref = tag_ptr(msg_var.inner, false);
3738                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3739                 }
3740                 case LDKMessageSendEvent_HandleError: {
3741                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3742                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3743                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
3744                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3745                 }
3746                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3747                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3748                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3749                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3750                         int64_t msg_ref = 0;
3751                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3752                         msg_ref = tag_ptr(msg_var.inner, false);
3753                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3754                 }
3755                 case LDKMessageSendEvent_SendShortIdsQuery: {
3756                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3757                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3758                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3759                         int64_t msg_ref = 0;
3760                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3761                         msg_ref = tag_ptr(msg_var.inner, false);
3762                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3763                 }
3764                 case LDKMessageSendEvent_SendReplyChannelRange: {
3765                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3766                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3767                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3768                         int64_t msg_ref = 0;
3769                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3770                         msg_ref = tag_ptr(msg_var.inner, false);
3771                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3772                 }
3773                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3774                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3775                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3776                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3777                         int64_t msg_ref = 0;
3778                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3779                         msg_ref = tag_ptr(msg_var.inner, false);
3780                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3781                 }
3782                 default: abort();
3783         }
3784 }
3785 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3786         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3787         for (size_t i = 0; i < ret.datalen; i++) {
3788                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3789         }
3790         return ret;
3791 }
3792 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3793 CHECK(owner->result_ok);
3794         return TxOut_clone(&*owner->contents.result);
3795 }
3796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3797         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3798         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3799         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3800         return tag_ptr(ret_ref, true);
3801 }
3802
3803 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3804 CHECK(!owner->result_ok);
3805         return AccessError_clone(&*owner->contents.err);
3806 }
3807 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3808         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3809         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3810         return ret_conv;
3811 }
3812
3813 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3814         return owner->a;
3815 }
3816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3817         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3818         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3819         return ret_conv;
3820 }
3821
3822 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3823         return owner->b;
3824 }
3825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3826         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3827         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3830         return ret_arr;
3831 }
3832
3833 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3834         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3835         for (size_t i = 0; i < ret.datalen; i++) {
3836                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3837         }
3838         return ret;
3839 }
3840 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3841         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3842         for (size_t i = 0; i < ret.datalen; i++) {
3843                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3844         }
3845         return ret;
3846 }
3847 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3848 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3849 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3850 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3851 static jclass LDKMonitorEvent_Completed_class = NULL;
3852 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
3853 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3854 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3856         LDKMonitorEvent_HTLCEvent_class =
3857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3858         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3859         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3860         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3861         LDKMonitorEvent_CommitmentTxConfirmed_class =
3862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3863         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3864         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3865         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3866         LDKMonitorEvent_Completed_class =
3867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
3868         CHECK(LDKMonitorEvent_Completed_class != NULL);
3869         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
3870         CHECK(LDKMonitorEvent_Completed_meth != NULL);
3871         LDKMonitorEvent_UpdateFailed_class =
3872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3873         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3874         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3875         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3876 }
3877 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3878         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3879         switch(obj->tag) {
3880                 case LDKMonitorEvent_HTLCEvent: {
3881                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3882                         int64_t htlc_event_ref = 0;
3883                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3884                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3885                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3886                 }
3887                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3888                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3889                         int64_t commitment_tx_confirmed_ref = 0;
3890                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3891                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3892                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3893                 }
3894                 case LDKMonitorEvent_Completed: {
3895                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3896                         int64_t funding_txo_ref = 0;
3897                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3898                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3899                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3900                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
3901                 }
3902                 case LDKMonitorEvent_UpdateFailed: {
3903                         LDKOutPoint update_failed_var = obj->update_failed;
3904                         int64_t update_failed_ref = 0;
3905                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3906                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3907                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3908                 }
3909                 default: abort();
3910         }
3911 }
3912 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3913         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3914         for (size_t i = 0; i < ret.datalen; i++) {
3915                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3916         }
3917         return ret;
3918 }
3919 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3920         LDKOutPoint ret = owner->a;
3921         ret.is_owned = false;
3922         return ret;
3923 }
3924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3925         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3926         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3927         int64_t ret_ref = 0;
3928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3930         return ret_ref;
3931 }
3932
3933 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3934         return CVec_MonitorEventZ_clone(&owner->b);
3935 }
3936 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3937         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3938         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3939         int64_tArray ret_arr = NULL;
3940         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3941         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3942         for (size_t o = 0; o < ret_var.datalen; o++) {
3943                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3944                 *ret_conv_14_copy = ret_var.data[o];
3945                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3946                 ret_arr_ptr[o] = ret_conv_14_ref;
3947         }
3948         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3949         FREE(ret_var.data);
3950         return ret_arr;
3951 }
3952
3953 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3954         return owner->c;
3955 }
3956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3957         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3960         return ret_arr;
3961 }
3962
3963 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3964         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3965         for (size_t i = 0; i < ret.datalen; i++) {
3966                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3967         }
3968         return ret;
3969 }
3970 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3971         LDKFixedPenaltyScorer ret = *owner->contents.result;
3972         ret.is_owned = false;
3973         return ret;
3974 }
3975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3976         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3977         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3978         int64_t ret_ref = 0;
3979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3981         return ret_ref;
3982 }
3983
3984 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3985 CHECK(!owner->result_ok);
3986         return DecodeError_clone(&*owner->contents.err);
3987 }
3988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3989         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3990         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3991         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3992         int64_t ret_ref = tag_ptr(ret_copy, true);
3993         return ret_ref;
3994 }
3995
3996 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3997         return owner->a;
3998 }
3999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4000         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4001         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
4002         return ret_conv;
4003 }
4004
4005 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4006         return owner->b;
4007 }
4008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4009         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4010         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
4011         return ret_conv;
4012 }
4013
4014 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
4015 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
4016 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
4017 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4019         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4021         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4022         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4023         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4024         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4026         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4027         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4028         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4029 }
4030 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4031         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4032         switch(obj->tag) {
4033                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4034                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4035                         *some_conv = obj->some;
4036                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4037                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4038                 }
4039                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4040                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4041                 }
4042                 default: abort();
4043         }
4044 }
4045 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4046         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4047         for (size_t i = 0; i < ret.datalen; i++) {
4048                 ret.data[i] = NodeId_clone(&orig->data[i]);
4049         }
4050         return ret;
4051 }
4052 typedef struct LDKLogger_JCalls {
4053         atomic_size_t refcnt;
4054         JavaVM *vm;
4055         jweak o;
4056         jmethodID log_meth;
4057 } LDKLogger_JCalls;
4058 static void LDKLogger_JCalls_free(void* this_arg) {
4059         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4060         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4061                 JNIEnv *env;
4062                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4063                 if (get_jenv_res == JNI_EDETACHED) {
4064                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4065                 } else {
4066                         DO_ASSERT(get_jenv_res == JNI_OK);
4067                 }
4068                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4069                 if (get_jenv_res == JNI_EDETACHED) {
4070                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4071                 }
4072                 FREE(j_calls);
4073         }
4074 }
4075 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4076         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4077         JNIEnv *env;
4078         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4079         if (get_jenv_res == JNI_EDETACHED) {
4080                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4081         } else {
4082                 DO_ASSERT(get_jenv_res == JNI_OK);
4083         }
4084         LDKRecord record_var = *record;
4085         int64_t record_ref = 0;
4086         record_var = Record_clone(&record_var);
4087         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4088         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4089         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4090         CHECK(obj != NULL);
4091         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4092         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4093                 (*env)->ExceptionDescribe(env);
4094                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4095         }
4096         if (get_jenv_res == JNI_EDETACHED) {
4097                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4098         }
4099 }
4100 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4101         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4102         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4103 }
4104 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4105         jclass c = (*env)->GetObjectClass(env, o);
4106         CHECK(c != NULL);
4107         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4108         atomic_init(&calls->refcnt, 1);
4109         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4110         calls->o = (*env)->NewWeakGlobalRef(env, o);
4111         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4112         CHECK(calls->log_meth != NULL);
4113
4114         LDKLogger ret = {
4115                 .this_arg = (void*) calls,
4116                 .log = log_LDKLogger_jcall,
4117                 .free = LDKLogger_JCalls_free,
4118         };
4119         return ret;
4120 }
4121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4122         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4123         *res_ptr = LDKLogger_init(env, clz, o);
4124         return tag_ptr(res_ptr, true);
4125 }
4126 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4127         LDKProbabilisticScorer ret = *owner->contents.result;
4128         ret.is_owned = false;
4129         return ret;
4130 }
4131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4132         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4133         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4134         int64_t ret_ref = 0;
4135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4137         return ret_ref;
4138 }
4139
4140 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4141 CHECK(!owner->result_ok);
4142         return DecodeError_clone(&*owner->contents.err);
4143 }
4144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4145         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4146         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4147         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4148         int64_t ret_ref = tag_ptr(ret_copy, true);
4149         return ret_ref;
4150 }
4151
4152 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4153         LDKInitFeatures ret = *owner->contents.result;
4154         ret.is_owned = false;
4155         return ret;
4156 }
4157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4158         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4159         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4160         int64_t ret_ref = 0;
4161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4163         return ret_ref;
4164 }
4165
4166 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4167 CHECK(!owner->result_ok);
4168         return DecodeError_clone(&*owner->contents.err);
4169 }
4170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4171         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4172         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4173         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4174         int64_t ret_ref = tag_ptr(ret_copy, true);
4175         return ret_ref;
4176 }
4177
4178 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4179         LDKChannelFeatures ret = *owner->contents.result;
4180         ret.is_owned = false;
4181         return ret;
4182 }
4183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4184         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4185         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4186         int64_t ret_ref = 0;
4187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4189         return ret_ref;
4190 }
4191
4192 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4193 CHECK(!owner->result_ok);
4194         return DecodeError_clone(&*owner->contents.err);
4195 }
4196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4197         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4198         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4199         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4200         int64_t ret_ref = tag_ptr(ret_copy, true);
4201         return ret_ref;
4202 }
4203
4204 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4205         LDKNodeFeatures ret = *owner->contents.result;
4206         ret.is_owned = false;
4207         return ret;
4208 }
4209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4210         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4211         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4212         int64_t ret_ref = 0;
4213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4215         return ret_ref;
4216 }
4217
4218 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4219 CHECK(!owner->result_ok);
4220         return DecodeError_clone(&*owner->contents.err);
4221 }
4222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4223         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4224         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4225         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4226         int64_t ret_ref = tag_ptr(ret_copy, true);
4227         return ret_ref;
4228 }
4229
4230 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4231         LDKInvoiceFeatures ret = *owner->contents.result;
4232         ret.is_owned = false;
4233         return ret;
4234 }
4235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4236         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4237         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4238         int64_t ret_ref = 0;
4239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4241         return ret_ref;
4242 }
4243
4244 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4245 CHECK(!owner->result_ok);
4246         return DecodeError_clone(&*owner->contents.err);
4247 }
4248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4249         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4250         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4251         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4252         int64_t ret_ref = tag_ptr(ret_copy, true);
4253         return ret_ref;
4254 }
4255
4256 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4257         LDKChannelTypeFeatures ret = *owner->contents.result;
4258         ret.is_owned = false;
4259         return ret;
4260 }
4261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4262         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4263         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4264         int64_t ret_ref = 0;
4265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4267         return ret_ref;
4268 }
4269
4270 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4271 CHECK(!owner->result_ok);
4272         return DecodeError_clone(&*owner->contents.err);
4273 }
4274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4275         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4276         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4277         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4278         int64_t ret_ref = tag_ptr(ret_copy, true);
4279         return ret_ref;
4280 }
4281
4282 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4283         LDKNodeId ret = *owner->contents.result;
4284         ret.is_owned = false;
4285         return ret;
4286 }
4287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4288         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4289         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4290         int64_t ret_ref = 0;
4291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4293         return ret_ref;
4294 }
4295
4296 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4297 CHECK(!owner->result_ok);
4298         return DecodeError_clone(&*owner->contents.err);
4299 }
4300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4301         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4302         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4303         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4304         int64_t ret_ref = tag_ptr(ret_copy, true);
4305         return ret_ref;
4306 }
4307
4308 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4309 CHECK(owner->result_ok);
4310         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4311 }
4312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4313         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4314         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4315         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4316         int64_t ret_ref = tag_ptr(ret_copy, true);
4317         return ret_ref;
4318 }
4319
4320 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4321 CHECK(!owner->result_ok);
4322         return DecodeError_clone(&*owner->contents.err);
4323 }
4324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4325         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4326         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4327         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4328         int64_t ret_ref = tag_ptr(ret_copy, true);
4329         return ret_ref;
4330 }
4331
4332 typedef struct LDKAccess_JCalls {
4333         atomic_size_t refcnt;
4334         JavaVM *vm;
4335         jweak o;
4336         jmethodID get_utxo_meth;
4337 } LDKAccess_JCalls;
4338 static void LDKAccess_JCalls_free(void* this_arg) {
4339         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4340         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4341                 JNIEnv *env;
4342                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4343                 if (get_jenv_res == JNI_EDETACHED) {
4344                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4345                 } else {
4346                         DO_ASSERT(get_jenv_res == JNI_OK);
4347                 }
4348                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4349                 if (get_jenv_res == JNI_EDETACHED) {
4350                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4351                 }
4352                 FREE(j_calls);
4353         }
4354 }
4355 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4356         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4357         JNIEnv *env;
4358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4359         if (get_jenv_res == JNI_EDETACHED) {
4360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4361         } else {
4362                 DO_ASSERT(get_jenv_res == JNI_OK);
4363         }
4364         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4365         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4366         int64_t short_channel_id_conv = short_channel_id;
4367         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4368         CHECK(obj != NULL);
4369         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4370         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4371                 (*env)->ExceptionDescribe(env);
4372                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
4373         }
4374         void* ret_ptr = untag_ptr(ret);
4375         CHECK_ACCESS(ret_ptr);
4376         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4377         FREE(untag_ptr(ret));
4378         if (get_jenv_res == JNI_EDETACHED) {
4379                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4380         }
4381         return ret_conv;
4382 }
4383 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4384         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4385         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4386 }
4387 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4388         jclass c = (*env)->GetObjectClass(env, o);
4389         CHECK(c != NULL);
4390         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4391         atomic_init(&calls->refcnt, 1);
4392         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4393         calls->o = (*env)->NewWeakGlobalRef(env, o);
4394         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4395         CHECK(calls->get_utxo_meth != NULL);
4396
4397         LDKAccess ret = {
4398                 .this_arg = (void*) calls,
4399                 .get_utxo = get_utxo_LDKAccess_jcall,
4400                 .free = LDKAccess_JCalls_free,
4401         };
4402         return ret;
4403 }
4404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4405         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4406         *res_ptr = LDKAccess_init(env, clz, o);
4407         return tag_ptr(res_ptr, true);
4408 }
4409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4410         void* this_arg_ptr = untag_ptr(this_arg);
4411         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4412         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4413         unsigned char genesis_hash_arr[32];
4414         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4415         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4416         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4417         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4418         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4419         return tag_ptr(ret_conv, true);
4420 }
4421
4422 static jclass LDKCOption_AccessZ_Some_class = NULL;
4423 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
4424 static jclass LDKCOption_AccessZ_None_class = NULL;
4425 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4427         LDKCOption_AccessZ_Some_class =
4428                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4429         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4430         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4431         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4432         LDKCOption_AccessZ_None_class =
4433                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4434         CHECK(LDKCOption_AccessZ_None_class != NULL);
4435         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4436         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4437 }
4438 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4439         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
4440         switch(obj->tag) {
4441                 case LDKCOption_AccessZ_Some: {
4442                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4443                         *some_ret = obj->some;
4444                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4445                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4446                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4447                                 LDKAccess_JCalls_cloned(&(*some_ret));
4448                         }
4449                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
4450                 }
4451                 case LDKCOption_AccessZ_None: {
4452                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4453                 }
4454                 default: abort();
4455         }
4456 }
4457 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4458 CHECK(owner->result_ok);
4459         return *owner->contents.result;
4460 }
4461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4462         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4463         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4464         return ret_conv;
4465 }
4466
4467 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4468         LDKLightningError ret = *owner->contents.err;
4469         ret.is_owned = false;
4470         return ret;
4471 }
4472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4473         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4474         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4475         int64_t ret_ref = 0;
4476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4478         return ret_ref;
4479 }
4480
4481 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4482         LDKChannelAnnouncement ret = owner->a;
4483         ret.is_owned = false;
4484         return ret;
4485 }
4486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4487         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4488         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4489         int64_t ret_ref = 0;
4490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4492         return ret_ref;
4493 }
4494
4495 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4496         LDKChannelUpdate ret = owner->b;
4497         ret.is_owned = false;
4498         return ret;
4499 }
4500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4501         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4502         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4503         int64_t ret_ref = 0;
4504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4506         return ret_ref;
4507 }
4508
4509 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4510         LDKChannelUpdate ret = owner->c;
4511         ret.is_owned = false;
4512         return ret;
4513 }
4514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4515         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4516         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4517         int64_t ret_ref = 0;
4518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4519         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4520         return ret_ref;
4521 }
4522
4523 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
4524 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
4525 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
4526 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
4527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
4528         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
4529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
4530         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
4531         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
4532         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
4533         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
4534                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
4535         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
4536         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
4537         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
4538 }
4539 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4540         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4541         switch(obj->tag) {
4542                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
4543                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4544                         *some_conv = obj->some;
4545                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4546                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
4547                 }
4548                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
4549                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
4550                 }
4551                 default: abort();
4552         }
4553 }
4554 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4555 CHECK(owner->result_ok);
4556         return *owner->contents.result;
4557 }
4558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4559         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4560         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4561 }
4562
4563 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4564         LDKLightningError ret = *owner->contents.err;
4565         ret.is_owned = false;
4566         return ret;
4567 }
4568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4569         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4570         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4571         int64_t ret_ref = 0;
4572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4574         return ret_ref;
4575 }
4576
4577 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4578         LDKChannelUpdateInfo ret = *owner->contents.result;
4579         ret.is_owned = false;
4580         return ret;
4581 }
4582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4583         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4584         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4585         int64_t ret_ref = 0;
4586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4588         return ret_ref;
4589 }
4590
4591 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4592 CHECK(!owner->result_ok);
4593         return DecodeError_clone(&*owner->contents.err);
4594 }
4595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4596         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4597         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4598         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4599         int64_t ret_ref = tag_ptr(ret_copy, true);
4600         return ret_ref;
4601 }
4602
4603 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4604         LDKChannelInfo ret = *owner->contents.result;
4605         ret.is_owned = false;
4606         return ret;
4607 }
4608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4609         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4610         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4611         int64_t ret_ref = 0;
4612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4614         return ret_ref;
4615 }
4616
4617 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4618 CHECK(!owner->result_ok);
4619         return DecodeError_clone(&*owner->contents.err);
4620 }
4621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4622         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4623         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4624         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4625         int64_t ret_ref = tag_ptr(ret_copy, true);
4626         return ret_ref;
4627 }
4628
4629 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4630         LDKRoutingFees ret = *owner->contents.result;
4631         ret.is_owned = false;
4632         return ret;
4633 }
4634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4635         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4636         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4637         int64_t ret_ref = 0;
4638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4640         return ret_ref;
4641 }
4642
4643 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4644 CHECK(!owner->result_ok);
4645         return DecodeError_clone(&*owner->contents.err);
4646 }
4647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4648         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4649         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4650         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4651         int64_t ret_ref = tag_ptr(ret_copy, true);
4652         return ret_ref;
4653 }
4654
4655 static jclass LDKNetAddress_IPv4_class = NULL;
4656 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4657 static jclass LDKNetAddress_IPv6_class = NULL;
4658 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4659 static jclass LDKNetAddress_OnionV2_class = NULL;
4660 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4661 static jclass LDKNetAddress_OnionV3_class = NULL;
4662 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4663 static jclass LDKNetAddress_Hostname_class = NULL;
4664 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4666         LDKNetAddress_IPv4_class =
4667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4668         CHECK(LDKNetAddress_IPv4_class != NULL);
4669         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4670         CHECK(LDKNetAddress_IPv4_meth != NULL);
4671         LDKNetAddress_IPv6_class =
4672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4673         CHECK(LDKNetAddress_IPv6_class != NULL);
4674         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4675         CHECK(LDKNetAddress_IPv6_meth != NULL);
4676         LDKNetAddress_OnionV2_class =
4677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4678         CHECK(LDKNetAddress_OnionV2_class != NULL);
4679         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4680         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4681         LDKNetAddress_OnionV3_class =
4682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4683         CHECK(LDKNetAddress_OnionV3_class != NULL);
4684         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4685         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4686         LDKNetAddress_Hostname_class =
4687                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4688         CHECK(LDKNetAddress_Hostname_class != NULL);
4689         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4690         CHECK(LDKNetAddress_Hostname_meth != NULL);
4691 }
4692 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4693         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
4694         switch(obj->tag) {
4695                 case LDKNetAddress_IPv4: {
4696                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4697                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4698                         int16_t port_conv = obj->i_pv4.port;
4699                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4700                 }
4701                 case LDKNetAddress_IPv6: {
4702                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4703                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4704                         int16_t port_conv = obj->i_pv6.port;
4705                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4706                 }
4707                 case LDKNetAddress_OnionV2: {
4708                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4709                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4710                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4711                 }
4712                 case LDKNetAddress_OnionV3: {
4713                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4714                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4715                         int16_t checksum_conv = obj->onion_v3.checksum;
4716                         int8_t version_conv = obj->onion_v3.version;
4717                         int16_t port_conv = obj->onion_v3.port;
4718                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4719                 }
4720                 case LDKNetAddress_Hostname: {
4721                         LDKHostname hostname_var = obj->hostname.hostname;
4722                         int64_t hostname_ref = 0;
4723                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4724                         hostname_ref = tag_ptr(hostname_var.inner, false);
4725                         int16_t port_conv = obj->hostname.port;
4726                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4727                 }
4728                 default: abort();
4729         }
4730 }
4731 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4732         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4733         for (size_t i = 0; i < ret.datalen; i++) {
4734                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4735         }
4736         return ret;
4737 }
4738 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4739         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4740         ret.is_owned = false;
4741         return ret;
4742 }
4743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4744         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4745         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4746         int64_t ret_ref = 0;
4747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4749         return ret_ref;
4750 }
4751
4752 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4753 CHECK(!owner->result_ok);
4754         return DecodeError_clone(&*owner->contents.err);
4755 }
4756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4757         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4758         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4759         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4760         int64_t ret_ref = tag_ptr(ret_copy, true);
4761         return ret_ref;
4762 }
4763
4764 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4765         LDKNodeAlias ret = *owner->contents.result;
4766         ret.is_owned = false;
4767         return ret;
4768 }
4769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4770         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4771         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4772         int64_t ret_ref = 0;
4773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4775         return ret_ref;
4776 }
4777
4778 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4779 CHECK(!owner->result_ok);
4780         return DecodeError_clone(&*owner->contents.err);
4781 }
4782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4783         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4784         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4785         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4786         int64_t ret_ref = tag_ptr(ret_copy, true);
4787         return ret_ref;
4788 }
4789
4790 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4791         LDKNodeInfo ret = *owner->contents.result;
4792         ret.is_owned = false;
4793         return ret;
4794 }
4795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4796         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4797         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4798         int64_t ret_ref = 0;
4799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4801         return ret_ref;
4802 }
4803
4804 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4805 CHECK(!owner->result_ok);
4806         return DecodeError_clone(&*owner->contents.err);
4807 }
4808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4809         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4810         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4811         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4812         int64_t ret_ref = tag_ptr(ret_copy, true);
4813         return ret_ref;
4814 }
4815
4816 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4817         LDKNetworkGraph ret = *owner->contents.result;
4818         ret.is_owned = false;
4819         return ret;
4820 }
4821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4822         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4823         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4824         int64_t ret_ref = 0;
4825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4827         return ret_ref;
4828 }
4829
4830 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4831 CHECK(!owner->result_ok);
4832         return DecodeError_clone(&*owner->contents.err);
4833 }
4834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4835         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4836         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4837         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4838         int64_t ret_ref = tag_ptr(ret_copy, true);
4839         return ret_ref;
4840 }
4841
4842 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4843 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4844 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4845 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4847         LDKCOption_CVec_NetAddressZZ_Some_class =
4848                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4849         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4850         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4851         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4852         LDKCOption_CVec_NetAddressZZ_None_class =
4853                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4854         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4855         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4856         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4857 }
4858 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4859         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4860         switch(obj->tag) {
4861                 case LDKCOption_CVec_NetAddressZZ_Some: {
4862                         LDKCVec_NetAddressZ some_var = obj->some;
4863                         int64_tArray some_arr = NULL;
4864                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4865                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4866                         for (size_t m = 0; m < some_var.datalen; m++) {
4867                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4868                                 some_arr_ptr[m] = some_conv_12_ref;
4869                         }
4870                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4871                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4872                 }
4873                 case LDKCOption_CVec_NetAddressZZ_None: {
4874                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4875                 }
4876                 default: abort();
4877         }
4878 }
4879 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4880         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
4881         ret.is_owned = false;
4882         return ret;
4883 }
4884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4885         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4886         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4887         int64_t ret_ref = 0;
4888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4890         return ret_ref;
4891 }
4892
4893 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4894 CHECK(!owner->result_ok);
4895         return DecodeError_clone(&*owner->contents.err);
4896 }
4897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4898         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4899         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4900         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4901         int64_t ret_ref = tag_ptr(ret_copy, true);
4902         return ret_ref;
4903 }
4904
4905 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4906         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
4907         ret.is_owned = false;
4908         return ret;
4909 }
4910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4911         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4912         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4913         int64_t ret_ref = 0;
4914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4916         return ret_ref;
4917 }
4918
4919 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4920 CHECK(!owner->result_ok);
4921         return DecodeError_clone(&*owner->contents.err);
4922 }
4923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4924         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4925         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4926         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4927         int64_t ret_ref = tag_ptr(ret_copy, true);
4928         return ret_ref;
4929 }
4930
4931 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4932 CHECK(owner->result_ok);
4933         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4934 }
4935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4936         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4937         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4938         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4939         int64_t ret_ref = tag_ptr(ret_copy, true);
4940         return ret_ref;
4941 }
4942
4943 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4944 CHECK(!owner->result_ok);
4945         return DecodeError_clone(&*owner->contents.err);
4946 }
4947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4948         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4949         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4950         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4951         int64_t ret_ref = tag_ptr(ret_copy, true);
4952         return ret_ref;
4953 }
4954
4955 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4956         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4957         for (size_t i = 0; i < ret.datalen; i++) {
4958                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4959         }
4960         return ret;
4961 }
4962 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4963         return owner->a;
4964 }
4965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4966         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4967         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4969         return ret_arr;
4970 }
4971
4972 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4973         return owner->b;
4974 }
4975 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4976         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4977         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4978         jobjectArray ret_arr = NULL;
4979         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4980         ;
4981         for (size_t i = 0; i < ret_var.datalen; i++) {
4982                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4983                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4984                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4985         }
4986         
4987         return ret_arr;
4988 }
4989
4990 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4991 CHECK(owner->result_ok);
4992         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4993 }
4994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4995         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
4996         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4997         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4998         return tag_ptr(ret_conv, true);
4999 }
5000
5001 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5002 CHECK(!owner->result_ok);
5003         return *owner->contents.err;
5004 }
5005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5006         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5007         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5008 }
5009
5010 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5011 CHECK(owner->result_ok);
5012         return *owner->contents.result;
5013 }
5014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5015         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5016         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5018         return ret_arr;
5019 }
5020
5021 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5022 CHECK(!owner->result_ok);
5023         return *owner->contents.err;
5024 }
5025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5026         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5027         CResult_SignatureNoneZ_get_err(owner_conv);
5028 }
5029
5030 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5031         return owner->a;
5032 }
5033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5034         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5035         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
5037         return ret_arr;
5038 }
5039
5040 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5041         return owner->b;
5042 }
5043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5044         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5045         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
5047         return ret_arr;
5048 }
5049
5050 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5051 CHECK(owner->result_ok);
5052         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
5053 }
5054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5055         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5056         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
5057         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
5058         return tag_ptr(ret_conv, true);
5059 }
5060
5061 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5062 CHECK(!owner->result_ok);
5063         return *owner->contents.err;
5064 }
5065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5066         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5067         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
5068 }
5069
5070 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5071 CHECK(owner->result_ok);
5072         return *owner->contents.result;
5073 }
5074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5075         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5076         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5077         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
5078         return ret_arr;
5079 }
5080
5081 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5082 CHECK(!owner->result_ok);
5083         return *owner->contents.err;
5084 }
5085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5086         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5087         CResult_SecretKeyNoneZ_get_err(owner_conv);
5088 }
5089
5090 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5091 CHECK(owner->result_ok);
5092         return *owner->contents.result;
5093 }
5094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5095         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5096         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5098         return ret_arr;
5099 }
5100
5101 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5102 CHECK(!owner->result_ok);
5103         return *owner->contents.err;
5104 }
5105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5106         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5107         CResult_PublicKeyNoneZ_get_err(owner_conv);
5108 }
5109
5110 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5111 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5112 static jclass LDKCOption_ScalarZ_None_class = NULL;
5113 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5115         LDKCOption_ScalarZ_Some_class =
5116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5117         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5118         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5119         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5120         LDKCOption_ScalarZ_None_class =
5121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5122         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5123         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5124         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5125 }
5126 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5127         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5128         switch(obj->tag) {
5129                 case LDKCOption_ScalarZ_Some: {
5130                         LDKBigEndianScalar* some_ref = &obj->some;
5131                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5132                 }
5133                 case LDKCOption_ScalarZ_None: {
5134                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5135                 }
5136                 default: abort();
5137         }
5138 }
5139 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5140 CHECK(owner->result_ok);
5141         return ThirtyTwoBytes_clone(&*owner->contents.result);
5142 }
5143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5144         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5145         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5146         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5147         return ret_arr;
5148 }
5149
5150 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5151 CHECK(!owner->result_ok);
5152         return *owner->contents.err;
5153 }
5154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5155         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5156         CResult_SharedSecretNoneZ_get_err(owner_conv);
5157 }
5158
5159 typedef struct LDKBaseSign_JCalls {
5160         atomic_size_t refcnt;
5161         JavaVM *vm;
5162         jweak o;
5163         jmethodID get_per_commitment_point_meth;
5164         jmethodID release_commitment_secret_meth;
5165         jmethodID validate_holder_commitment_meth;
5166         jmethodID channel_keys_id_meth;
5167         jmethodID sign_counterparty_commitment_meth;
5168         jmethodID validate_counterparty_revocation_meth;
5169         jmethodID sign_holder_commitment_and_htlcs_meth;
5170         jmethodID sign_justice_revoked_output_meth;
5171         jmethodID sign_justice_revoked_htlc_meth;
5172         jmethodID sign_counterparty_htlc_transaction_meth;
5173         jmethodID sign_closing_transaction_meth;
5174         jmethodID sign_holder_anchor_input_meth;
5175         jmethodID sign_channel_announcement_meth;
5176         jmethodID ready_channel_meth;
5177 } LDKBaseSign_JCalls;
5178 static void LDKBaseSign_JCalls_free(void* this_arg) {
5179         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5180         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5181                 JNIEnv *env;
5182                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5183                 if (get_jenv_res == JNI_EDETACHED) {
5184                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5185                 } else {
5186                         DO_ASSERT(get_jenv_res == JNI_OK);
5187                 }
5188                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5189                 if (get_jenv_res == JNI_EDETACHED) {
5190                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5191                 }
5192                 FREE(j_calls);
5193         }
5194 }
5195 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5196         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5197         JNIEnv *env;
5198         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5199         if (get_jenv_res == JNI_EDETACHED) {
5200                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5201         } else {
5202                 DO_ASSERT(get_jenv_res == JNI_OK);
5203         }
5204         int64_t idx_conv = idx;
5205         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5206         CHECK(obj != NULL);
5207         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5208         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5209                 (*env)->ExceptionDescribe(env);
5210                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
5211         }
5212         LDKPublicKey ret_ref;
5213         CHECK((*env)->GetArrayLength(env, ret) == 33);
5214         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5215         if (get_jenv_res == JNI_EDETACHED) {
5216                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5217         }
5218         return ret_ref;
5219 }
5220 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5221         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5222         JNIEnv *env;
5223         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5224         if (get_jenv_res == JNI_EDETACHED) {
5225                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5226         } else {
5227                 DO_ASSERT(get_jenv_res == JNI_OK);
5228         }
5229         int64_t idx_conv = idx;
5230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5231         CHECK(obj != NULL);
5232         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5233         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5234                 (*env)->ExceptionDescribe(env);
5235                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
5236         }
5237         LDKThirtyTwoBytes ret_ref;
5238         CHECK((*env)->GetArrayLength(env, ret) == 32);
5239         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5240         if (get_jenv_res == JNI_EDETACHED) {
5241                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5242         }
5243         return ret_ref;
5244 }
5245 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5246         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5247         JNIEnv *env;
5248         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5249         if (get_jenv_res == JNI_EDETACHED) {
5250                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5251         } else {
5252                 DO_ASSERT(get_jenv_res == JNI_OK);
5253         }
5254         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5255         int64_t holder_tx_ref = 0;
5256         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5257         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5258         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5259         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5260         jobjectArray preimages_arr = NULL;
5261         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5262         ;
5263         for (size_t i = 0; i < preimages_var.datalen; i++) {
5264                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5265                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5266                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5267         }
5268         
5269         FREE(preimages_var.data);
5270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5271         CHECK(obj != NULL);
5272         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5274                 (*env)->ExceptionDescribe(env);
5275                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
5276         }
5277         void* ret_ptr = untag_ptr(ret);
5278         CHECK_ACCESS(ret_ptr);
5279         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5280         FREE(untag_ptr(ret));
5281         if (get_jenv_res == JNI_EDETACHED) {
5282                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5283         }
5284         return ret_conv;
5285 }
5286 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
5287         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5288         JNIEnv *env;
5289         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5290         if (get_jenv_res == JNI_EDETACHED) {
5291                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5292         } else {
5293                 DO_ASSERT(get_jenv_res == JNI_OK);
5294         }
5295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5296         CHECK(obj != NULL);
5297         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5298         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5299                 (*env)->ExceptionDescribe(env);
5300                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
5301         }
5302         LDKThirtyTwoBytes ret_ref;
5303         CHECK((*env)->GetArrayLength(env, ret) == 32);
5304         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5305         if (get_jenv_res == JNI_EDETACHED) {
5306                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5307         }
5308         return ret_ref;
5309 }
5310 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5311         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5312         JNIEnv *env;
5313         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5314         if (get_jenv_res == JNI_EDETACHED) {
5315                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5316         } else {
5317                 DO_ASSERT(get_jenv_res == JNI_OK);
5318         }
5319         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5320         int64_t commitment_tx_ref = 0;
5321         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5322         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5323         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5324         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5325         jobjectArray preimages_arr = NULL;
5326         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5327         ;
5328         for (size_t i = 0; i < preimages_var.datalen; i++) {
5329                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5330                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5331                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5332         }
5333         
5334         FREE(preimages_var.data);
5335         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5336         CHECK(obj != NULL);
5337         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5338         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5339                 (*env)->ExceptionDescribe(env);
5340                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
5341         }
5342         void* ret_ptr = untag_ptr(ret);
5343         CHECK_ACCESS(ret_ptr);
5344         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5345         FREE(untag_ptr(ret));
5346         if (get_jenv_res == JNI_EDETACHED) {
5347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5348         }
5349         return ret_conv;
5350 }
5351 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5352         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5353         JNIEnv *env;
5354         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5355         if (get_jenv_res == JNI_EDETACHED) {
5356                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5357         } else {
5358                 DO_ASSERT(get_jenv_res == JNI_OK);
5359         }
5360         int64_t idx_conv = idx;
5361         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
5362         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
5363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5364         CHECK(obj != NULL);
5365         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
5366         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5367                 (*env)->ExceptionDescribe(env);
5368                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
5369         }
5370         void* ret_ptr = untag_ptr(ret);
5371         CHECK_ACCESS(ret_ptr);
5372         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5373         FREE(untag_ptr(ret));
5374         if (get_jenv_res == JNI_EDETACHED) {
5375                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5376         }
5377         return ret_conv;
5378 }
5379 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
5380         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5381         JNIEnv *env;
5382         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5383         if (get_jenv_res == JNI_EDETACHED) {
5384                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5385         } else {
5386                 DO_ASSERT(get_jenv_res == JNI_OK);
5387         }
5388         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
5389         int64_t commitment_tx_ref = 0;
5390         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5391         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5392         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5394         CHECK(obj != NULL);
5395         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5396         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5397                 (*env)->ExceptionDescribe(env);
5398                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5399         }
5400         void* ret_ptr = untag_ptr(ret);
5401         CHECK_ACCESS(ret_ptr);
5402         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5403         FREE(untag_ptr(ret));
5404         if (get_jenv_res == JNI_EDETACHED) {
5405                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5406         }
5407         return ret_conv;
5408 }
5409 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
5410         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5411         JNIEnv *env;
5412         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5413         if (get_jenv_res == JNI_EDETACHED) {
5414                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5415         } else {
5416                 DO_ASSERT(get_jenv_res == JNI_OK);
5417         }
5418         LDKTransaction justice_tx_var = justice_tx;
5419         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5420         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5421         Transaction_free(justice_tx_var);
5422         int64_t input_conv = input;
5423         int64_t amount_conv = amount;
5424         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5425         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5426         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5427         CHECK(obj != NULL);
5428         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr);
5429         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5430                 (*env)->ExceptionDescribe(env);
5431                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5432         }
5433         void* ret_ptr = untag_ptr(ret);
5434         CHECK_ACCESS(ret_ptr);
5435         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5436         FREE(untag_ptr(ret));
5437         if (get_jenv_res == JNI_EDETACHED) {
5438                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5439         }
5440         return ret_conv;
5441 }
5442 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
5443         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5444         JNIEnv *env;
5445         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5446         if (get_jenv_res == JNI_EDETACHED) {
5447                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5448         } else {
5449                 DO_ASSERT(get_jenv_res == JNI_OK);
5450         }
5451         LDKTransaction justice_tx_var = justice_tx;
5452         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5453         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5454         Transaction_free(justice_tx_var);
5455         int64_t input_conv = input;
5456         int64_t amount_conv = amount;
5457         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5458         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5459         LDKHTLCOutputInCommitment htlc_var = *htlc;
5460         int64_t htlc_ref = 0;
5461         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5462         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5463         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5464         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5465         CHECK(obj != NULL);
5466         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr, htlc_ref);
5467         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5468                 (*env)->ExceptionDescribe(env);
5469                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5470         }
5471         void* ret_ptr = untag_ptr(ret);
5472         CHECK_ACCESS(ret_ptr);
5473         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5474         FREE(untag_ptr(ret));
5475         if (get_jenv_res == JNI_EDETACHED) {
5476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5477         }
5478         return ret_conv;
5479 }
5480 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
5481         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5482         JNIEnv *env;
5483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5484         if (get_jenv_res == JNI_EDETACHED) {
5485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5486         } else {
5487                 DO_ASSERT(get_jenv_res == JNI_OK);
5488         }
5489         LDKTransaction htlc_tx_var = htlc_tx;
5490         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5491         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5492         Transaction_free(htlc_tx_var);
5493         int64_t input_conv = input;
5494         int64_t amount_conv = amount;
5495         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5496         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5497         LDKHTLCOutputInCommitment htlc_var = *htlc;
5498         int64_t htlc_ref = 0;
5499         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5500         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5501         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5503         CHECK(obj != NULL);
5504         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input_conv, amount_conv, per_commitment_point_arr, htlc_ref);
5505         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5506                 (*env)->ExceptionDescribe(env);
5507                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5508         }
5509         void* ret_ptr = untag_ptr(ret);
5510         CHECK_ACCESS(ret_ptr);
5511         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5512         FREE(untag_ptr(ret));
5513         if (get_jenv_res == JNI_EDETACHED) {
5514                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5515         }
5516         return ret_conv;
5517 }
5518 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5519         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5520         JNIEnv *env;
5521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5522         if (get_jenv_res == JNI_EDETACHED) {
5523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5524         } else {
5525                 DO_ASSERT(get_jenv_res == JNI_OK);
5526         }
5527         LDKClosingTransaction closing_tx_var = *closing_tx;
5528         int64_t closing_tx_ref = 0;
5529         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5530         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5531         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
5532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5533         CHECK(obj != NULL);
5534         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5536                 (*env)->ExceptionDescribe(env);
5537                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5538         }
5539         void* ret_ptr = untag_ptr(ret);
5540         CHECK_ACCESS(ret_ptr);
5541         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5542         FREE(untag_ptr(ret));
5543         if (get_jenv_res == JNI_EDETACHED) {
5544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5545         }
5546         return ret_conv;
5547 }
5548 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKBaseSign_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
5549         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5550         JNIEnv *env;
5551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5552         if (get_jenv_res == JNI_EDETACHED) {
5553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5554         } else {
5555                 DO_ASSERT(get_jenv_res == JNI_OK);
5556         }
5557         LDKTransaction anchor_tx_var = anchor_tx;
5558         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
5559         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
5560         Transaction_free(anchor_tx_var);
5561         int64_t input_conv = input;
5562         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5563         CHECK(obj != NULL);
5564         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
5565         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5566                 (*env)->ExceptionDescribe(env);
5567                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKBaseSign from rust threw an exception.");
5568         }
5569         void* ret_ptr = untag_ptr(ret);
5570         CHECK_ACCESS(ret_ptr);
5571         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5572         FREE(untag_ptr(ret));
5573         if (get_jenv_res == JNI_EDETACHED) {
5574                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5575         }
5576         return ret_conv;
5577 }
5578 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5579         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5580         JNIEnv *env;
5581         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5582         if (get_jenv_res == JNI_EDETACHED) {
5583                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5584         } else {
5585                 DO_ASSERT(get_jenv_res == JNI_OK);
5586         }
5587         LDKUnsignedChannelAnnouncement msg_var = *msg;
5588         int64_t msg_ref = 0;
5589         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5591         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
5592         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5593         CHECK(obj != NULL);
5594         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5595         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5596                 (*env)->ExceptionDescribe(env);
5597                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5598         }
5599         void* ret_ptr = untag_ptr(ret);
5600         CHECK_ACCESS(ret_ptr);
5601         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5602         FREE(untag_ptr(ret));
5603         if (get_jenv_res == JNI_EDETACHED) {
5604                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5605         }
5606         return ret_conv;
5607 }
5608 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5609         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5610         JNIEnv *env;
5611         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5612         if (get_jenv_res == JNI_EDETACHED) {
5613                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5614         } else {
5615                 DO_ASSERT(get_jenv_res == JNI_OK);
5616         }
5617         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5618         int64_t channel_parameters_ref = 0;
5619         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5620         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5621         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5623         CHECK(obj != NULL);
5624         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5625         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5626                 (*env)->ExceptionDescribe(env);
5627                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5628         }
5629         if (get_jenv_res == JNI_EDETACHED) {
5630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5631         }
5632 }
5633 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5634         jclass c = (*env)->GetObjectClass(env, o);
5635         CHECK(c != NULL);
5636         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5637         atomic_init(&calls->refcnt, 1);
5638         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5639         calls->o = (*env)->NewWeakGlobalRef(env, o);
5640         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5641         CHECK(calls->get_per_commitment_point_meth != NULL);
5642         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5643         CHECK(calls->release_commitment_secret_meth != NULL);
5644         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5645         CHECK(calls->validate_holder_commitment_meth != NULL);
5646         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5647         CHECK(calls->channel_keys_id_meth != NULL);
5648         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5649         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5650         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5651         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5652         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5653         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5654         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5655         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5656         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5657         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5658         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5659         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5660         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5661         CHECK(calls->sign_closing_transaction_meth != NULL);
5662         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
5663         CHECK(calls->sign_holder_anchor_input_meth != NULL);
5664         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5665         CHECK(calls->sign_channel_announcement_meth != NULL);
5666         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5667         CHECK(calls->ready_channel_meth != NULL);
5668
5669         LDKChannelPublicKeys pubkeys_conv;
5670         pubkeys_conv.inner = untag_ptr(pubkeys);
5671         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5672         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5673
5674         LDKBaseSign ret = {
5675                 .this_arg = (void*) calls,
5676                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5677                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5678                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5679                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5680                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5681                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5682                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5683                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5684                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5685                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5686                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5687                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKBaseSign_jcall,
5688                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5689                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5690                 .free = LDKBaseSign_JCalls_free,
5691                 .pubkeys = pubkeys_conv,
5692                 .set_pubkeys = NULL,
5693         };
5694         return ret;
5695 }
5696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5697         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5698         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5699         return tag_ptr(res_ptr, true);
5700 }
5701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5702         void* this_arg_ptr = untag_ptr(this_arg);
5703         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5704         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5705         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5707         return ret_arr;
5708 }
5709
5710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5711         void* this_arg_ptr = untag_ptr(this_arg);
5712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5713         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5716         return ret_arr;
5717 }
5718
5719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx, jobjectArray preimages) {
5720         void* this_arg_ptr = untag_ptr(this_arg);
5721         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5722         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5723         LDKHolderCommitmentTransaction holder_tx_conv;
5724         holder_tx_conv.inner = untag_ptr(holder_tx);
5725         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5726         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5727         holder_tx_conv.is_owned = false;
5728         LDKCVec_PaymentPreimageZ preimages_constr;
5729         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5730         if (preimages_constr.datalen > 0)
5731                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5732         else
5733                 preimages_constr.data = NULL;
5734         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5735                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5736                 LDKThirtyTwoBytes preimages_conv_8_ref;
5737                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5738                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5739                 preimages_constr.data[i] = preimages_conv_8_ref;
5740         }
5741         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5742         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5743         return tag_ptr(ret_conv, true);
5744 }
5745
5746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5747         void* this_arg_ptr = untag_ptr(this_arg);
5748         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5749         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5750         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5751         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5752         return ret_arr;
5753 }
5754
5755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx, jobjectArray preimages) {
5756         void* this_arg_ptr = untag_ptr(this_arg);
5757         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5758         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5759         LDKCommitmentTransaction commitment_tx_conv;
5760         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5761         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5762         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5763         commitment_tx_conv.is_owned = false;
5764         LDKCVec_PaymentPreimageZ preimages_constr;
5765         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5766         if (preimages_constr.datalen > 0)
5767                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5768         else
5769                 preimages_constr.data = NULL;
5770         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5771                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5772                 LDKThirtyTwoBytes preimages_conv_8_ref;
5773                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5774                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5775                 preimages_constr.data[i] = preimages_conv_8_ref;
5776         }
5777         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5778         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5779         return tag_ptr(ret_conv, true);
5780 }
5781
5782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
5783         void* this_arg_ptr = untag_ptr(this_arg);
5784         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5785         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5786         unsigned char secret_arr[32];
5787         CHECK((*env)->GetArrayLength(env, secret) == 32);
5788         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5789         unsigned char (*secret_ref)[32] = &secret_arr;
5790         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5791         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5792         return tag_ptr(ret_conv, true);
5793 }
5794
5795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
5796         void* this_arg_ptr = untag_ptr(this_arg);
5797         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5798         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5799         LDKHolderCommitmentTransaction commitment_tx_conv;
5800         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5801         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5802         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5803         commitment_tx_conv.is_owned = false;
5804         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5805         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5806         return tag_ptr(ret_conv, true);
5807 }
5808
5809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
5810         void* this_arg_ptr = untag_ptr(this_arg);
5811         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5812         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5813         LDKTransaction justice_tx_ref;
5814         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5815         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5816         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5817         justice_tx_ref.data_is_owned = true;
5818         unsigned char per_commitment_key_arr[32];
5819         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5820         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5821         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5822         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5823         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5824         return tag_ptr(ret_conv, true);
5825 }
5826
5827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
5828         void* this_arg_ptr = untag_ptr(this_arg);
5829         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5830         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5831         LDKTransaction justice_tx_ref;
5832         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5833         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5834         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5835         justice_tx_ref.data_is_owned = true;
5836         unsigned char per_commitment_key_arr[32];
5837         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5838         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5839         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5840         LDKHTLCOutputInCommitment htlc_conv;
5841         htlc_conv.inner = untag_ptr(htlc);
5842         htlc_conv.is_owned = ptr_is_owned(htlc);
5843         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5844         htlc_conv.is_owned = false;
5845         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5846         *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
5847         return tag_ptr(ret_conv, true);
5848 }
5849
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
5851         void* this_arg_ptr = untag_ptr(this_arg);
5852         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5853         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5854         LDKTransaction htlc_tx_ref;
5855         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5856         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5857         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5858         htlc_tx_ref.data_is_owned = true;
5859         LDKPublicKey per_commitment_point_ref;
5860         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5861         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5862         LDKHTLCOutputInCommitment htlc_conv;
5863         htlc_conv.inner = untag_ptr(htlc);
5864         htlc_conv.is_owned = ptr_is_owned(htlc);
5865         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5866         htlc_conv.is_owned = false;
5867         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5868         *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);
5869         return tag_ptr(ret_conv, true);
5870 }
5871
5872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
5873         void* this_arg_ptr = untag_ptr(this_arg);
5874         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5875         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5876         LDKClosingTransaction closing_tx_conv;
5877         closing_tx_conv.inner = untag_ptr(closing_tx);
5878         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
5879         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5880         closing_tx_conv.is_owned = false;
5881         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5882         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5883         return tag_ptr(ret_conv, true);
5884 }
5885
5886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1anchor_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray anchor_tx, int64_t input) {
5887         void* this_arg_ptr = untag_ptr(this_arg);
5888         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5889         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5890         LDKTransaction anchor_tx_ref;
5891         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
5892         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
5893         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
5894         anchor_tx_ref.data_is_owned = true;
5895         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5896         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
5897         return tag_ptr(ret_conv, true);
5898 }
5899
5900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5901         void* this_arg_ptr = untag_ptr(this_arg);
5902         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5903         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5904         LDKUnsignedChannelAnnouncement msg_conv;
5905         msg_conv.inner = untag_ptr(msg);
5906         msg_conv.is_owned = ptr_is_owned(msg);
5907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5908         msg_conv.is_owned = false;
5909         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5910         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5911         return tag_ptr(ret_conv, true);
5912 }
5913
5914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5915         void* this_arg_ptr = untag_ptr(this_arg);
5916         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5917         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5918         LDKChannelTransactionParameters channel_parameters_conv;
5919         channel_parameters_conv.inner = untag_ptr(channel_parameters);
5920         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
5921         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5922         channel_parameters_conv.is_owned = false;
5923         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5924 }
5925
5926 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5927         if (this_arg->set_pubkeys != NULL)
5928                 this_arg->set_pubkeys(this_arg);
5929         return this_arg->pubkeys;
5930 }
5931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5932         void* this_arg_ptr = untag_ptr(this_arg);
5933         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5934         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5935         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5936         int64_t ret_ref = 0;
5937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5939         return ret_ref;
5940 }
5941
5942 typedef struct LDKSign_JCalls {
5943         atomic_size_t refcnt;
5944         JavaVM *vm;
5945         jweak o;
5946         LDKBaseSign_JCalls* BaseSign;
5947         jmethodID write_meth;
5948 } LDKSign_JCalls;
5949 static void LDKSign_JCalls_free(void* this_arg) {
5950         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5951         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5952                 JNIEnv *env;
5953                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5954                 if (get_jenv_res == JNI_EDETACHED) {
5955                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5956                 } else {
5957                         DO_ASSERT(get_jenv_res == JNI_OK);
5958                 }
5959                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5960                 if (get_jenv_res == JNI_EDETACHED) {
5961                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5962                 }
5963                 FREE(j_calls);
5964         }
5965 }
5966 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5967         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5968         JNIEnv *env;
5969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5970         if (get_jenv_res == JNI_EDETACHED) {
5971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5972         } else {
5973                 DO_ASSERT(get_jenv_res == JNI_OK);
5974         }
5975         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5976         CHECK(obj != NULL);
5977         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5978         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5979                 (*env)->ExceptionDescribe(env);
5980                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5981         }
5982         LDKCVec_u8Z ret_ref;
5983         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5984         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5985         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5986         if (get_jenv_res == JNI_EDETACHED) {
5987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5988         }
5989         return ret_ref;
5990 }
5991 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5992         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5993         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5994         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5995 }
5996 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5997         jclass c = (*env)->GetObjectClass(env, o);
5998         CHECK(c != NULL);
5999         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
6000         atomic_init(&calls->refcnt, 1);
6001         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6002         calls->o = (*env)->NewWeakGlobalRef(env, o);
6003         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6004         CHECK(calls->write_meth != NULL);
6005
6006         LDKChannelPublicKeys pubkeys_conv;
6007         pubkeys_conv.inner = untag_ptr(pubkeys);
6008         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6009         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6010
6011         LDKSign ret = {
6012                 .this_arg = (void*) calls,
6013                 .write = write_LDKSign_jcall,
6014                 .cloned = LDKSign_JCalls_cloned,
6015                 .free = LDKSign_JCalls_free,
6016                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
6017         };
6018         calls->BaseSign = ret.BaseSign.this_arg;
6019         return ret;
6020 }
6021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6022         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
6023         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
6024         return tag_ptr(res_ptr, true);
6025 }
6026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
6027         LDKSign *inp = (LDKSign *)untag_ptr(arg);
6028         return tag_ptr(&inp->BaseSign, false);
6029 }
6030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6031         void* this_arg_ptr = untag_ptr(this_arg);
6032         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6033         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
6034         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6035         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6036         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6037         CVec_u8Z_free(ret_var);
6038         return ret_arr;
6039 }
6040
6041 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6042 CHECK(owner->result_ok);
6043         return Sign_clone(&*owner->contents.result);
6044 }
6045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6046         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6047         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6048         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
6049         return tag_ptr(ret_ret, true);
6050 }
6051
6052 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6053 CHECK(!owner->result_ok);
6054         return DecodeError_clone(&*owner->contents.err);
6055 }
6056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6057         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6058         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6059         *ret_copy = CResult_SignDecodeErrorZ_get_err(owner_conv);
6060         int64_t ret_ref = tag_ptr(ret_copy, true);
6061         return ret_ref;
6062 }
6063
6064 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6065 CHECK(owner->result_ok);
6066         return *owner->contents.result;
6067 }
6068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6069         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6070         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
6071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
6072         return ret_arr;
6073 }
6074
6075 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6076 CHECK(!owner->result_ok);
6077         return *owner->contents.err;
6078 }
6079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6080         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6081         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
6082 }
6083
6084 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6085         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6086         for (size_t i = 0; i < ret.datalen; i++) {
6087                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6088         }
6089         return ret;
6090 }
6091 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6092 CHECK(owner->result_ok);
6093         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6094 }
6095 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6096         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6097         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6098         jobjectArray ret_arr = NULL;
6099         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6100         ;
6101         for (size_t i = 0; i < ret_var.datalen; i++) {
6102                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6103                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6104                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6105                 CVec_u8Z_free(ret_conv_8_var);
6106                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6107         }
6108         
6109         FREE(ret_var.data);
6110         return ret_arr;
6111 }
6112
6113 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6114 CHECK(!owner->result_ok);
6115         return *owner->contents.err;
6116 }
6117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6118         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6119         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6120 }
6121
6122 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6123         LDKInMemorySigner ret = *owner->contents.result;
6124         ret.is_owned = false;
6125         return ret;
6126 }
6127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6128         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6129         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6130         int64_t ret_ref = 0;
6131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6133         return ret_ref;
6134 }
6135
6136 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6137 CHECK(!owner->result_ok);
6138         return DecodeError_clone(&*owner->contents.err);
6139 }
6140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6141         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6142         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6143         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6144         int64_t ret_ref = tag_ptr(ret_copy, true);
6145         return ret_ref;
6146 }
6147
6148 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6149         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6150         for (size_t i = 0; i < ret.datalen; i++) {
6151                 ret.data[i] = TxOut_clone(&orig->data[i]);
6152         }
6153         return ret;
6154 }
6155 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6156 CHECK(owner->result_ok);
6157         return *owner->contents.result;
6158 }
6159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6160         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6161         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6162         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6163         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6164         return ret_arr;
6165 }
6166
6167 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6168 CHECK(!owner->result_ok);
6169         return *owner->contents.err;
6170 }
6171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6172         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6173         CResult_TransactionNoneZ_get_err(owner_conv);
6174 }
6175
6176 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6177         return ThirtyTwoBytes_clone(&owner->a);
6178 }
6179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6180         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6181         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6183         return ret_arr;
6184 }
6185
6186 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6187         LDKChannelMonitor ret = owner->b;
6188         ret.is_owned = false;
6189         return ret;
6190 }
6191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6192         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6193         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6194         int64_t ret_ref = 0;
6195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6197         return ret_ref;
6198 }
6199
6200 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6201         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6202         for (size_t i = 0; i < ret.datalen; i++) {
6203                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6204         }
6205         return ret;
6206 }
6207 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6208 CHECK(owner->result_ok);
6209         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6210 }
6211 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6212         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6213         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6214         int64_tArray ret_arr = NULL;
6215         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6216         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6217         for (size_t j = 0; j < ret_var.datalen; j++) {
6218                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6219                 *ret_conv_35_conv = ret_var.data[j];
6220                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6221         }
6222         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6223         FREE(ret_var.data);
6224         return ret_arr;
6225 }
6226
6227 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6228 CHECK(!owner->result_ok);
6229         return *owner->contents.err;
6230 }
6231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6232         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6233         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6234         return ret_conv;
6235 }
6236
6237 static jclass LDKCOption_u16Z_Some_class = NULL;
6238 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6239 static jclass LDKCOption_u16Z_None_class = NULL;
6240 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6242         LDKCOption_u16Z_Some_class =
6243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6244         CHECK(LDKCOption_u16Z_Some_class != NULL);
6245         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6246         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6247         LDKCOption_u16Z_None_class =
6248                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6249         CHECK(LDKCOption_u16Z_None_class != NULL);
6250         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6251         CHECK(LDKCOption_u16Z_None_meth != NULL);
6252 }
6253 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6254         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6255         switch(obj->tag) {
6256                 case LDKCOption_u16Z_Some: {
6257                         int16_t some_conv = obj->some;
6258                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6259                 }
6260                 case LDKCOption_u16Z_None: {
6261                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6262                 }
6263                 default: abort();
6264         }
6265 }
6266 static jclass LDKAPIError_APIMisuseError_class = NULL;
6267 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
6268 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
6269 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
6270 static jclass LDKAPIError_RouteError_class = NULL;
6271 static jmethodID LDKAPIError_RouteError_meth = NULL;
6272 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
6273 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
6274 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
6275 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
6276 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
6277 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
6278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
6279         LDKAPIError_APIMisuseError_class =
6280                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
6281         CHECK(LDKAPIError_APIMisuseError_class != NULL);
6282         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
6283         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
6284         LDKAPIError_FeeRateTooHigh_class =
6285                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
6286         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
6287         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
6288         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
6289         LDKAPIError_RouteError_class =
6290                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
6291         CHECK(LDKAPIError_RouteError_class != NULL);
6292         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
6293         CHECK(LDKAPIError_RouteError_meth != NULL);
6294         LDKAPIError_ChannelUnavailable_class =
6295                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
6296         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
6297         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
6298         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
6299         LDKAPIError_MonitorUpdateInProgress_class =
6300                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
6301         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
6302         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
6303         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
6304         LDKAPIError_IncompatibleShutdownScript_class =
6305                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
6306         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
6307         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
6308         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
6309 }
6310 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6311         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
6312         switch(obj->tag) {
6313                 case LDKAPIError_APIMisuseError: {
6314                         LDKStr err_str = obj->api_misuse_error.err;
6315                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6316                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
6317                 }
6318                 case LDKAPIError_FeeRateTooHigh: {
6319                         LDKStr err_str = obj->fee_rate_too_high.err;
6320                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6321                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
6322                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
6323                 }
6324                 case LDKAPIError_RouteError: {
6325                         LDKStr err_str = obj->route_error.err;
6326                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6327                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
6328                 }
6329                 case LDKAPIError_ChannelUnavailable: {
6330                         LDKStr err_str = obj->channel_unavailable.err;
6331                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6332                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
6333                 }
6334                 case LDKAPIError_MonitorUpdateInProgress: {
6335                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
6336                 }
6337                 case LDKAPIError_IncompatibleShutdownScript: {
6338                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
6339                         int64_t script_ref = 0;
6340                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
6341                         script_ref = tag_ptr(script_var.inner, false);
6342                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
6343                 }
6344                 default: abort();
6345         }
6346 }
6347 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6348 CHECK(owner->result_ok);
6349         return *owner->contents.result;
6350 }
6351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6352         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6353         CResult_NoneAPIErrorZ_get_ok(owner_conv);
6354 }
6355
6356 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6357 CHECK(!owner->result_ok);
6358         return APIError_clone(&*owner->contents.err);
6359 }
6360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6361         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6362         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6363         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
6364         int64_t ret_ref = tag_ptr(ret_copy, true);
6365         return ret_ref;
6366 }
6367
6368 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
6369         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
6370         for (size_t i = 0; i < ret.datalen; i++) {
6371                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
6372         }
6373         return ret;
6374 }
6375 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
6376         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
6377         for (size_t i = 0; i < ret.datalen; i++) {
6378                 ret.data[i] = APIError_clone(&orig->data[i]);
6379         }
6380         return ret;
6381 }
6382 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6383 CHECK(owner->result_ok);
6384         return ThirtyTwoBytes_clone(&*owner->contents.result);
6385 }
6386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6387         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6388         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6390         return ret_arr;
6391 }
6392
6393 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6394 CHECK(!owner->result_ok);
6395         return APIError_clone(&*owner->contents.err);
6396 }
6397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6398         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6399         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6400         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6401         int64_t ret_ref = tag_ptr(ret_copy, true);
6402         return ret_ref;
6403 }
6404
6405 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6406 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6407 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6408 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6409 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6410 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6411 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6412 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6414         LDKPaymentSendFailure_ParameterError_class =
6415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6416         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6417         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6418         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6419         LDKPaymentSendFailure_PathParameterError_class =
6420                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6421         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6422         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6423         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6424         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6425                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6426         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6427         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6428         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6429         LDKPaymentSendFailure_PartialFailure_class =
6430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6431         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6432         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6433         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6434 }
6435 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6436         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6437         switch(obj->tag) {
6438                 case LDKPaymentSendFailure_ParameterError: {
6439                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6440                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6441                 }
6442                 case LDKPaymentSendFailure_PathParameterError: {
6443                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6444                         int64_tArray path_parameter_error_arr = NULL;
6445                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6446                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6447                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6448                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6449                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6450                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6451                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6452                         }
6453                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6454                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6455                 }
6456                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6457                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6458                         int64_tArray all_failed_retry_safe_arr = NULL;
6459                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6460                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6461                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6462                                 int64_t all_failed_retry_safe_conv_10_ref = tag_ptr(&all_failed_retry_safe_var.data[k], false);
6463                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6464                         }
6465                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6466                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6467                 }
6468                 case LDKPaymentSendFailure_PartialFailure: {
6469                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6470                         int64_tArray results_arr = NULL;
6471                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6472                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6473                         for (size_t w = 0; w < results_var.datalen; w++) {
6474                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6475                                 *results_conv_22_conv = results_var.data[w];
6476                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6477                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6478                         }
6479                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6480                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6481                         int64_t failed_paths_retry_ref = 0;
6482                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6483                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6484                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6485                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6486                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6487                 }
6488                 default: abort();
6489         }
6490 }
6491 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6492 CHECK(owner->result_ok);
6493         return ThirtyTwoBytes_clone(&*owner->contents.result);
6494 }
6495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6496         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6497         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6499         return ret_arr;
6500 }
6501
6502 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6503 CHECK(!owner->result_ok);
6504         return PaymentSendFailure_clone(&*owner->contents.err);
6505 }
6506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6507         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6508         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6509         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6510         int64_t ret_ref = tag_ptr(ret_copy, true);
6511         return ret_ref;
6512 }
6513
6514 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6515 CHECK(owner->result_ok);
6516         return *owner->contents.result;
6517 }
6518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6519         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6520         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6521 }
6522
6523 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6524 CHECK(!owner->result_ok);
6525         return PaymentSendFailure_clone(&*owner->contents.err);
6526 }
6527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6528         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6529         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6530         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6531         int64_t ret_ref = tag_ptr(ret_copy, true);
6532         return ret_ref;
6533 }
6534
6535 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6536         return ThirtyTwoBytes_clone(&owner->a);
6537 }
6538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6539         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6540         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6542         return ret_arr;
6543 }
6544
6545 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6546         return ThirtyTwoBytes_clone(&owner->b);
6547 }
6548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6549         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6550         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6552         return ret_arr;
6553 }
6554
6555 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6556 CHECK(owner->result_ok);
6557         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6558 }
6559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6560         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6561         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6562         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6563         return tag_ptr(ret_conv, true);
6564 }
6565
6566 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6567 CHECK(!owner->result_ok);
6568         return PaymentSendFailure_clone(&*owner->contents.err);
6569 }
6570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6571         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6572         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6573         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6574         int64_t ret_ref = tag_ptr(ret_copy, true);
6575         return ret_ref;
6576 }
6577
6578 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6579         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6580         for (size_t i = 0; i < ret.datalen; i++) {
6581                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6582         }
6583         return ret;
6584 }
6585 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6586         return ThirtyTwoBytes_clone(&owner->a);
6587 }
6588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6589         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6592         return ret_arr;
6593 }
6594
6595 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6596         return ThirtyTwoBytes_clone(&owner->b);
6597 }
6598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6599         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6600         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6602         return ret_arr;
6603 }
6604
6605 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6606 CHECK(owner->result_ok);
6607         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6608 }
6609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6610         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6611         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6612         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6613         return tag_ptr(ret_conv, true);
6614 }
6615
6616 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6617 CHECK(!owner->result_ok);
6618         return *owner->contents.err;
6619 }
6620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6621         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6622         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6623 }
6624
6625 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6626 CHECK(owner->result_ok);
6627         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6628 }
6629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6630         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6631         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6632         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6633         return tag_ptr(ret_conv, true);
6634 }
6635
6636 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6637 CHECK(!owner->result_ok);
6638         return APIError_clone(&*owner->contents.err);
6639 }
6640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6641         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6642         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6643         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6644         int64_t ret_ref = tag_ptr(ret_copy, true);
6645         return ret_ref;
6646 }
6647
6648 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6649 CHECK(owner->result_ok);
6650         return ThirtyTwoBytes_clone(&*owner->contents.result);
6651 }
6652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6653         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6654         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6656         return ret_arr;
6657 }
6658
6659 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6660 CHECK(!owner->result_ok);
6661         return *owner->contents.err;
6662 }
6663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6664         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6665         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6666 }
6667
6668 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6669 CHECK(owner->result_ok);
6670         return ThirtyTwoBytes_clone(&*owner->contents.result);
6671 }
6672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6673         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6676         return ret_arr;
6677 }
6678
6679 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6680 CHECK(!owner->result_ok);
6681         return APIError_clone(&*owner->contents.err);
6682 }
6683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6684         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6685         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6686         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6687         int64_t ret_ref = tag_ptr(ret_copy, true);
6688         return ret_ref;
6689 }
6690
6691 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6692 CHECK(owner->result_ok);
6693         return ThirtyTwoBytes_clone(&*owner->contents.result);
6694 }
6695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6696         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6699         return ret_arr;
6700 }
6701
6702 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6703 CHECK(!owner->result_ok);
6704         return APIError_clone(&*owner->contents.err);
6705 }
6706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6707         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6708         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6709         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6710         int64_t ret_ref = tag_ptr(ret_copy, true);
6711         return ret_ref;
6712 }
6713
6714 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6715         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
6716         ret.is_owned = false;
6717         return ret;
6718 }
6719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6720         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6721         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6722         int64_t ret_ref = 0;
6723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6725         return ret_ref;
6726 }
6727
6728 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6729 CHECK(!owner->result_ok);
6730         return DecodeError_clone(&*owner->contents.err);
6731 }
6732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6733         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6734         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6735         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6736         int64_t ret_ref = tag_ptr(ret_copy, true);
6737         return ret_ref;
6738 }
6739
6740 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6741         LDKChannelCounterparty ret = *owner->contents.result;
6742         ret.is_owned = false;
6743         return ret;
6744 }
6745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6746         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6747         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6748         int64_t ret_ref = 0;
6749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6751         return ret_ref;
6752 }
6753
6754 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6755 CHECK(!owner->result_ok);
6756         return DecodeError_clone(&*owner->contents.err);
6757 }
6758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6759         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6760         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6761         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6762         int64_t ret_ref = tag_ptr(ret_copy, true);
6763         return ret_ref;
6764 }
6765
6766 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6767         LDKChannelDetails ret = *owner->contents.result;
6768         ret.is_owned = false;
6769         return ret;
6770 }
6771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6772         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6773         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6774         int64_t ret_ref = 0;
6775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6777         return ret_ref;
6778 }
6779
6780 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6781 CHECK(!owner->result_ok);
6782         return DecodeError_clone(&*owner->contents.err);
6783 }
6784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6785         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6786         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6787         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6788         int64_t ret_ref = tag_ptr(ret_copy, true);
6789         return ret_ref;
6790 }
6791
6792 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6793         LDKPhantomRouteHints ret = *owner->contents.result;
6794         ret.is_owned = false;
6795         return ret;
6796 }
6797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6798         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6799         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6800         int64_t ret_ref = 0;
6801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6803         return ret_ref;
6804 }
6805
6806 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6807 CHECK(!owner->result_ok);
6808         return DecodeError_clone(&*owner->contents.err);
6809 }
6810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6811         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6812         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6813         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6814         int64_t ret_ref = tag_ptr(ret_copy, true);
6815         return ret_ref;
6816 }
6817
6818 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6819         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6820         for (size_t i = 0; i < ret.datalen; i++) {
6821                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6822         }
6823         return ret;
6824 }
6825 typedef struct LDKWatch_JCalls {
6826         atomic_size_t refcnt;
6827         JavaVM *vm;
6828         jweak o;
6829         jmethodID watch_channel_meth;
6830         jmethodID update_channel_meth;
6831         jmethodID release_pending_monitor_events_meth;
6832 } LDKWatch_JCalls;
6833 static void LDKWatch_JCalls_free(void* this_arg) {
6834         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6835         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6836                 JNIEnv *env;
6837                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6838                 if (get_jenv_res == JNI_EDETACHED) {
6839                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6840                 } else {
6841                         DO_ASSERT(get_jenv_res == JNI_OK);
6842                 }
6843                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6844                 if (get_jenv_res == JNI_EDETACHED) {
6845                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6846                 }
6847                 FREE(j_calls);
6848         }
6849 }
6850 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6851         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6852         JNIEnv *env;
6853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6854         if (get_jenv_res == JNI_EDETACHED) {
6855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6856         } else {
6857                 DO_ASSERT(get_jenv_res == JNI_OK);
6858         }
6859         LDKOutPoint funding_txo_var = funding_txo;
6860         int64_t funding_txo_ref = 0;
6861         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6862         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6863         LDKChannelMonitor monitor_var = monitor;
6864         int64_t monitor_ref = 0;
6865         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6866         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
6867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6868         CHECK(obj != NULL);
6869         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6870         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6871                 (*env)->ExceptionDescribe(env);
6872                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6873         }
6874         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
6875         if (get_jenv_res == JNI_EDETACHED) {
6876                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6877         }
6878         return ret_conv;
6879 }
6880 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6881         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6882         JNIEnv *env;
6883         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6884         if (get_jenv_res == JNI_EDETACHED) {
6885                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6886         } else {
6887                 DO_ASSERT(get_jenv_res == JNI_OK);
6888         }
6889         LDKOutPoint funding_txo_var = funding_txo;
6890         int64_t funding_txo_ref = 0;
6891         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6892         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6893         LDKChannelMonitorUpdate update_var = update;
6894         int64_t update_ref = 0;
6895         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6896         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
6897         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6898         CHECK(obj != NULL);
6899         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6900         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6901                 (*env)->ExceptionDescribe(env);
6902                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6903         }
6904         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
6905         if (get_jenv_res == JNI_EDETACHED) {
6906                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6907         }
6908         return ret_conv;
6909 }
6910 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6911         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6912         JNIEnv *env;
6913         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6914         if (get_jenv_res == JNI_EDETACHED) {
6915                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6916         } else {
6917                 DO_ASSERT(get_jenv_res == JNI_OK);
6918         }
6919         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6920         CHECK(obj != NULL);
6921         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6922         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6923                 (*env)->ExceptionDescribe(env);
6924                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6925         }
6926         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6927         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6928         if (ret_constr.datalen > 0)
6929                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6930         else
6931                 ret_constr.data = NULL;
6932         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6933         for (size_t x = 0; x < ret_constr.datalen; x++) {
6934                 int64_t ret_conv_49 = ret_vals[x];
6935                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
6936                 CHECK_ACCESS(ret_conv_49_ptr);
6937                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6938                 FREE(untag_ptr(ret_conv_49));
6939                 ret_constr.data[x] = ret_conv_49_conv;
6940         }
6941         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6942         if (get_jenv_res == JNI_EDETACHED) {
6943                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6944         }
6945         return ret_constr;
6946 }
6947 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6948         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6949         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6950 }
6951 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6952         jclass c = (*env)->GetObjectClass(env, o);
6953         CHECK(c != NULL);
6954         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6955         atomic_init(&calls->refcnt, 1);
6956         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6957         calls->o = (*env)->NewWeakGlobalRef(env, o);
6958         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
6959         CHECK(calls->watch_channel_meth != NULL);
6960         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
6961         CHECK(calls->update_channel_meth != NULL);
6962         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6963         CHECK(calls->release_pending_monitor_events_meth != NULL);
6964
6965         LDKWatch ret = {
6966                 .this_arg = (void*) calls,
6967                 .watch_channel = watch_channel_LDKWatch_jcall,
6968                 .update_channel = update_channel_LDKWatch_jcall,
6969                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6970                 .free = LDKWatch_JCalls_free,
6971         };
6972         return ret;
6973 }
6974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6975         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6976         *res_ptr = LDKWatch_init(env, clz, o);
6977         return tag_ptr(res_ptr, true);
6978 }
6979 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
6980         void* this_arg_ptr = untag_ptr(this_arg);
6981         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6982         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6983         LDKOutPoint funding_txo_conv;
6984         funding_txo_conv.inner = untag_ptr(funding_txo);
6985         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6986         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6987         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6988         LDKChannelMonitor monitor_conv;
6989         monitor_conv.inner = untag_ptr(monitor);
6990         monitor_conv.is_owned = ptr_is_owned(monitor);
6991         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6992         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6993         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
6994         return ret_conv;
6995 }
6996
6997 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
6998         void* this_arg_ptr = untag_ptr(this_arg);
6999         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7000         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7001         LDKOutPoint funding_txo_conv;
7002         funding_txo_conv.inner = untag_ptr(funding_txo);
7003         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7004         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7005         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7006         LDKChannelMonitorUpdate update_conv;
7007         update_conv.inner = untag_ptr(update);
7008         update_conv.is_owned = ptr_is_owned(update);
7009         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7010         update_conv = ChannelMonitorUpdate_clone(&update_conv);
7011         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv));
7012         return ret_conv;
7013 }
7014
7015 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7016         void* this_arg_ptr = untag_ptr(this_arg);
7017         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7018         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7019         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7020         int64_tArray ret_arr = NULL;
7021         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7022         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7023         for (size_t x = 0; x < ret_var.datalen; x++) {
7024                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7025                 *ret_conv_49_conv = ret_var.data[x];
7026                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7027         }
7028         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7029         FREE(ret_var.data);
7030         return ret_arr;
7031 }
7032
7033 typedef struct LDKBroadcasterInterface_JCalls {
7034         atomic_size_t refcnt;
7035         JavaVM *vm;
7036         jweak o;
7037         jmethodID broadcast_transaction_meth;
7038 } LDKBroadcasterInterface_JCalls;
7039 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7040         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7041         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7042                 JNIEnv *env;
7043                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7044                 if (get_jenv_res == JNI_EDETACHED) {
7045                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7046                 } else {
7047                         DO_ASSERT(get_jenv_res == JNI_OK);
7048                 }
7049                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7050                 if (get_jenv_res == JNI_EDETACHED) {
7051                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7052                 }
7053                 FREE(j_calls);
7054         }
7055 }
7056 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7057         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7058         JNIEnv *env;
7059         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7060         if (get_jenv_res == JNI_EDETACHED) {
7061                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7062         } else {
7063                 DO_ASSERT(get_jenv_res == JNI_OK);
7064         }
7065         LDKTransaction tx_var = tx;
7066         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7067         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7068         Transaction_free(tx_var);
7069         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7070         CHECK(obj != NULL);
7071         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7072         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7073                 (*env)->ExceptionDescribe(env);
7074                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7075         }
7076         if (get_jenv_res == JNI_EDETACHED) {
7077                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7078         }
7079 }
7080 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7081         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7082         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7083 }
7084 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7085         jclass c = (*env)->GetObjectClass(env, o);
7086         CHECK(c != NULL);
7087         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7088         atomic_init(&calls->refcnt, 1);
7089         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7090         calls->o = (*env)->NewWeakGlobalRef(env, o);
7091         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7092         CHECK(calls->broadcast_transaction_meth != NULL);
7093
7094         LDKBroadcasterInterface ret = {
7095                 .this_arg = (void*) calls,
7096                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7097                 .free = LDKBroadcasterInterface_JCalls_free,
7098         };
7099         return ret;
7100 }
7101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7102         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7103         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7104         return tag_ptr(res_ptr, true);
7105 }
7106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7107         void* this_arg_ptr = untag_ptr(this_arg);
7108         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7109         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7110         LDKTransaction tx_ref;
7111         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7112         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7113         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7114         tx_ref.data_is_owned = true;
7115         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7116 }
7117
7118 typedef struct LDKKeysInterface_JCalls {
7119         atomic_size_t refcnt;
7120         JavaVM *vm;
7121         jweak o;
7122         jmethodID get_node_secret_meth;
7123         jmethodID get_node_id_meth;
7124         jmethodID ecdh_meth;
7125         jmethodID get_destination_script_meth;
7126         jmethodID get_shutdown_scriptpubkey_meth;
7127         jmethodID get_channel_signer_meth;
7128         jmethodID get_secure_random_bytes_meth;
7129         jmethodID read_chan_signer_meth;
7130         jmethodID sign_invoice_meth;
7131         jmethodID get_inbound_payment_key_material_meth;
7132 } LDKKeysInterface_JCalls;
7133 static void LDKKeysInterface_JCalls_free(void* this_arg) {
7134         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7135         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7136                 JNIEnv *env;
7137                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7138                 if (get_jenv_res == JNI_EDETACHED) {
7139                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7140                 } else {
7141                         DO_ASSERT(get_jenv_res == JNI_OK);
7142                 }
7143                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7144                 if (get_jenv_res == JNI_EDETACHED) {
7145                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7146                 }
7147                 FREE(j_calls);
7148         }
7149 }
7150 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7151         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7152         JNIEnv *env;
7153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7154         if (get_jenv_res == JNI_EDETACHED) {
7155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7156         } else {
7157                 DO_ASSERT(get_jenv_res == JNI_OK);
7158         }
7159         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7161         CHECK(obj != NULL);
7162         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
7163         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7164                 (*env)->ExceptionDescribe(env);
7165                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
7166         }
7167         void* ret_ptr = untag_ptr(ret);
7168         CHECK_ACCESS(ret_ptr);
7169         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
7170         FREE(untag_ptr(ret));
7171         if (get_jenv_res == JNI_EDETACHED) {
7172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7173         }
7174         return ret_conv;
7175 }
7176 LDKCResult_PublicKeyNoneZ get_node_id_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7177         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7178         JNIEnv *env;
7179         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7180         if (get_jenv_res == JNI_EDETACHED) {
7181                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7182         } else {
7183                 DO_ASSERT(get_jenv_res == JNI_OK);
7184         }
7185         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7187         CHECK(obj != NULL);
7188         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7189         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7190                 (*env)->ExceptionDescribe(env);
7191                 (*env)->FatalError(env, "A call to get_node_id in LDKKeysInterface from rust threw an exception.");
7192         }
7193         void* ret_ptr = untag_ptr(ret);
7194         CHECK_ACCESS(ret_ptr);
7195         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7196         FREE(untag_ptr(ret));
7197         if (get_jenv_res == JNI_EDETACHED) {
7198                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7199         }
7200         return ret_conv;
7201 }
7202 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7203         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7204         JNIEnv *env;
7205         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7206         if (get_jenv_res == JNI_EDETACHED) {
7207                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7208         } else {
7209                 DO_ASSERT(get_jenv_res == JNI_OK);
7210         }
7211         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7212         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7213         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7214         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7215         *tweak_copy = tweak;
7216         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7217         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7218         CHECK(obj != NULL);
7219         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7220         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7221                 (*env)->ExceptionDescribe(env);
7222                 (*env)->FatalError(env, "A call to ecdh in LDKKeysInterface from rust threw an exception.");
7223         }
7224         void* ret_ptr = untag_ptr(ret);
7225         CHECK_ACCESS(ret_ptr);
7226         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7227         FREE(untag_ptr(ret));
7228         if (get_jenv_res == JNI_EDETACHED) {
7229                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7230         }
7231         return ret_conv;
7232 }
7233 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
7234         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7235         JNIEnv *env;
7236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7237         if (get_jenv_res == JNI_EDETACHED) {
7238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7239         } else {
7240                 DO_ASSERT(get_jenv_res == JNI_OK);
7241         }
7242         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7243         CHECK(obj != NULL);
7244         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
7245         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7246                 (*env)->ExceptionDescribe(env);
7247                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
7248         }
7249         LDKCVec_u8Z ret_ref;
7250         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7251         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7252         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7253         if (get_jenv_res == JNI_EDETACHED) {
7254                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7255         }
7256         return ret_ref;
7257 }
7258 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
7259         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7260         JNIEnv *env;
7261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7262         if (get_jenv_res == JNI_EDETACHED) {
7263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7264         } else {
7265                 DO_ASSERT(get_jenv_res == JNI_OK);
7266         }
7267         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7268         CHECK(obj != NULL);
7269         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
7270         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7271                 (*env)->ExceptionDescribe(env);
7272                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
7273         }
7274         LDKShutdownScript ret_conv;
7275         ret_conv.inner = untag_ptr(ret);
7276         ret_conv.is_owned = ptr_is_owned(ret);
7277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7278         if (get_jenv_res == JNI_EDETACHED) {
7279                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7280         }
7281         return ret_conv;
7282 }
7283 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
7284         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7285         JNIEnv *env;
7286         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7287         if (get_jenv_res == JNI_EDETACHED) {
7288                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7289         } else {
7290                 DO_ASSERT(get_jenv_res == JNI_OK);
7291         }
7292         jboolean inbound_conv = inbound;
7293         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7295         CHECK(obj != NULL);
7296         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
7297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7298                 (*env)->ExceptionDescribe(env);
7299                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
7300         }
7301         void* ret_ptr = untag_ptr(ret);
7302         CHECK_ACCESS(ret_ptr);
7303         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
7304         FREE(untag_ptr(ret));
7305         if (get_jenv_res == JNI_EDETACHED) {
7306                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7307         }
7308         return ret_conv;
7309 }
7310 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
7311         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7312         JNIEnv *env;
7313         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7314         if (get_jenv_res == JNI_EDETACHED) {
7315                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7316         } else {
7317                 DO_ASSERT(get_jenv_res == JNI_OK);
7318         }
7319         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7320         CHECK(obj != NULL);
7321         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7322         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7323                 (*env)->ExceptionDescribe(env);
7324                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
7325         }
7326         LDKThirtyTwoBytes ret_ref;
7327         CHECK((*env)->GetArrayLength(env, ret) == 32);
7328         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7329         if (get_jenv_res == JNI_EDETACHED) {
7330                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7331         }
7332         return ret_ref;
7333 }
7334 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
7335         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7336         JNIEnv *env;
7337         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7338         if (get_jenv_res == JNI_EDETACHED) {
7339                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7340         } else {
7341                 DO_ASSERT(get_jenv_res == JNI_OK);
7342         }
7343         LDKu8slice reader_var = reader;
7344         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
7345         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
7346         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7347         CHECK(obj != NULL);
7348         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
7349         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7350                 (*env)->ExceptionDescribe(env);
7351                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
7352         }
7353         void* ret_ptr = untag_ptr(ret);
7354         CHECK_ACCESS(ret_ptr);
7355         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
7356         FREE(untag_ptr(ret));
7357         if (get_jenv_res == JNI_EDETACHED) {
7358                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7359         }
7360         return ret_conv;
7361 }
7362 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
7363         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7364         JNIEnv *env;
7365         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7366         if (get_jenv_res == JNI_EDETACHED) {
7367                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7368         } else {
7369                 DO_ASSERT(get_jenv_res == JNI_OK);
7370         }
7371         LDKu8slice hrp_bytes_var = hrp_bytes;
7372         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7373         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7374         LDKCVec_u5Z invoice_data_var = invoice_data;
7375         jobjectArray invoice_data_arr = NULL;
7376         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7377         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7378         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7379                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7380                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7381         }
7382         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7383         FREE(invoice_data_var.data);
7384         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7385         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7386         CHECK(obj != NULL);
7387         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7388         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7389                 (*env)->ExceptionDescribe(env);
7390                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7391         }
7392         void* ret_ptr = untag_ptr(ret);
7393         CHECK_ACCESS(ret_ptr);
7394         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7395         FREE(untag_ptr(ret));
7396         if (get_jenv_res == JNI_EDETACHED) {
7397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7398         }
7399         return ret_conv;
7400 }
7401 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7402         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7403         JNIEnv *env;
7404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7405         if (get_jenv_res == JNI_EDETACHED) {
7406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7407         } else {
7408                 DO_ASSERT(get_jenv_res == JNI_OK);
7409         }
7410         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7411         CHECK(obj != NULL);
7412         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7413         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7414                 (*env)->ExceptionDescribe(env);
7415                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7416         }
7417         LDKThirtyTwoBytes ret_ref;
7418         CHECK((*env)->GetArrayLength(env, ret) == 32);
7419         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7420         if (get_jenv_res == JNI_EDETACHED) {
7421                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7422         }
7423         return ret_ref;
7424 }
7425 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7426         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7427         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7428 }
7429 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7430         jclass c = (*env)->GetObjectClass(env, o);
7431         CHECK(c != NULL);
7432         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7433         atomic_init(&calls->refcnt, 1);
7434         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7435         calls->o = (*env)->NewWeakGlobalRef(env, o);
7436         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7437         CHECK(calls->get_node_secret_meth != NULL);
7438         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
7439         CHECK(calls->get_node_id_meth != NULL);
7440         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7441         CHECK(calls->ecdh_meth != NULL);
7442         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7443         CHECK(calls->get_destination_script_meth != NULL);
7444         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7445         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7446         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7447         CHECK(calls->get_channel_signer_meth != NULL);
7448         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7449         CHECK(calls->get_secure_random_bytes_meth != NULL);
7450         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7451         CHECK(calls->read_chan_signer_meth != NULL);
7452         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7453         CHECK(calls->sign_invoice_meth != NULL);
7454         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7455         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7456
7457         LDKKeysInterface ret = {
7458                 .this_arg = (void*) calls,
7459                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7460                 .get_node_id = get_node_id_LDKKeysInterface_jcall,
7461                 .ecdh = ecdh_LDKKeysInterface_jcall,
7462                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7463                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7464                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7465                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7466                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7467                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7468                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7469                 .free = LDKKeysInterface_JCalls_free,
7470         };
7471         return ret;
7472 }
7473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7474         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7475         *res_ptr = LDKKeysInterface_init(env, clz, o);
7476         return tag_ptr(res_ptr, true);
7477 }
7478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7479         void* this_arg_ptr = untag_ptr(this_arg);
7480         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7481         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7482         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7483         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7484         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7485         return tag_ptr(ret_conv, true);
7486 }
7487
7488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7489         void* this_arg_ptr = untag_ptr(this_arg);
7490         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7491         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7492         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7493         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
7494         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
7495         return tag_ptr(ret_conv, true);
7496 }
7497
7498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1ecdh(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient, int8_tArray other_key, int64_t tweak) {
7499         void* this_arg_ptr = untag_ptr(this_arg);
7500         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7501         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7502         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7503         LDKPublicKey other_key_ref;
7504         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7505         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7506         void* tweak_ptr = untag_ptr(tweak);
7507         CHECK_ACCESS(tweak_ptr);
7508         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7509         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7510         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7511         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7512         return tag_ptr(ret_conv, true);
7513 }
7514
7515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7516         void* this_arg_ptr = untag_ptr(this_arg);
7517         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7518         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7519         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7520         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7521         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7522         CVec_u8Z_free(ret_var);
7523         return ret_arr;
7524 }
7525
7526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7527         void* this_arg_ptr = untag_ptr(this_arg);
7528         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7529         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7530         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7531         int64_t ret_ref = 0;
7532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7534         return ret_ref;
7535 }
7536
7537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
7538         void* this_arg_ptr = untag_ptr(this_arg);
7539         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7540         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7541         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7542         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7543         return tag_ptr(ret_ret, true);
7544 }
7545
7546 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7547         void* this_arg_ptr = untag_ptr(this_arg);
7548         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7549         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7550         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7552         return ret_arr;
7553 }
7554
7555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7556         void* this_arg_ptr = untag_ptr(this_arg);
7557         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7558         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7559         LDKu8slice reader_ref;
7560         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7561         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7562         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7563         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7564         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7565         return tag_ptr(ret_conv, true);
7566 }
7567
7568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray hrp_bytes, jobjectArray invoice_data, jclass receipient) {
7569         void* this_arg_ptr = untag_ptr(this_arg);
7570         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7571         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7572         LDKu8slice hrp_bytes_ref;
7573         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7574         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7575         LDKCVec_u5Z invoice_data_constr;
7576         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7577         if (invoice_data_constr.datalen > 0)
7578                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7579         else
7580                 invoice_data_constr.data = NULL;
7581         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7582         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7583                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7584                 
7585                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7586         }
7587         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7588         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7589         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7590         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7591         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7592         return tag_ptr(ret_conv, true);
7593 }
7594
7595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7596         void* this_arg_ptr = untag_ptr(this_arg);
7597         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7598         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7599         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7600         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7601         return ret_arr;
7602 }
7603
7604 typedef struct LDKFeeEstimator_JCalls {
7605         atomic_size_t refcnt;
7606         JavaVM *vm;
7607         jweak o;
7608         jmethodID get_est_sat_per_1000_weight_meth;
7609 } LDKFeeEstimator_JCalls;
7610 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7611         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7612         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7613                 JNIEnv *env;
7614                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7615                 if (get_jenv_res == JNI_EDETACHED) {
7616                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7617                 } else {
7618                         DO_ASSERT(get_jenv_res == JNI_OK);
7619                 }
7620                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7621                 if (get_jenv_res == JNI_EDETACHED) {
7622                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7623                 }
7624                 FREE(j_calls);
7625         }
7626 }
7627 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7628         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7629         JNIEnv *env;
7630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7631         if (get_jenv_res == JNI_EDETACHED) {
7632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7633         } else {
7634                 DO_ASSERT(get_jenv_res == JNI_OK);
7635         }
7636         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7637         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7638         CHECK(obj != NULL);
7639         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7641                 (*env)->ExceptionDescribe(env);
7642                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7643         }
7644         if (get_jenv_res == JNI_EDETACHED) {
7645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7646         }
7647         return ret;
7648 }
7649 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7650         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7651         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7652 }
7653 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7654         jclass c = (*env)->GetObjectClass(env, o);
7655         CHECK(c != NULL);
7656         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7657         atomic_init(&calls->refcnt, 1);
7658         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7659         calls->o = (*env)->NewWeakGlobalRef(env, o);
7660         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7661         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7662
7663         LDKFeeEstimator ret = {
7664                 .this_arg = (void*) calls,
7665                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7666                 .free = LDKFeeEstimator_JCalls_free,
7667         };
7668         return ret;
7669 }
7670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7671         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7672         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7673         return tag_ptr(res_ptr, true);
7674 }
7675 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_arg, jclass confirmation_target) {
7676         void* this_arg_ptr = untag_ptr(this_arg);
7677         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7678         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7679         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7680         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7681         return ret_conv;
7682 }
7683
7684 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7685         return ThirtyTwoBytes_clone(&owner->a);
7686 }
7687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7688         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7689         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7691         return ret_arr;
7692 }
7693
7694 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7695         LDKChannelManager ret = owner->b;
7696         ret.is_owned = false;
7697         return ret;
7698 }
7699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7700         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7701         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7702         int64_t ret_ref = 0;
7703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7705         return ret_ref;
7706 }
7707
7708 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7709 CHECK(owner->result_ok);
7710         return &*owner->contents.result;
7711 }
7712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7713         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7714         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
7715         return ret_ret;
7716 }
7717
7718 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7719 CHECK(!owner->result_ok);
7720         return DecodeError_clone(&*owner->contents.err);
7721 }
7722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7723         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7724         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7725         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7726         int64_t ret_ref = tag_ptr(ret_copy, true);
7727         return ret_ref;
7728 }
7729
7730 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7731         LDKChannelConfig ret = *owner->contents.result;
7732         ret.is_owned = false;
7733         return ret;
7734 }
7735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7736         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7737         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7738         int64_t ret_ref = 0;
7739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7740         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7741         return ret_ref;
7742 }
7743
7744 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7745 CHECK(!owner->result_ok);
7746         return DecodeError_clone(&*owner->contents.err);
7747 }
7748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7749         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7750         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7751         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7752         int64_t ret_ref = tag_ptr(ret_copy, true);
7753         return ret_ref;
7754 }
7755
7756 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7757         LDKOutPoint ret = *owner->contents.result;
7758         ret.is_owned = false;
7759         return ret;
7760 }
7761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7762         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7763         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7764         int64_t ret_ref = 0;
7765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7767         return ret_ref;
7768 }
7769
7770 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7771 CHECK(!owner->result_ok);
7772         return DecodeError_clone(&*owner->contents.err);
7773 }
7774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7775         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7776         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7777         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7778         int64_t ret_ref = tag_ptr(ret_copy, true);
7779         return ret_ref;
7780 }
7781
7782 typedef struct LDKType_JCalls {
7783         atomic_size_t refcnt;
7784         JavaVM *vm;
7785         jweak o;
7786         jmethodID type_id_meth;
7787         jmethodID debug_str_meth;
7788         jmethodID write_meth;
7789 } LDKType_JCalls;
7790 static void LDKType_JCalls_free(void* this_arg) {
7791         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7792         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7793                 JNIEnv *env;
7794                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7795                 if (get_jenv_res == JNI_EDETACHED) {
7796                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7797                 } else {
7798                         DO_ASSERT(get_jenv_res == JNI_OK);
7799                 }
7800                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7801                 if (get_jenv_res == JNI_EDETACHED) {
7802                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7803                 }
7804                 FREE(j_calls);
7805         }
7806 }
7807 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7808         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7809         JNIEnv *env;
7810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7811         if (get_jenv_res == JNI_EDETACHED) {
7812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7813         } else {
7814                 DO_ASSERT(get_jenv_res == JNI_OK);
7815         }
7816         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7817         CHECK(obj != NULL);
7818         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7819         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7820                 (*env)->ExceptionDescribe(env);
7821                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7822         }
7823         if (get_jenv_res == JNI_EDETACHED) {
7824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7825         }
7826         return ret;
7827 }
7828 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7829         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7830         JNIEnv *env;
7831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7832         if (get_jenv_res == JNI_EDETACHED) {
7833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7834         } else {
7835                 DO_ASSERT(get_jenv_res == JNI_OK);
7836         }
7837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7838         CHECK(obj != NULL);
7839         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7841                 (*env)->ExceptionDescribe(env);
7842                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7843         }
7844         LDKStr ret_conv = java_to_owned_str(env, ret);
7845         if (get_jenv_res == JNI_EDETACHED) {
7846                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7847         }
7848         return ret_conv;
7849 }
7850 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7851         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7852         JNIEnv *env;
7853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7854         if (get_jenv_res == JNI_EDETACHED) {
7855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7856         } else {
7857                 DO_ASSERT(get_jenv_res == JNI_OK);
7858         }
7859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7860         CHECK(obj != NULL);
7861         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7863                 (*env)->ExceptionDescribe(env);
7864                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7865         }
7866         LDKCVec_u8Z ret_ref;
7867         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7868         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7869         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7870         if (get_jenv_res == JNI_EDETACHED) {
7871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7872         }
7873         return ret_ref;
7874 }
7875 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7876         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7877         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7878 }
7879 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7880         jclass c = (*env)->GetObjectClass(env, o);
7881         CHECK(c != NULL);
7882         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7883         atomic_init(&calls->refcnt, 1);
7884         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7885         calls->o = (*env)->NewWeakGlobalRef(env, o);
7886         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7887         CHECK(calls->type_id_meth != NULL);
7888         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7889         CHECK(calls->debug_str_meth != NULL);
7890         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7891         CHECK(calls->write_meth != NULL);
7892
7893         LDKType ret = {
7894                 .this_arg = (void*) calls,
7895                 .type_id = type_id_LDKType_jcall,
7896                 .debug_str = debug_str_LDKType_jcall,
7897                 .write = write_LDKType_jcall,
7898                 .cloned = LDKType_JCalls_cloned,
7899                 .free = LDKType_JCalls_free,
7900         };
7901         return ret;
7902 }
7903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7904         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7905         *res_ptr = LDKType_init(env, clz, o);
7906         return tag_ptr(res_ptr, true);
7907 }
7908 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7909         void* this_arg_ptr = untag_ptr(this_arg);
7910         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7911         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7912         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7913         return ret_conv;
7914 }
7915
7916 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7917         void* this_arg_ptr = untag_ptr(this_arg);
7918         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7919         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7920         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7921         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7922         Str_free(ret_str);
7923         return ret_conv;
7924 }
7925
7926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7927         void* this_arg_ptr = untag_ptr(this_arg);
7928         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7929         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7930         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7933         CVec_u8Z_free(ret_var);
7934         return ret_arr;
7935 }
7936
7937 static jclass LDKCOption_TypeZ_Some_class = NULL;
7938 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7939 static jclass LDKCOption_TypeZ_None_class = NULL;
7940 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7942         LDKCOption_TypeZ_Some_class =
7943                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7944         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7945         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7946         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7947         LDKCOption_TypeZ_None_class =
7948                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7949         CHECK(LDKCOption_TypeZ_None_class != NULL);
7950         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7951         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7952 }
7953 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7954         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7955         switch(obj->tag) {
7956                 case LDKCOption_TypeZ_Some: {
7957                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7958                         *some_ret = Type_clone(&obj->some);
7959                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
7960                 }
7961                 case LDKCOption_TypeZ_None: {
7962                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7963                 }
7964                 default: abort();
7965         }
7966 }
7967 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7968 CHECK(owner->result_ok);
7969         return COption_TypeZ_clone(&*owner->contents.result);
7970 }
7971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7972         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7973         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7974         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7975         int64_t ret_ref = tag_ptr(ret_copy, true);
7976         return ret_ref;
7977 }
7978
7979 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7980 CHECK(!owner->result_ok);
7981         return DecodeError_clone(&*owner->contents.err);
7982 }
7983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7984         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7985         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7986         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7987         int64_t ret_ref = tag_ptr(ret_copy, true);
7988         return ret_ref;
7989 }
7990
7991 static jclass LDKPaymentError_Invoice_class = NULL;
7992 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7993 static jclass LDKPaymentError_Routing_class = NULL;
7994 static jmethodID LDKPaymentError_Routing_meth = NULL;
7995 static jclass LDKPaymentError_Sending_class = NULL;
7996 static jmethodID LDKPaymentError_Sending_meth = NULL;
7997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7998         LDKPaymentError_Invoice_class =
7999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
8000         CHECK(LDKPaymentError_Invoice_class != NULL);
8001         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
8002         CHECK(LDKPaymentError_Invoice_meth != NULL);
8003         LDKPaymentError_Routing_class =
8004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
8005         CHECK(LDKPaymentError_Routing_class != NULL);
8006         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
8007         CHECK(LDKPaymentError_Routing_meth != NULL);
8008         LDKPaymentError_Sending_class =
8009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
8010         CHECK(LDKPaymentError_Sending_class != NULL);
8011         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
8012         CHECK(LDKPaymentError_Sending_meth != NULL);
8013 }
8014 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8015         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
8016         switch(obj->tag) {
8017                 case LDKPaymentError_Invoice: {
8018                         LDKStr invoice_str = obj->invoice;
8019                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
8020                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
8021                 }
8022                 case LDKPaymentError_Routing: {
8023                         LDKLightningError routing_var = obj->routing;
8024                         int64_t routing_ref = 0;
8025                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
8026                         routing_ref = tag_ptr(routing_var.inner, false);
8027                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
8028                 }
8029                 case LDKPaymentError_Sending: {
8030                         int64_t sending_ref = tag_ptr(&obj->sending, false);
8031                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
8032                 }
8033                 default: abort();
8034         }
8035 }
8036 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8037 CHECK(owner->result_ok);
8038         return ThirtyTwoBytes_clone(&*owner->contents.result);
8039 }
8040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8041         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8042         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
8044         return ret_arr;
8045 }
8046
8047 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8048 CHECK(!owner->result_ok);
8049         return PaymentError_clone(&*owner->contents.err);
8050 }
8051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8052         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8053         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8054         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
8055         int64_t ret_ref = tag_ptr(ret_copy, true);
8056         return ret_ref;
8057 }
8058
8059 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
8060         LDKInFlightHtlcs ret = *owner->contents.result;
8061         ret.is_owned = false;
8062         return ret;
8063 }
8064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8065         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8066         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
8067         int64_t ret_ref = 0;
8068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8070         return ret_ref;
8071 }
8072
8073 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
8074 CHECK(!owner->result_ok);
8075         return DecodeError_clone(&*owner->contents.err);
8076 }
8077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8078         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8079         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8080         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
8081         int64_t ret_ref = tag_ptr(ret_copy, true);
8082         return ret_ref;
8083 }
8084
8085 static jclass LDKParseError_Bech32Error_class = NULL;
8086 static jmethodID LDKParseError_Bech32Error_meth = NULL;
8087 static jclass LDKParseError_ParseAmountError_class = NULL;
8088 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
8089 static jclass LDKParseError_MalformedSignature_class = NULL;
8090 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
8091 static jclass LDKParseError_BadPrefix_class = NULL;
8092 static jmethodID LDKParseError_BadPrefix_meth = NULL;
8093 static jclass LDKParseError_UnknownCurrency_class = NULL;
8094 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
8095 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
8096 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
8097 static jclass LDKParseError_MalformedHRP_class = NULL;
8098 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
8099 static jclass LDKParseError_TooShortDataPart_class = NULL;
8100 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
8101 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
8102 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
8103 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
8104 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
8105 static jclass LDKParseError_PaddingError_class = NULL;
8106 static jmethodID LDKParseError_PaddingError_meth = NULL;
8107 static jclass LDKParseError_IntegerOverflowError_class = NULL;
8108 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
8109 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
8110 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
8111 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
8112 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
8113 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
8114 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
8115 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
8116 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
8117 static jclass LDKParseError_InvalidSliceLength_class = NULL;
8118 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
8119 static jclass LDKParseError_Skip_class = NULL;
8120 static jmethodID LDKParseError_Skip_meth = NULL;
8121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
8122         LDKParseError_Bech32Error_class =
8123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
8124         CHECK(LDKParseError_Bech32Error_class != NULL);
8125         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
8126         CHECK(LDKParseError_Bech32Error_meth != NULL);
8127         LDKParseError_ParseAmountError_class =
8128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
8129         CHECK(LDKParseError_ParseAmountError_class != NULL);
8130         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
8131         CHECK(LDKParseError_ParseAmountError_meth != NULL);
8132         LDKParseError_MalformedSignature_class =
8133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
8134         CHECK(LDKParseError_MalformedSignature_class != NULL);
8135         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
8136         CHECK(LDKParseError_MalformedSignature_meth != NULL);
8137         LDKParseError_BadPrefix_class =
8138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
8139         CHECK(LDKParseError_BadPrefix_class != NULL);
8140         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
8141         CHECK(LDKParseError_BadPrefix_meth != NULL);
8142         LDKParseError_UnknownCurrency_class =
8143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
8144         CHECK(LDKParseError_UnknownCurrency_class != NULL);
8145         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
8146         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
8147         LDKParseError_UnknownSiPrefix_class =
8148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
8149         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
8150         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
8151         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
8152         LDKParseError_MalformedHRP_class =
8153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
8154         CHECK(LDKParseError_MalformedHRP_class != NULL);
8155         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
8156         CHECK(LDKParseError_MalformedHRP_meth != NULL);
8157         LDKParseError_TooShortDataPart_class =
8158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
8159         CHECK(LDKParseError_TooShortDataPart_class != NULL);
8160         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
8161         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
8162         LDKParseError_UnexpectedEndOfTaggedFields_class =
8163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
8164         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
8165         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
8166         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
8167         LDKParseError_DescriptionDecodeError_class =
8168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
8169         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
8170         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
8171         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
8172         LDKParseError_PaddingError_class =
8173                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
8174         CHECK(LDKParseError_PaddingError_class != NULL);
8175         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
8176         CHECK(LDKParseError_PaddingError_meth != NULL);
8177         LDKParseError_IntegerOverflowError_class =
8178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
8179         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
8180         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
8181         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
8182         LDKParseError_InvalidSegWitProgramLength_class =
8183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
8184         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
8185         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
8186         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
8187         LDKParseError_InvalidPubKeyHashLength_class =
8188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
8189         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
8190         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
8191         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
8192         LDKParseError_InvalidScriptHashLength_class =
8193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
8194         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
8195         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
8196         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
8197         LDKParseError_InvalidRecoveryId_class =
8198                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
8199         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
8200         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
8201         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
8202         LDKParseError_InvalidSliceLength_class =
8203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
8204         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
8205         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
8206         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
8207         LDKParseError_Skip_class =
8208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
8209         CHECK(LDKParseError_Skip_class != NULL);
8210         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
8211         CHECK(LDKParseError_Skip_meth != NULL);
8212 }
8213 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8214         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
8215         switch(obj->tag) {
8216                 case LDKParseError_Bech32Error: {
8217                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
8218                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
8219                 }
8220                 case LDKParseError_ParseAmountError: {
8221                         /*obj->parse_amount_error*/
8222                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
8223                 }
8224                 case LDKParseError_MalformedSignature: {
8225                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
8226                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
8227                 }
8228                 case LDKParseError_BadPrefix: {
8229                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
8230                 }
8231                 case LDKParseError_UnknownCurrency: {
8232                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
8233                 }
8234                 case LDKParseError_UnknownSiPrefix: {
8235                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
8236                 }
8237                 case LDKParseError_MalformedHRP: {
8238                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
8239                 }
8240                 case LDKParseError_TooShortDataPart: {
8241                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
8242                 }
8243                 case LDKParseError_UnexpectedEndOfTaggedFields: {
8244                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
8245                 }
8246                 case LDKParseError_DescriptionDecodeError: {
8247                         /*obj->description_decode_error*/
8248                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
8249                 }
8250                 case LDKParseError_PaddingError: {
8251                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
8252                 }
8253                 case LDKParseError_IntegerOverflowError: {
8254                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
8255                 }
8256                 case LDKParseError_InvalidSegWitProgramLength: {
8257                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
8258                 }
8259                 case LDKParseError_InvalidPubKeyHashLength: {
8260                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
8261                 }
8262                 case LDKParseError_InvalidScriptHashLength: {
8263                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
8264                 }
8265                 case LDKParseError_InvalidRecoveryId: {
8266                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
8267                 }
8268                 case LDKParseError_InvalidSliceLength: {
8269                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
8270                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
8271                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
8272                 }
8273                 case LDKParseError_Skip: {
8274                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
8275                 }
8276                 default: abort();
8277         }
8278 }
8279 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8280 CHECK(owner->result_ok);
8281         return SiPrefix_clone(&*owner->contents.result);
8282 }
8283 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8284         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8285         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
8286         return ret_conv;
8287 }
8288
8289 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8290 CHECK(!owner->result_ok);
8291         return ParseError_clone(&*owner->contents.err);
8292 }
8293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8294         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8295         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8296         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
8297         int64_t ret_ref = tag_ptr(ret_copy, true);
8298         return ret_ref;
8299 }
8300
8301 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
8302 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
8303 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
8304 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
8305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
8306         LDKParseOrSemanticError_ParseError_class =
8307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
8308         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
8309         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
8310         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
8311         LDKParseOrSemanticError_SemanticError_class =
8312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
8313         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
8314         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
8315         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
8316 }
8317 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8318         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
8319         switch(obj->tag) {
8320                 case LDKParseOrSemanticError_ParseError: {
8321                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
8322                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
8323                 }
8324                 case LDKParseOrSemanticError_SemanticError: {
8325                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
8326                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
8327                 }
8328                 default: abort();
8329         }
8330 }
8331 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8332         LDKInvoice ret = *owner->contents.result;
8333         ret.is_owned = false;
8334         return ret;
8335 }
8336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8337         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8338         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
8339         int64_t ret_ref = 0;
8340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8342         return ret_ref;
8343 }
8344
8345 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8346 CHECK(!owner->result_ok);
8347         return ParseOrSemanticError_clone(&*owner->contents.err);
8348 }
8349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8350         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8351         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
8352         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
8353         int64_t ret_ref = tag_ptr(ret_copy, true);
8354         return ret_ref;
8355 }
8356
8357 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8358         LDKSignedRawInvoice ret = *owner->contents.result;
8359         ret.is_owned = false;
8360         return ret;
8361 }
8362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8363         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8364         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
8365         int64_t ret_ref = 0;
8366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8368         return ret_ref;
8369 }
8370
8371 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8372 CHECK(!owner->result_ok);
8373         return ParseError_clone(&*owner->contents.err);
8374 }
8375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8376         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8377         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8378         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
8379         int64_t ret_ref = tag_ptr(ret_copy, true);
8380         return ret_ref;
8381 }
8382
8383 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8384         LDKRawInvoice ret = owner->a;
8385         ret.is_owned = false;
8386         return ret;
8387 }
8388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8389         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8390         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8391         int64_t ret_ref = 0;
8392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8394         return ret_ref;
8395 }
8396
8397 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8398         return ThirtyTwoBytes_clone(&owner->b);
8399 }
8400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8401         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8402         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8404         return ret_arr;
8405 }
8406
8407 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8408         LDKInvoiceSignature ret = owner->c;
8409         ret.is_owned = false;
8410         return ret;
8411 }
8412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8413         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8414         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
8415         int64_t ret_ref = 0;
8416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8418         return ret_ref;
8419 }
8420
8421 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8422         LDKPayeePubKey ret = *owner->contents.result;
8423         ret.is_owned = false;
8424         return ret;
8425 }
8426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8427         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8428         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
8429         int64_t ret_ref = 0;
8430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8432         return ret_ref;
8433 }
8434
8435 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8436 CHECK(!owner->result_ok);
8437         return *owner->contents.err;
8438 }
8439 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8440         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8441         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8442         return ret_conv;
8443 }
8444
8445 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8446         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8447         for (size_t i = 0; i < ret.datalen; i++) {
8448                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8449         }
8450         return ret;
8451 }
8452 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8453         LDKPositiveTimestamp ret = *owner->contents.result;
8454         ret.is_owned = false;
8455         return ret;
8456 }
8457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8458         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8459         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8460         int64_t ret_ref = 0;
8461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8463         return ret_ref;
8464 }
8465
8466 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8467 CHECK(!owner->result_ok);
8468         return CreationError_clone(&*owner->contents.err);
8469 }
8470 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8471         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8472         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8473         return ret_conv;
8474 }
8475
8476 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8477 CHECK(owner->result_ok);
8478         return *owner->contents.result;
8479 }
8480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8481         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8482         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8483 }
8484
8485 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8486 CHECK(!owner->result_ok);
8487         return SemanticError_clone(&*owner->contents.err);
8488 }
8489 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8490         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8491         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8492         return ret_conv;
8493 }
8494
8495 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8496         LDKInvoice ret = *owner->contents.result;
8497         ret.is_owned = false;
8498         return ret;
8499 }
8500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8501         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8502         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8503         int64_t ret_ref = 0;
8504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8506         return ret_ref;
8507 }
8508
8509 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8510 CHECK(!owner->result_ok);
8511         return SemanticError_clone(&*owner->contents.err);
8512 }
8513 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8514         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8515         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8516         return ret_conv;
8517 }
8518
8519 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8520         LDKDescription ret = *owner->contents.result;
8521         ret.is_owned = false;
8522         return ret;
8523 }
8524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8525         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8526         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8527         int64_t ret_ref = 0;
8528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8530         return ret_ref;
8531 }
8532
8533 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8534 CHECK(!owner->result_ok);
8535         return CreationError_clone(&*owner->contents.err);
8536 }
8537 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8538         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8539         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8540         return ret_conv;
8541 }
8542
8543 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8544         LDKPrivateRoute ret = *owner->contents.result;
8545         ret.is_owned = false;
8546         return ret;
8547 }
8548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8549         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8550         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
8551         int64_t ret_ref = 0;
8552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8554         return ret_ref;
8555 }
8556
8557 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8558 CHECK(!owner->result_ok);
8559         return CreationError_clone(&*owner->contents.err);
8560 }
8561 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8562         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8563         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8564         return ret_conv;
8565 }
8566
8567 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8568 CHECK(owner->result_ok);
8569         return *owner->contents.result;
8570 }
8571 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8572         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8573         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8574         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8575         return ret_conv;
8576 }
8577
8578 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8579 CHECK(!owner->result_ok);
8580         return *owner->contents.err;
8581 }
8582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8583         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8584         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8585         return ret_conv;
8586 }
8587
8588 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8589         LDKChannelMonitorUpdate ret = *owner->contents.result;
8590         ret.is_owned = false;
8591         return ret;
8592 }
8593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8594         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8595         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8596         int64_t ret_ref = 0;
8597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8599         return ret_ref;
8600 }
8601
8602 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8603 CHECK(!owner->result_ok);
8604         return DecodeError_clone(&*owner->contents.err);
8605 }
8606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8607         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8608         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8609         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8610         int64_t ret_ref = tag_ptr(ret_copy, true);
8611         return ret_ref;
8612 }
8613
8614 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8615 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8616 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8617 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8619         LDKCOption_MonitorEventZ_Some_class =
8620                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8621         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8622         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8623         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8624         LDKCOption_MonitorEventZ_None_class =
8625                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8626         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8627         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8628         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8629 }
8630 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8631         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
8632         switch(obj->tag) {
8633                 case LDKCOption_MonitorEventZ_Some: {
8634                         int64_t some_ref = tag_ptr(&obj->some, false);
8635                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8636                 }
8637                 case LDKCOption_MonitorEventZ_None: {
8638                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8639                 }
8640                 default: abort();
8641         }
8642 }
8643 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8644 CHECK(owner->result_ok);
8645         return COption_MonitorEventZ_clone(&*owner->contents.result);
8646 }
8647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8648         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8649         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8650         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8651         int64_t ret_ref = tag_ptr(ret_copy, true);
8652         return ret_ref;
8653 }
8654
8655 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8656 CHECK(!owner->result_ok);
8657         return DecodeError_clone(&*owner->contents.err);
8658 }
8659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8660         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8661         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8662         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8663         int64_t ret_ref = tag_ptr(ret_copy, true);
8664         return ret_ref;
8665 }
8666
8667 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8668         LDKHTLCUpdate ret = *owner->contents.result;
8669         ret.is_owned = false;
8670         return ret;
8671 }
8672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8673         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8674         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8675         int64_t ret_ref = 0;
8676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8678         return ret_ref;
8679 }
8680
8681 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8682 CHECK(!owner->result_ok);
8683         return DecodeError_clone(&*owner->contents.err);
8684 }
8685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8686         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8687         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8688         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8689         int64_t ret_ref = tag_ptr(ret_copy, true);
8690         return ret_ref;
8691 }
8692
8693 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8694         LDKOutPoint ret = owner->a;
8695         ret.is_owned = false;
8696         return ret;
8697 }
8698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8699         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8700         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8701         int64_t ret_ref = 0;
8702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8704         return ret_ref;
8705 }
8706
8707 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8708         return CVec_u8Z_clone(&owner->b);
8709 }
8710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8711         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8712         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8713         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8714         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8715         CVec_u8Z_free(ret_var);
8716         return ret_arr;
8717 }
8718
8719 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8720         return owner->a;
8721 }
8722 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8723         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8724         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8725         return ret_conv;
8726 }
8727
8728 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8729         return CVec_u8Z_clone(&owner->b);
8730 }
8731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8732         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8733         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8736         CVec_u8Z_free(ret_var);
8737         return ret_arr;
8738 }
8739
8740 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8741         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8742         for (size_t i = 0; i < ret.datalen; i++) {
8743                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8744         }
8745         return ret;
8746 }
8747 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8748         return ThirtyTwoBytes_clone(&owner->a);
8749 }
8750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8751         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8752         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8754         return ret_arr;
8755 }
8756
8757 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8758         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8759 }
8760 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8761         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8762         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8763         int64_tArray ret_arr = NULL;
8764         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8765         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8766         for (size_t v = 0; v < ret_var.datalen; v++) {
8767                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8768                 *ret_conv_21_conv = ret_var.data[v];
8769                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
8770         }
8771         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8772         FREE(ret_var.data);
8773         return ret_arr;
8774 }
8775
8776 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8777         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
8778         for (size_t i = 0; i < ret.datalen; i++) {
8779                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8780         }
8781         return ret;
8782 }
8783 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8784         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8785         for (size_t i = 0; i < ret.datalen; i++) {
8786                 ret.data[i] = Event_clone(&orig->data[i]);
8787         }
8788         return ret;
8789 }
8790 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8791         return owner->a;
8792 }
8793 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8794         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8795         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8796         return ret_conv;
8797 }
8798
8799 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8800         return TxOut_clone(&owner->b);
8801 }
8802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8803         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8804         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8805         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8806         return tag_ptr(ret_ref, true);
8807 }
8808
8809 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8810         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8811         for (size_t i = 0; i < ret.datalen; i++) {
8812                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8813         }
8814         return ret;
8815 }
8816 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8817         return ThirtyTwoBytes_clone(&owner->a);
8818 }
8819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8820         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8821         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8823         return ret_arr;
8824 }
8825
8826 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8827         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8828 }
8829 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8830         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8831         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8832         int64_tArray ret_arr = NULL;
8833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8835         for (size_t u = 0; u < ret_var.datalen; u++) {
8836                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8837                 *ret_conv_20_conv = ret_var.data[u];
8838                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
8839         }
8840         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8841         FREE(ret_var.data);
8842         return ret_arr;
8843 }
8844
8845 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8846         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
8847         for (size_t i = 0; i < ret.datalen; i++) {
8848                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8849         }
8850         return ret;
8851 }
8852 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8853 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8854 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8855 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8856 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8857 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8858 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
8859 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
8860 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
8861 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
8862 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
8863 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
8864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8865         LDKBalance_ClaimableOnChannelClose_class =
8866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8867         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8868         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8869         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8870         LDKBalance_ClaimableAwaitingConfirmations_class =
8871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8872         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8873         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8874         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8875         LDKBalance_ContentiousClaimable_class =
8876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8877         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8878         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8879         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8880         LDKBalance_MaybeTimeoutClaimableHTLC_class =
8881                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
8882         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
8883         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
8884         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
8885         LDKBalance_MaybePreimageClaimableHTLC_class =
8886                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
8887         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
8888         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
8889         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
8890         LDKBalance_CounterpartyRevokedOutputClaimable_class =
8891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
8892         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
8893         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
8894         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
8895 }
8896 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8897         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
8898         switch(obj->tag) {
8899                 case LDKBalance_ClaimableOnChannelClose: {
8900                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8901                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8902                 }
8903                 case LDKBalance_ClaimableAwaitingConfirmations: {
8904                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8905                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8906                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8907                 }
8908                 case LDKBalance_ContentiousClaimable: {
8909                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8910                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8911                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8912                 }
8913                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
8914                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
8915                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
8916                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8917                 }
8918                 case LDKBalance_MaybePreimageClaimableHTLC: {
8919                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
8920                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
8921                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
8922                 }
8923                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
8924                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
8925                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
8926                 }
8927                 default: abort();
8928         }
8929 }
8930 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8931         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8932         for (size_t i = 0; i < ret.datalen; i++) {
8933                 ret.data[i] = Balance_clone(&orig->data[i]);
8934         }
8935         return ret;
8936 }
8937 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8938 CHECK(owner->result_ok);
8939         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8940 }
8941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8942         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8943         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8944         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8945         return tag_ptr(ret_conv, true);
8946 }
8947
8948 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8949 CHECK(!owner->result_ok);
8950         return DecodeError_clone(&*owner->contents.err);
8951 }
8952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8953         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8954         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8955         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8956         int64_t ret_ref = tag_ptr(ret_copy, true);
8957         return ret_ref;
8958 }
8959
8960 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8961         return owner->a;
8962 }
8963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8964         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8965         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8967         return ret_arr;
8968 }
8969
8970 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8971         return Type_clone(&owner->b);
8972 }
8973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8974         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8975         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8976         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8977         return tag_ptr(ret_ret, true);
8978 }
8979
8980 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8981         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8982         for (size_t i = 0; i < ret.datalen; i++) {
8983                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8984         }
8985         return ret;
8986 }
8987 typedef struct LDKCustomOnionMessageContents_JCalls {
8988         atomic_size_t refcnt;
8989         JavaVM *vm;
8990         jweak o;
8991         jmethodID tlv_type_meth;
8992         jmethodID write_meth;
8993 } LDKCustomOnionMessageContents_JCalls;
8994 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
8995         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8996         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8997                 JNIEnv *env;
8998                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8999                 if (get_jenv_res == JNI_EDETACHED) {
9000                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9001                 } else {
9002                         DO_ASSERT(get_jenv_res == JNI_OK);
9003                 }
9004                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9005                 if (get_jenv_res == JNI_EDETACHED) {
9006                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9007                 }
9008                 FREE(j_calls);
9009         }
9010 }
9011 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9012         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9013         JNIEnv *env;
9014         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9015         if (get_jenv_res == JNI_EDETACHED) {
9016                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9017         } else {
9018                 DO_ASSERT(get_jenv_res == JNI_OK);
9019         }
9020         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9021         CHECK(obj != NULL);
9022         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
9023         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9024                 (*env)->ExceptionDescribe(env);
9025                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
9026         }
9027         if (get_jenv_res == JNI_EDETACHED) {
9028                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9029         }
9030         return ret;
9031 }
9032 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9033         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9034         JNIEnv *env;
9035         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9036         if (get_jenv_res == JNI_EDETACHED) {
9037                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9038         } else {
9039                 DO_ASSERT(get_jenv_res == JNI_OK);
9040         }
9041         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9042         CHECK(obj != NULL);
9043         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9044         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9045                 (*env)->ExceptionDescribe(env);
9046                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
9047         }
9048         LDKCVec_u8Z ret_ref;
9049         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9050         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9051         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9052         if (get_jenv_res == JNI_EDETACHED) {
9053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9054         }
9055         return ret_ref;
9056 }
9057 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
9058         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
9059         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9060 }
9061 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
9062         jclass c = (*env)->GetObjectClass(env, o);
9063         CHECK(c != NULL);
9064         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
9065         atomic_init(&calls->refcnt, 1);
9066         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9067         calls->o = (*env)->NewWeakGlobalRef(env, o);
9068         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
9069         CHECK(calls->tlv_type_meth != NULL);
9070         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9071         CHECK(calls->write_meth != NULL);
9072
9073         LDKCustomOnionMessageContents ret = {
9074                 .this_arg = (void*) calls,
9075                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
9076                 .write = write_LDKCustomOnionMessageContents_jcall,
9077                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
9078                 .free = LDKCustomOnionMessageContents_JCalls_free,
9079         };
9080         return ret;
9081 }
9082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
9083         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9084         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
9085         return tag_ptr(res_ptr, true);
9086 }
9087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
9088         void* this_arg_ptr = untag_ptr(this_arg);
9089         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9090         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9091         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
9092         return ret_conv;
9093 }
9094
9095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9096         void* this_arg_ptr = untag_ptr(this_arg);
9097         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9098         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9099         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9102         CVec_u8Z_free(ret_var);
9103         return ret_arr;
9104 }
9105
9106 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
9107 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
9108 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
9109 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
9110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
9111         LDKCOption_CustomOnionMessageContentsZ_Some_class =
9112                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
9113         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
9114         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
9115         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
9116         LDKCOption_CustomOnionMessageContentsZ_None_class =
9117                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
9118         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
9119         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
9120         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
9121 }
9122 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9123         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
9124         switch(obj->tag) {
9125                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
9126                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9127                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
9128                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
9129                 }
9130                 case LDKCOption_CustomOnionMessageContentsZ_None: {
9131                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
9132                 }
9133                 default: abort();
9134         }
9135 }
9136 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9137 CHECK(owner->result_ok);
9138         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
9139 }
9140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9141         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9142         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
9143         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
9144         int64_t ret_ref = tag_ptr(ret_copy, true);
9145         return ret_ref;
9146 }
9147
9148 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9149 CHECK(!owner->result_ok);
9150         return DecodeError_clone(&*owner->contents.err);
9151 }
9152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9153         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9154         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9155         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
9156         int64_t ret_ref = tag_ptr(ret_copy, true);
9157         return ret_ref;
9158 }
9159
9160 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
9161 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
9162 static jclass LDKCOption_NetAddressZ_None_class = NULL;
9163 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
9164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
9165         LDKCOption_NetAddressZ_Some_class =
9166                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
9167         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
9168         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
9169         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
9170         LDKCOption_NetAddressZ_None_class =
9171                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
9172         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
9173         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
9174         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
9175 }
9176 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9177         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
9178         switch(obj->tag) {
9179                 case LDKCOption_NetAddressZ_Some: {
9180                         int64_t some_ref = tag_ptr(&obj->some, false);
9181                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
9182                 }
9183                 case LDKCOption_NetAddressZ_None: {
9184                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
9185                 }
9186                 default: abort();
9187         }
9188 }
9189 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9190 CHECK(owner->result_ok);
9191         return CVec_u8Z_clone(&*owner->contents.result);
9192 }
9193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9194         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9195         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
9196         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9197         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9198         CVec_u8Z_free(ret_var);
9199         return ret_arr;
9200 }
9201
9202 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9203         LDKPeerHandleError ret = *owner->contents.err;
9204         ret.is_owned = false;
9205         return ret;
9206 }
9207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9208         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9209         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
9210         int64_t ret_ref = 0;
9211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9213         return ret_ref;
9214 }
9215
9216 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9217 CHECK(owner->result_ok);
9218         return *owner->contents.result;
9219 }
9220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9221         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9222         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
9223 }
9224
9225 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9226         LDKPeerHandleError ret = *owner->contents.err;
9227         ret.is_owned = false;
9228         return ret;
9229 }
9230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9231         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9232         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9233         int64_t ret_ref = 0;
9234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9236         return ret_ref;
9237 }
9238
9239 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9240 CHECK(owner->result_ok);
9241         return *owner->contents.result;
9242 }
9243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9244         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9245         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9246         return ret_conv;
9247 }
9248
9249 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9250         LDKPeerHandleError ret = *owner->contents.err;
9251         ret.is_owned = false;
9252         return ret;
9253 }
9254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9255         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9256         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9257         int64_t ret_ref = 0;
9258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9260         return ret_ref;
9261 }
9262
9263 static jclass LDKSendError_Secp256k1_class = NULL;
9264 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9265 static jclass LDKSendError_TooBigPacket_class = NULL;
9266 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9267 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9268 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9269 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9270 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9271 static jclass LDKSendError_InvalidMessage_class = NULL;
9272 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
9273 static jclass LDKSendError_BufferFull_class = NULL;
9274 static jmethodID LDKSendError_BufferFull_meth = NULL;
9275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9276         LDKSendError_Secp256k1_class =
9277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9278         CHECK(LDKSendError_Secp256k1_class != NULL);
9279         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9280         CHECK(LDKSendError_Secp256k1_meth != NULL);
9281         LDKSendError_TooBigPacket_class =
9282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9283         CHECK(LDKSendError_TooBigPacket_class != NULL);
9284         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9285         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9286         LDKSendError_TooFewBlindedHops_class =
9287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9288         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9289         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9290         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9291         LDKSendError_InvalidFirstHop_class =
9292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9293         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9294         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9295         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9296         LDKSendError_InvalidMessage_class =
9297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
9298         CHECK(LDKSendError_InvalidMessage_class != NULL);
9299         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
9300         CHECK(LDKSendError_InvalidMessage_meth != NULL);
9301         LDKSendError_BufferFull_class =
9302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9303         CHECK(LDKSendError_BufferFull_class != NULL);
9304         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9305         CHECK(LDKSendError_BufferFull_meth != NULL);
9306 }
9307 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9308         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9309         switch(obj->tag) {
9310                 case LDKSendError_Secp256k1: {
9311                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9312                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9313                 }
9314                 case LDKSendError_TooBigPacket: {
9315                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9316                 }
9317                 case LDKSendError_TooFewBlindedHops: {
9318                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9319                 }
9320                 case LDKSendError_InvalidFirstHop: {
9321                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9322                 }
9323                 case LDKSendError_InvalidMessage: {
9324                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
9325                 }
9326                 case LDKSendError_BufferFull: {
9327                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9328                 }
9329                 default: abort();
9330         }
9331 }
9332 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9333 CHECK(owner->result_ok);
9334         return *owner->contents.result;
9335 }
9336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9337         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9338         CResult_NoneSendErrorZ_get_ok(owner_conv);
9339 }
9340
9341 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9342 CHECK(!owner->result_ok);
9343         return SendError_clone(&*owner->contents.err);
9344 }
9345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9346         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9347         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9348         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9349         int64_t ret_ref = tag_ptr(ret_copy, true);
9350         return ret_ref;
9351 }
9352
9353 static jclass LDKGraphSyncError_DecodeError_class = NULL;
9354 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
9355 static jclass LDKGraphSyncError_LightningError_class = NULL;
9356 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
9357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
9358         LDKGraphSyncError_DecodeError_class =
9359                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
9360         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
9361         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
9362         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
9363         LDKGraphSyncError_LightningError_class =
9364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
9365         CHECK(LDKGraphSyncError_LightningError_class != NULL);
9366         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
9367         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
9368 }
9369 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9370         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
9371         switch(obj->tag) {
9372                 case LDKGraphSyncError_DecodeError: {
9373                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
9374                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
9375                 }
9376                 case LDKGraphSyncError_LightningError: {
9377                         LDKLightningError lightning_error_var = obj->lightning_error;
9378                         int64_t lightning_error_ref = 0;
9379                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
9380                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
9381                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
9382                 }
9383                 default: abort();
9384         }
9385 }
9386 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9387 CHECK(owner->result_ok);
9388         return *owner->contents.result;
9389 }
9390 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9391         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9392         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
9393         return ret_conv;
9394 }
9395
9396 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9397 CHECK(!owner->result_ok);
9398         return GraphSyncError_clone(&*owner->contents.err);
9399 }
9400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9401         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9402         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
9403         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
9404         int64_t ret_ref = tag_ptr(ret_copy, true);
9405         return ret_ref;
9406 }
9407
9408 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9409 CHECK(owner->result_ok);
9410         return NetAddress_clone(&*owner->contents.result);
9411 }
9412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9413         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9414         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9415         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
9416         int64_t ret_ref = tag_ptr(ret_copy, true);
9417         return ret_ref;
9418 }
9419
9420 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9421 CHECK(!owner->result_ok);
9422         return DecodeError_clone(&*owner->contents.err);
9423 }
9424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9425         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9426         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9427         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
9428         int64_t ret_ref = tag_ptr(ret_copy, true);
9429         return ret_ref;
9430 }
9431
9432 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
9433         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
9434         for (size_t i = 0; i < ret.datalen; i++) {
9435                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
9436         }
9437         return ret;
9438 }
9439 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
9440         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
9441         for (size_t i = 0; i < ret.datalen; i++) {
9442                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
9443         }
9444         return ret;
9445 }
9446 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
9447         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
9448         for (size_t i = 0; i < ret.datalen; i++) {
9449                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
9450         }
9451         return ret;
9452 }
9453 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
9454         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
9455         for (size_t i = 0; i < ret.datalen; i++) {
9456                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
9457         }
9458         return ret;
9459 }
9460 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9461         LDKAcceptChannel ret = *owner->contents.result;
9462         ret.is_owned = false;
9463         return ret;
9464 }
9465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9466         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9467         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
9468         int64_t ret_ref = 0;
9469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9471         return ret_ref;
9472 }
9473
9474 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9475 CHECK(!owner->result_ok);
9476         return DecodeError_clone(&*owner->contents.err);
9477 }
9478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9479         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9480         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9481         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
9482         int64_t ret_ref = tag_ptr(ret_copy, true);
9483         return ret_ref;
9484 }
9485
9486 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9487         LDKAnnouncementSignatures ret = *owner->contents.result;
9488         ret.is_owned = false;
9489         return ret;
9490 }
9491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9492         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9493         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
9494         int64_t ret_ref = 0;
9495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9497         return ret_ref;
9498 }
9499
9500 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9501 CHECK(!owner->result_ok);
9502         return DecodeError_clone(&*owner->contents.err);
9503 }
9504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9505         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9506         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9507         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
9508         int64_t ret_ref = tag_ptr(ret_copy, true);
9509         return ret_ref;
9510 }
9511
9512 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9513         LDKChannelReestablish ret = *owner->contents.result;
9514         ret.is_owned = false;
9515         return ret;
9516 }
9517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9518         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9519         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
9520         int64_t ret_ref = 0;
9521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9523         return ret_ref;
9524 }
9525
9526 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9527 CHECK(!owner->result_ok);
9528         return DecodeError_clone(&*owner->contents.err);
9529 }
9530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9531         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9532         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9533         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
9534         int64_t ret_ref = tag_ptr(ret_copy, true);
9535         return ret_ref;
9536 }
9537
9538 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9539         LDKClosingSigned ret = *owner->contents.result;
9540         ret.is_owned = false;
9541         return ret;
9542 }
9543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9544         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9545         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
9546         int64_t ret_ref = 0;
9547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9549         return ret_ref;
9550 }
9551
9552 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9553 CHECK(!owner->result_ok);
9554         return DecodeError_clone(&*owner->contents.err);
9555 }
9556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9557         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9558         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9559         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9560         int64_t ret_ref = tag_ptr(ret_copy, true);
9561         return ret_ref;
9562 }
9563
9564 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9565         LDKClosingSignedFeeRange ret = *owner->contents.result;
9566         ret.is_owned = false;
9567         return ret;
9568 }
9569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9570         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9571         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9572         int64_t ret_ref = 0;
9573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9574         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9575         return ret_ref;
9576 }
9577
9578 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9579 CHECK(!owner->result_ok);
9580         return DecodeError_clone(&*owner->contents.err);
9581 }
9582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9583         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9584         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9585         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9586         int64_t ret_ref = tag_ptr(ret_copy, true);
9587         return ret_ref;
9588 }
9589
9590 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9591         LDKCommitmentSigned ret = *owner->contents.result;
9592         ret.is_owned = false;
9593         return ret;
9594 }
9595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9596         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9597         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9598         int64_t ret_ref = 0;
9599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9601         return ret_ref;
9602 }
9603
9604 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9605 CHECK(!owner->result_ok);
9606         return DecodeError_clone(&*owner->contents.err);
9607 }
9608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9609         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9610         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9611         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9612         int64_t ret_ref = tag_ptr(ret_copy, true);
9613         return ret_ref;
9614 }
9615
9616 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9617         LDKFundingCreated ret = *owner->contents.result;
9618         ret.is_owned = false;
9619         return ret;
9620 }
9621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9622         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9623         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9624         int64_t ret_ref = 0;
9625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9627         return ret_ref;
9628 }
9629
9630 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9631 CHECK(!owner->result_ok);
9632         return DecodeError_clone(&*owner->contents.err);
9633 }
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9635         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9636         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9637         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9638         int64_t ret_ref = tag_ptr(ret_copy, true);
9639         return ret_ref;
9640 }
9641
9642 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9643         LDKFundingSigned ret = *owner->contents.result;
9644         ret.is_owned = false;
9645         return ret;
9646 }
9647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9648         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9649         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9650         int64_t ret_ref = 0;
9651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9653         return ret_ref;
9654 }
9655
9656 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9657 CHECK(!owner->result_ok);
9658         return DecodeError_clone(&*owner->contents.err);
9659 }
9660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9661         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9662         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9663         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9664         int64_t ret_ref = tag_ptr(ret_copy, true);
9665         return ret_ref;
9666 }
9667
9668 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9669         LDKChannelReady ret = *owner->contents.result;
9670         ret.is_owned = false;
9671         return ret;
9672 }
9673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9674         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9675         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9676         int64_t ret_ref = 0;
9677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9679         return ret_ref;
9680 }
9681
9682 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9683 CHECK(!owner->result_ok);
9684         return DecodeError_clone(&*owner->contents.err);
9685 }
9686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9687         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9688         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9689         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9690         int64_t ret_ref = tag_ptr(ret_copy, true);
9691         return ret_ref;
9692 }
9693
9694 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9695         LDKInit ret = *owner->contents.result;
9696         ret.is_owned = false;
9697         return ret;
9698 }
9699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9700         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9701         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9702         int64_t ret_ref = 0;
9703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9705         return ret_ref;
9706 }
9707
9708 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9709 CHECK(!owner->result_ok);
9710         return DecodeError_clone(&*owner->contents.err);
9711 }
9712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9713         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9714         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9715         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
9716         int64_t ret_ref = tag_ptr(ret_copy, true);
9717         return ret_ref;
9718 }
9719
9720 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9721         LDKOpenChannel ret = *owner->contents.result;
9722         ret.is_owned = false;
9723         return ret;
9724 }
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9726         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9727         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9728         int64_t ret_ref = 0;
9729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9731         return ret_ref;
9732 }
9733
9734 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9735 CHECK(!owner->result_ok);
9736         return DecodeError_clone(&*owner->contents.err);
9737 }
9738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9739         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9740         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9741         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9742         int64_t ret_ref = tag_ptr(ret_copy, true);
9743         return ret_ref;
9744 }
9745
9746 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9747         LDKRevokeAndACK ret = *owner->contents.result;
9748         ret.is_owned = false;
9749         return ret;
9750 }
9751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9752         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9753         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9754         int64_t ret_ref = 0;
9755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9757         return ret_ref;
9758 }
9759
9760 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9761 CHECK(!owner->result_ok);
9762         return DecodeError_clone(&*owner->contents.err);
9763 }
9764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9765         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9766         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9767         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9768         int64_t ret_ref = tag_ptr(ret_copy, true);
9769         return ret_ref;
9770 }
9771
9772 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9773         LDKShutdown ret = *owner->contents.result;
9774         ret.is_owned = false;
9775         return ret;
9776 }
9777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9778         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9779         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9780         int64_t ret_ref = 0;
9781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9783         return ret_ref;
9784 }
9785
9786 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9787 CHECK(!owner->result_ok);
9788         return DecodeError_clone(&*owner->contents.err);
9789 }
9790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9791         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9792         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9793         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9794         int64_t ret_ref = tag_ptr(ret_copy, true);
9795         return ret_ref;
9796 }
9797
9798 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9799         LDKUpdateFailHTLC ret = *owner->contents.result;
9800         ret.is_owned = false;
9801         return ret;
9802 }
9803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9804         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9805         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9806         int64_t ret_ref = 0;
9807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9809         return ret_ref;
9810 }
9811
9812 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9813 CHECK(!owner->result_ok);
9814         return DecodeError_clone(&*owner->contents.err);
9815 }
9816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9817         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9818         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9819         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9820         int64_t ret_ref = tag_ptr(ret_copy, true);
9821         return ret_ref;
9822 }
9823
9824 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9825         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
9826         ret.is_owned = false;
9827         return ret;
9828 }
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9830         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9831         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9832         int64_t ret_ref = 0;
9833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9835         return ret_ref;
9836 }
9837
9838 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9839 CHECK(!owner->result_ok);
9840         return DecodeError_clone(&*owner->contents.err);
9841 }
9842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9843         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9844         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9845         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9846         int64_t ret_ref = tag_ptr(ret_copy, true);
9847         return ret_ref;
9848 }
9849
9850 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9851         LDKUpdateFee ret = *owner->contents.result;
9852         ret.is_owned = false;
9853         return ret;
9854 }
9855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9856         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9857         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9858         int64_t ret_ref = 0;
9859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9861         return ret_ref;
9862 }
9863
9864 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9865 CHECK(!owner->result_ok);
9866         return DecodeError_clone(&*owner->contents.err);
9867 }
9868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9869         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9870         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9871         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9872         int64_t ret_ref = tag_ptr(ret_copy, true);
9873         return ret_ref;
9874 }
9875
9876 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9877         LDKUpdateFulfillHTLC ret = *owner->contents.result;
9878         ret.is_owned = false;
9879         return ret;
9880 }
9881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9882         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9883         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9884         int64_t ret_ref = 0;
9885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9887         return ret_ref;
9888 }
9889
9890 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9891 CHECK(!owner->result_ok);
9892         return DecodeError_clone(&*owner->contents.err);
9893 }
9894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9895         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9896         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9897         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9898         int64_t ret_ref = tag_ptr(ret_copy, true);
9899         return ret_ref;
9900 }
9901
9902 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9903         LDKUpdateAddHTLC ret = *owner->contents.result;
9904         ret.is_owned = false;
9905         return ret;
9906 }
9907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9908         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9909         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9910         int64_t ret_ref = 0;
9911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9913         return ret_ref;
9914 }
9915
9916 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9917 CHECK(!owner->result_ok);
9918         return DecodeError_clone(&*owner->contents.err);
9919 }
9920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9921         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9922         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9923         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9924         int64_t ret_ref = tag_ptr(ret_copy, true);
9925         return ret_ref;
9926 }
9927
9928 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9929         LDKOnionMessage ret = *owner->contents.result;
9930         ret.is_owned = false;
9931         return ret;
9932 }
9933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9934         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9935         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
9936         int64_t ret_ref = 0;
9937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9939         return ret_ref;
9940 }
9941
9942 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9943 CHECK(!owner->result_ok);
9944         return DecodeError_clone(&*owner->contents.err);
9945 }
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9947         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9948         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9949         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
9950         int64_t ret_ref = tag_ptr(ret_copy, true);
9951         return ret_ref;
9952 }
9953
9954 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9955         LDKPing ret = *owner->contents.result;
9956         ret.is_owned = false;
9957         return ret;
9958 }
9959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9960         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9961         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9962         int64_t ret_ref = 0;
9963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9965         return ret_ref;
9966 }
9967
9968 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9969 CHECK(!owner->result_ok);
9970         return DecodeError_clone(&*owner->contents.err);
9971 }
9972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9973         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9974         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9975         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
9976         int64_t ret_ref = tag_ptr(ret_copy, true);
9977         return ret_ref;
9978 }
9979
9980 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9981         LDKPong ret = *owner->contents.result;
9982         ret.is_owned = false;
9983         return ret;
9984 }
9985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9986         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
9987         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9988         int64_t ret_ref = 0;
9989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9991         return ret_ref;
9992 }
9993
9994 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9995 CHECK(!owner->result_ok);
9996         return DecodeError_clone(&*owner->contents.err);
9997 }
9998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9999         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10000         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10001         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
10002         int64_t ret_ref = tag_ptr(ret_copy, true);
10003         return ret_ref;
10004 }
10005
10006 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10007         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
10008         ret.is_owned = false;
10009         return ret;
10010 }
10011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10012         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10013         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10014         int64_t ret_ref = 0;
10015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10017         return ret_ref;
10018 }
10019
10020 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10021 CHECK(!owner->result_ok);
10022         return DecodeError_clone(&*owner->contents.err);
10023 }
10024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10025         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10026         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10027         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10028         int64_t ret_ref = tag_ptr(ret_copy, true);
10029         return ret_ref;
10030 }
10031
10032 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10033         LDKChannelAnnouncement ret = *owner->contents.result;
10034         ret.is_owned = false;
10035         return ret;
10036 }
10037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10038         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10039         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10040         int64_t ret_ref = 0;
10041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10043         return ret_ref;
10044 }
10045
10046 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10047 CHECK(!owner->result_ok);
10048         return DecodeError_clone(&*owner->contents.err);
10049 }
10050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10051         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10052         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10053         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10054         int64_t ret_ref = tag_ptr(ret_copy, true);
10055         return ret_ref;
10056 }
10057
10058 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10059         LDKUnsignedChannelUpdate ret = *owner->contents.result;
10060         ret.is_owned = false;
10061         return ret;
10062 }
10063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10064         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10065         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10066         int64_t ret_ref = 0;
10067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10069         return ret_ref;
10070 }
10071
10072 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10073 CHECK(!owner->result_ok);
10074         return DecodeError_clone(&*owner->contents.err);
10075 }
10076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10077         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10078         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10079         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
10080         int64_t ret_ref = tag_ptr(ret_copy, true);
10081         return ret_ref;
10082 }
10083
10084 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10085         LDKChannelUpdate ret = *owner->contents.result;
10086         ret.is_owned = false;
10087         return ret;
10088 }
10089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10090         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10091         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10092         int64_t ret_ref = 0;
10093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10095         return ret_ref;
10096 }
10097
10098 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10099 CHECK(!owner->result_ok);
10100         return DecodeError_clone(&*owner->contents.err);
10101 }
10102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10103         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10104         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10105         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
10106         int64_t ret_ref = tag_ptr(ret_copy, true);
10107         return ret_ref;
10108 }
10109
10110 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10111         LDKErrorMessage ret = *owner->contents.result;
10112         ret.is_owned = false;
10113         return ret;
10114 }
10115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10116         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10117         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
10118         int64_t ret_ref = 0;
10119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10121         return ret_ref;
10122 }
10123
10124 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10125 CHECK(!owner->result_ok);
10126         return DecodeError_clone(&*owner->contents.err);
10127 }
10128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10129         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10130         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10131         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
10132         int64_t ret_ref = tag_ptr(ret_copy, true);
10133         return ret_ref;
10134 }
10135
10136 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10137         LDKWarningMessage ret = *owner->contents.result;
10138         ret.is_owned = false;
10139         return ret;
10140 }
10141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10142         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10143         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
10144         int64_t ret_ref = 0;
10145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10147         return ret_ref;
10148 }
10149
10150 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10151 CHECK(!owner->result_ok);
10152         return DecodeError_clone(&*owner->contents.err);
10153 }
10154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10155         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10156         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10157         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
10158         int64_t ret_ref = tag_ptr(ret_copy, true);
10159         return ret_ref;
10160 }
10161
10162 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10163         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
10164         ret.is_owned = false;
10165         return ret;
10166 }
10167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10168         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10169         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10170         int64_t ret_ref = 0;
10171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10173         return ret_ref;
10174 }
10175
10176 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10177 CHECK(!owner->result_ok);
10178         return DecodeError_clone(&*owner->contents.err);
10179 }
10180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10181         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10182         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10183         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10184         int64_t ret_ref = tag_ptr(ret_copy, true);
10185         return ret_ref;
10186 }
10187
10188 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10189         LDKNodeAnnouncement ret = *owner->contents.result;
10190         ret.is_owned = false;
10191         return ret;
10192 }
10193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10194         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10195         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10196         int64_t ret_ref = 0;
10197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10199         return ret_ref;
10200 }
10201
10202 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10203 CHECK(!owner->result_ok);
10204         return DecodeError_clone(&*owner->contents.err);
10205 }
10206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10207         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10208         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10209         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10210         int64_t ret_ref = tag_ptr(ret_copy, true);
10211         return ret_ref;
10212 }
10213
10214 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10215         LDKQueryShortChannelIds ret = *owner->contents.result;
10216         ret.is_owned = false;
10217         return ret;
10218 }
10219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10220         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10221         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
10222         int64_t ret_ref = 0;
10223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10225         return ret_ref;
10226 }
10227
10228 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10229 CHECK(!owner->result_ok);
10230         return DecodeError_clone(&*owner->contents.err);
10231 }
10232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10233         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10234         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10235         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
10236         int64_t ret_ref = tag_ptr(ret_copy, true);
10237         return ret_ref;
10238 }
10239
10240 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10241         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
10242         ret.is_owned = false;
10243         return ret;
10244 }
10245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10246         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10247         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
10248         int64_t ret_ref = 0;
10249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10251         return ret_ref;
10252 }
10253
10254 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10255 CHECK(!owner->result_ok);
10256         return DecodeError_clone(&*owner->contents.err);
10257 }
10258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10259         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10260         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10261         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
10262         int64_t ret_ref = tag_ptr(ret_copy, true);
10263         return ret_ref;
10264 }
10265
10266 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10267         LDKQueryChannelRange ret = *owner->contents.result;
10268         ret.is_owned = false;
10269         return ret;
10270 }
10271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10272         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10273         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
10274         int64_t ret_ref = 0;
10275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10277         return ret_ref;
10278 }
10279
10280 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10281 CHECK(!owner->result_ok);
10282         return DecodeError_clone(&*owner->contents.err);
10283 }
10284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10285         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10286         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10287         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
10288         int64_t ret_ref = tag_ptr(ret_copy, true);
10289         return ret_ref;
10290 }
10291
10292 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10293         LDKReplyChannelRange ret = *owner->contents.result;
10294         ret.is_owned = false;
10295         return ret;
10296 }
10297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10298         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10299         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
10300         int64_t ret_ref = 0;
10301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10303         return ret_ref;
10304 }
10305
10306 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10307 CHECK(!owner->result_ok);
10308         return DecodeError_clone(&*owner->contents.err);
10309 }
10310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10311         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10312         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10313         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10314         int64_t ret_ref = tag_ptr(ret_copy, true);
10315         return ret_ref;
10316 }
10317
10318 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10319         LDKGossipTimestampFilter ret = *owner->contents.result;
10320         ret.is_owned = false;
10321         return ret;
10322 }
10323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10324         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10325         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10326         int64_t ret_ref = 0;
10327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10329         return ret_ref;
10330 }
10331
10332 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10333 CHECK(!owner->result_ok);
10334         return DecodeError_clone(&*owner->contents.err);
10335 }
10336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10337         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10338         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10339         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10340         int64_t ret_ref = tag_ptr(ret_copy, true);
10341         return ret_ref;
10342 }
10343
10344 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10345         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10346         for (size_t i = 0; i < ret.datalen; i++) {
10347                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10348         }
10349         return ret;
10350 }
10351 static jclass LDKSignOrCreationError_SignError_class = NULL;
10352 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10353 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10354 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10356         LDKSignOrCreationError_SignError_class =
10357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10358         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10359         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10360         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10361         LDKSignOrCreationError_CreationError_class =
10362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10363         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10364         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10365         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10366 }
10367 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10368         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
10369         switch(obj->tag) {
10370                 case LDKSignOrCreationError_SignError: {
10371                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10372                 }
10373                 case LDKSignOrCreationError_CreationError: {
10374                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10375                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10376                 }
10377                 default: abort();
10378         }
10379 }
10380 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10381         LDKInvoice ret = *owner->contents.result;
10382         ret.is_owned = false;
10383         return ret;
10384 }
10385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10386         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10387         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10388         int64_t ret_ref = 0;
10389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10391         return ret_ref;
10392 }
10393
10394 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10395 CHECK(!owner->result_ok);
10396         return SignOrCreationError_clone(&*owner->contents.err);
10397 }
10398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10399         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10400         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10401         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10402         int64_t ret_ref = tag_ptr(ret_copy, true);
10403         return ret_ref;
10404 }
10405
10406 typedef struct LDKFilter_JCalls {
10407         atomic_size_t refcnt;
10408         JavaVM *vm;
10409         jweak o;
10410         jmethodID register_tx_meth;
10411         jmethodID register_output_meth;
10412 } LDKFilter_JCalls;
10413 static void LDKFilter_JCalls_free(void* this_arg) {
10414         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10415         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10416                 JNIEnv *env;
10417                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10418                 if (get_jenv_res == JNI_EDETACHED) {
10419                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10420                 } else {
10421                         DO_ASSERT(get_jenv_res == JNI_OK);
10422                 }
10423                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10424                 if (get_jenv_res == JNI_EDETACHED) {
10425                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10426                 }
10427                 FREE(j_calls);
10428         }
10429 }
10430 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10431         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10432         JNIEnv *env;
10433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10434         if (get_jenv_res == JNI_EDETACHED) {
10435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10436         } else {
10437                 DO_ASSERT(get_jenv_res == JNI_OK);
10438         }
10439         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10440         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10441         LDKu8slice script_pubkey_var = script_pubkey;
10442         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10443         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10444         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10445         CHECK(obj != NULL);
10446         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10447         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10448                 (*env)->ExceptionDescribe(env);
10449                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10450         }
10451         if (get_jenv_res == JNI_EDETACHED) {
10452                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10453         }
10454 }
10455 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10456         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10457         JNIEnv *env;
10458         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10459         if (get_jenv_res == JNI_EDETACHED) {
10460                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10461         } else {
10462                 DO_ASSERT(get_jenv_res == JNI_OK);
10463         }
10464         LDKWatchedOutput output_var = output;
10465         int64_t output_ref = 0;
10466         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10467         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
10468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10469         CHECK(obj != NULL);
10470         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
10471         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10472                 (*env)->ExceptionDescribe(env);
10473                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10474         }
10475         if (get_jenv_res == JNI_EDETACHED) {
10476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10477         }
10478 }
10479 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10480         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10481         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10482 }
10483 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10484         jclass c = (*env)->GetObjectClass(env, o);
10485         CHECK(c != NULL);
10486         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10487         atomic_init(&calls->refcnt, 1);
10488         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10489         calls->o = (*env)->NewWeakGlobalRef(env, o);
10490         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10491         CHECK(calls->register_tx_meth != NULL);
10492         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
10493         CHECK(calls->register_output_meth != NULL);
10494
10495         LDKFilter ret = {
10496                 .this_arg = (void*) calls,
10497                 .register_tx = register_tx_LDKFilter_jcall,
10498                 .register_output = register_output_LDKFilter_jcall,
10499                 .free = LDKFilter_JCalls_free,
10500         };
10501         return ret;
10502 }
10503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10504         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10505         *res_ptr = LDKFilter_init(env, clz, o);
10506         return tag_ptr(res_ptr, true);
10507 }
10508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
10509         void* this_arg_ptr = untag_ptr(this_arg);
10510         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10511         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10512         unsigned char txid_arr[32];
10513         CHECK((*env)->GetArrayLength(env, txid) == 32);
10514         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10515         unsigned char (*txid_ref)[32] = &txid_arr;
10516         LDKu8slice script_pubkey_ref;
10517         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10518         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10519         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10520         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10521 }
10522
10523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10524         void* this_arg_ptr = untag_ptr(this_arg);
10525         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10526         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10527         LDKWatchedOutput output_conv;
10528         output_conv.inner = untag_ptr(output);
10529         output_conv.is_owned = ptr_is_owned(output);
10530         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10531         output_conv = WatchedOutput_clone(&output_conv);
10532         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10533 }
10534
10535 static jclass LDKCOption_FilterZ_Some_class = NULL;
10536 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10537 static jclass LDKCOption_FilterZ_None_class = NULL;
10538 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10540         LDKCOption_FilterZ_Some_class =
10541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10542         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10543         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10544         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10545         LDKCOption_FilterZ_None_class =
10546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10547         CHECK(LDKCOption_FilterZ_None_class != NULL);
10548         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10549         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10550 }
10551 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10552         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
10553         switch(obj->tag) {
10554                 case LDKCOption_FilterZ_Some: {
10555                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10556                         *some_ret = obj->some;
10557                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10558                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10559                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10560                                 LDKFilter_JCalls_cloned(&(*some_ret));
10561                         }
10562                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
10563                 }
10564                 case LDKCOption_FilterZ_None: {
10565                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10566                 }
10567                 default: abort();
10568         }
10569 }
10570 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10571         LDKLockedChannelMonitor ret = *owner->contents.result;
10572         ret.is_owned = false;
10573         return ret;
10574 }
10575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10576         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10577         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10578         int64_t ret_ref = 0;
10579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10580         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10581         return ret_ref;
10582 }
10583
10584 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10585 CHECK(!owner->result_ok);
10586         return *owner->contents.err;
10587 }
10588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10589         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10590         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10591 }
10592
10593 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10594         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10595         for (size_t i = 0; i < ret.datalen; i++) {
10596                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10597         }
10598         return ret;
10599 }
10600 typedef struct LDKMessageSendEventsProvider_JCalls {
10601         atomic_size_t refcnt;
10602         JavaVM *vm;
10603         jweak o;
10604         jmethodID get_and_clear_pending_msg_events_meth;
10605 } LDKMessageSendEventsProvider_JCalls;
10606 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10607         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10608         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10609                 JNIEnv *env;
10610                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10611                 if (get_jenv_res == JNI_EDETACHED) {
10612                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10613                 } else {
10614                         DO_ASSERT(get_jenv_res == JNI_OK);
10615                 }
10616                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10617                 if (get_jenv_res == JNI_EDETACHED) {
10618                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10619                 }
10620                 FREE(j_calls);
10621         }
10622 }
10623 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10624         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10625         JNIEnv *env;
10626         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10627         if (get_jenv_res == JNI_EDETACHED) {
10628                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10629         } else {
10630                 DO_ASSERT(get_jenv_res == JNI_OK);
10631         }
10632         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10633         CHECK(obj != NULL);
10634         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10635         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10636                 (*env)->ExceptionDescribe(env);
10637                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10638         }
10639         LDKCVec_MessageSendEventZ ret_constr;
10640         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10641         if (ret_constr.datalen > 0)
10642                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10643         else
10644                 ret_constr.data = NULL;
10645         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10646         for (size_t s = 0; s < ret_constr.datalen; s++) {
10647                 int64_t ret_conv_18 = ret_vals[s];
10648                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
10649                 CHECK_ACCESS(ret_conv_18_ptr);
10650                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10651                 FREE(untag_ptr(ret_conv_18));
10652                 ret_constr.data[s] = ret_conv_18_conv;
10653         }
10654         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10655         if (get_jenv_res == JNI_EDETACHED) {
10656                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10657         }
10658         return ret_constr;
10659 }
10660 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10661         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10662         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10663 }
10664 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10665         jclass c = (*env)->GetObjectClass(env, o);
10666         CHECK(c != NULL);
10667         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10668         atomic_init(&calls->refcnt, 1);
10669         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10670         calls->o = (*env)->NewWeakGlobalRef(env, o);
10671         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10672         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10673
10674         LDKMessageSendEventsProvider ret = {
10675                 .this_arg = (void*) calls,
10676                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10677                 .free = LDKMessageSendEventsProvider_JCalls_free,
10678         };
10679         return ret;
10680 }
10681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10682         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10683         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10684         return tag_ptr(res_ptr, true);
10685 }
10686 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10687         void* this_arg_ptr = untag_ptr(this_arg);
10688         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10689         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10690         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10691         int64_tArray ret_arr = NULL;
10692         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10693         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10694         for (size_t s = 0; s < ret_var.datalen; s++) {
10695                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10696                 *ret_conv_18_copy = ret_var.data[s];
10697                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
10698                 ret_arr_ptr[s] = ret_conv_18_ref;
10699         }
10700         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10701         FREE(ret_var.data);
10702         return ret_arr;
10703 }
10704
10705 typedef struct LDKOnionMessageProvider_JCalls {
10706         atomic_size_t refcnt;
10707         JavaVM *vm;
10708         jweak o;
10709         jmethodID next_onion_message_for_peer_meth;
10710 } LDKOnionMessageProvider_JCalls;
10711 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
10712         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10713         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10714                 JNIEnv *env;
10715                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10716                 if (get_jenv_res == JNI_EDETACHED) {
10717                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10718                 } else {
10719                         DO_ASSERT(get_jenv_res == JNI_OK);
10720                 }
10721                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10722                 if (get_jenv_res == JNI_EDETACHED) {
10723                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10724                 }
10725                 FREE(j_calls);
10726         }
10727 }
10728 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
10729         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10730         JNIEnv *env;
10731         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10732         if (get_jenv_res == JNI_EDETACHED) {
10733                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10734         } else {
10735                 DO_ASSERT(get_jenv_res == JNI_OK);
10736         }
10737         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
10738         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
10739         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10740         CHECK(obj != NULL);
10741         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
10742         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10743                 (*env)->ExceptionDescribe(env);
10744                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
10745         }
10746         LDKOnionMessage ret_conv;
10747         ret_conv.inner = untag_ptr(ret);
10748         ret_conv.is_owned = ptr_is_owned(ret);
10749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
10750         if (get_jenv_res == JNI_EDETACHED) {
10751                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10752         }
10753         return ret_conv;
10754 }
10755 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
10756         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
10757         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10758 }
10759 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
10760         jclass c = (*env)->GetObjectClass(env, o);
10761         CHECK(c != NULL);
10762         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
10763         atomic_init(&calls->refcnt, 1);
10764         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10765         calls->o = (*env)->NewWeakGlobalRef(env, o);
10766         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
10767         CHECK(calls->next_onion_message_for_peer_meth != NULL);
10768
10769         LDKOnionMessageProvider ret = {
10770                 .this_arg = (void*) calls,
10771                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
10772                 .free = LDKOnionMessageProvider_JCalls_free,
10773         };
10774         return ret;
10775 }
10776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10777         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
10778         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
10779         return tag_ptr(res_ptr, true);
10780 }
10781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1next_1onion_1message_1for_1peer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id) {
10782         void* this_arg_ptr = untag_ptr(this_arg);
10783         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10784         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
10785         LDKPublicKey peer_node_id_ref;
10786         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
10787         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
10788         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
10789         int64_t ret_ref = 0;
10790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10792         return ret_ref;
10793 }
10794
10795 typedef struct LDKEventHandler_JCalls {
10796         atomic_size_t refcnt;
10797         JavaVM *vm;
10798         jweak o;
10799         jmethodID handle_event_meth;
10800 } LDKEventHandler_JCalls;
10801 static void LDKEventHandler_JCalls_free(void* this_arg) {
10802         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10803         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10804                 JNIEnv *env;
10805                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10806                 if (get_jenv_res == JNI_EDETACHED) {
10807                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10808                 } else {
10809                         DO_ASSERT(get_jenv_res == JNI_OK);
10810                 }
10811                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10812                 if (get_jenv_res == JNI_EDETACHED) {
10813                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10814                 }
10815                 FREE(j_calls);
10816         }
10817 }
10818 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10819         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10820         JNIEnv *env;
10821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10822         if (get_jenv_res == JNI_EDETACHED) {
10823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10824         } else {
10825                 DO_ASSERT(get_jenv_res == JNI_OK);
10826         }
10827         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10828         *ret_event = Event_clone(event);
10829         int64_t ref_event = tag_ptr(ret_event, true);
10830         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10831         CHECK(obj != NULL);
10832         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, ref_event);
10833         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10834                 (*env)->ExceptionDescribe(env);
10835                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10836         }
10837         if (get_jenv_res == JNI_EDETACHED) {
10838                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10839         }
10840 }
10841 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10842         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10843         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10844 }
10845 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10846         jclass c = (*env)->GetObjectClass(env, o);
10847         CHECK(c != NULL);
10848         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10849         atomic_init(&calls->refcnt, 1);
10850         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10851         calls->o = (*env)->NewWeakGlobalRef(env, o);
10852         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10853         CHECK(calls->handle_event_meth != NULL);
10854
10855         LDKEventHandler ret = {
10856                 .this_arg = (void*) calls,
10857                 .handle_event = handle_event_LDKEventHandler_jcall,
10858                 .free = LDKEventHandler_JCalls_free,
10859         };
10860         return ret;
10861 }
10862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10863         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10864         *res_ptr = LDKEventHandler_init(env, clz, o);
10865         return tag_ptr(res_ptr, true);
10866 }
10867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10868         void* this_arg_ptr = untag_ptr(this_arg);
10869         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10870         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10871         LDKEvent* event_conv = (LDKEvent*)untag_ptr(event);
10872         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10873 }
10874
10875 typedef struct LDKEventsProvider_JCalls {
10876         atomic_size_t refcnt;
10877         JavaVM *vm;
10878         jweak o;
10879         jmethodID process_pending_events_meth;
10880 } LDKEventsProvider_JCalls;
10881 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10882         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10883         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10884                 JNIEnv *env;
10885                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10886                 if (get_jenv_res == JNI_EDETACHED) {
10887                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10888                 } else {
10889                         DO_ASSERT(get_jenv_res == JNI_OK);
10890                 }
10891                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10892                 if (get_jenv_res == JNI_EDETACHED) {
10893                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10894                 }
10895                 FREE(j_calls);
10896         }
10897 }
10898 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10899         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10900         JNIEnv *env;
10901         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10902         if (get_jenv_res == JNI_EDETACHED) {
10903                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10904         } else {
10905                 DO_ASSERT(get_jenv_res == JNI_OK);
10906         }
10907         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10908         *handler_ret = handler;
10909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10910         CHECK(obj != NULL);
10911         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
10912         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10913                 (*env)->ExceptionDescribe(env);
10914                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10915         }
10916         if (get_jenv_res == JNI_EDETACHED) {
10917                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10918         }
10919 }
10920 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10921         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10922         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10923 }
10924 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10925         jclass c = (*env)->GetObjectClass(env, o);
10926         CHECK(c != NULL);
10927         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10928         atomic_init(&calls->refcnt, 1);
10929         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10930         calls->o = (*env)->NewWeakGlobalRef(env, o);
10931         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10932         CHECK(calls->process_pending_events_meth != NULL);
10933
10934         LDKEventsProvider ret = {
10935                 .this_arg = (void*) calls,
10936                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10937                 .free = LDKEventsProvider_JCalls_free,
10938         };
10939         return ret;
10940 }
10941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10942         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10943         *res_ptr = LDKEventsProvider_init(env, clz, o);
10944         return tag_ptr(res_ptr, true);
10945 }
10946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10947         void* this_arg_ptr = untag_ptr(this_arg);
10948         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10949         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10950         void* handler_ptr = untag_ptr(handler);
10951         CHECK_ACCESS(handler_ptr);
10952         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10953         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10955                 LDKEventHandler_JCalls_cloned(&handler_conv);
10956         }
10957         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10958 }
10959
10960 typedef struct LDKPersister_JCalls {
10961         atomic_size_t refcnt;
10962         JavaVM *vm;
10963         jweak o;
10964         jmethodID persist_manager_meth;
10965         jmethodID persist_graph_meth;
10966         jmethodID persist_scorer_meth;
10967 } LDKPersister_JCalls;
10968 static void LDKPersister_JCalls_free(void* this_arg) {
10969         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10970         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10971                 JNIEnv *env;
10972                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10973                 if (get_jenv_res == JNI_EDETACHED) {
10974                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10975                 } else {
10976                         DO_ASSERT(get_jenv_res == JNI_OK);
10977                 }
10978                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10979                 if (get_jenv_res == JNI_EDETACHED) {
10980                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10981                 }
10982                 FREE(j_calls);
10983         }
10984 }
10985 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10986         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10987         JNIEnv *env;
10988         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10989         if (get_jenv_res == JNI_EDETACHED) {
10990                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10991         } else {
10992                 DO_ASSERT(get_jenv_res == JNI_OK);
10993         }
10994         LDKChannelManager channel_manager_var = *channel_manager;
10995         int64_t channel_manager_ref = 0;
10996         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10997         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10998         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
10999         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11000         CHECK(obj != NULL);
11001         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11002         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11003                 (*env)->ExceptionDescribe(env);
11004                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11005         }
11006         void* ret_ptr = untag_ptr(ret);
11007         CHECK_ACCESS(ret_ptr);
11008         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11009         FREE(untag_ptr(ret));
11010         if (get_jenv_res == JNI_EDETACHED) {
11011                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11012         }
11013         return ret_conv;
11014 }
11015 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11016         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11017         JNIEnv *env;
11018         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11019         if (get_jenv_res == JNI_EDETACHED) {
11020                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11021         } else {
11022                 DO_ASSERT(get_jenv_res == JNI_OK);
11023         }
11024         LDKNetworkGraph network_graph_var = *network_graph;
11025         int64_t network_graph_ref = 0;
11026         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11027         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11028         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
11029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11030         CHECK(obj != NULL);
11031         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11032         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11033                 (*env)->ExceptionDescribe(env);
11034                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11035         }
11036         void* ret_ptr = untag_ptr(ret);
11037         CHECK_ACCESS(ret_ptr);
11038         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11039         FREE(untag_ptr(ret));
11040         if (get_jenv_res == JNI_EDETACHED) {
11041                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11042         }
11043         return ret_conv;
11044 }
11045 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
11046         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11047         JNIEnv *env;
11048         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11049         if (get_jenv_res == JNI_EDETACHED) {
11050                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11051         } else {
11052                 DO_ASSERT(get_jenv_res == JNI_OK);
11053         }
11054         // WARNING: This object doesn't live past this scope, needs clone!
11055         int64_t ret_scorer = tag_ptr(scorer, false);
11056         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11057         CHECK(obj != NULL);
11058         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
11059         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11060                 (*env)->ExceptionDescribe(env);
11061                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11062         }
11063         void* ret_ptr = untag_ptr(ret);
11064         CHECK_ACCESS(ret_ptr);
11065         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11066         FREE(untag_ptr(ret));
11067         if (get_jenv_res == JNI_EDETACHED) {
11068                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11069         }
11070         return ret_conv;
11071 }
11072 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11073         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11074         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11075 }
11076 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11077         jclass c = (*env)->GetObjectClass(env, o);
11078         CHECK(c != NULL);
11079         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11080         atomic_init(&calls->refcnt, 1);
11081         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11082         calls->o = (*env)->NewWeakGlobalRef(env, o);
11083         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11084         CHECK(calls->persist_manager_meth != NULL);
11085         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11086         CHECK(calls->persist_graph_meth != NULL);
11087         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11088         CHECK(calls->persist_scorer_meth != NULL);
11089
11090         LDKPersister ret = {
11091                 .this_arg = (void*) calls,
11092                 .persist_manager = persist_manager_LDKPersister_jcall,
11093                 .persist_graph = persist_graph_LDKPersister_jcall,
11094                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11095                 .free = LDKPersister_JCalls_free,
11096         };
11097         return ret;
11098 }
11099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11100         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11101         *res_ptr = LDKPersister_init(env, clz, o);
11102         return tag_ptr(res_ptr, true);
11103 }
11104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11105         void* this_arg_ptr = untag_ptr(this_arg);
11106         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11107         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11108         LDKChannelManager channel_manager_conv;
11109         channel_manager_conv.inner = untag_ptr(channel_manager);
11110         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
11111         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11112         channel_manager_conv.is_owned = false;
11113         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11114         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11115         return tag_ptr(ret_conv, true);
11116 }
11117
11118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11119         void* this_arg_ptr = untag_ptr(this_arg);
11120         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11121         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11122         LDKNetworkGraph network_graph_conv;
11123         network_graph_conv.inner = untag_ptr(network_graph);
11124         network_graph_conv.is_owned = ptr_is_owned(network_graph);
11125         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11126         network_graph_conv.is_owned = false;
11127         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11128         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11129         return tag_ptr(ret_conv, true);
11130 }
11131
11132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11133         void* this_arg_ptr = untag_ptr(this_arg);
11134         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11135         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11136         void* scorer_ptr = untag_ptr(scorer);
11137         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
11138         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
11139         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11140         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
11141         return tag_ptr(ret_conv, true);
11142 }
11143
11144 typedef struct LDKFutureCallback_JCalls {
11145         atomic_size_t refcnt;
11146         JavaVM *vm;
11147         jweak o;
11148         jmethodID call_meth;
11149 } LDKFutureCallback_JCalls;
11150 static void LDKFutureCallback_JCalls_free(void* this_arg) {
11151         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11152         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11153                 JNIEnv *env;
11154                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11155                 if (get_jenv_res == JNI_EDETACHED) {
11156                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11157                 } else {
11158                         DO_ASSERT(get_jenv_res == JNI_OK);
11159                 }
11160                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11161                 if (get_jenv_res == JNI_EDETACHED) {
11162                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11163                 }
11164                 FREE(j_calls);
11165         }
11166 }
11167 void call_LDKFutureCallback_jcall(const void* this_arg) {
11168         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11169         JNIEnv *env;
11170         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11171         if (get_jenv_res == JNI_EDETACHED) {
11172                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11173         } else {
11174                 DO_ASSERT(get_jenv_res == JNI_OK);
11175         }
11176         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11177         CHECK(obj != NULL);
11178         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
11179         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11180                 (*env)->ExceptionDescribe(env);
11181                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
11182         }
11183         if (get_jenv_res == JNI_EDETACHED) {
11184                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11185         }
11186 }
11187 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
11188         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
11189         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11190 }
11191 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
11192         jclass c = (*env)->GetObjectClass(env, o);
11193         CHECK(c != NULL);
11194         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
11195         atomic_init(&calls->refcnt, 1);
11196         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11197         calls->o = (*env)->NewWeakGlobalRef(env, o);
11198         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
11199         CHECK(calls->call_meth != NULL);
11200
11201         LDKFutureCallback ret = {
11202                 .this_arg = (void*) calls,
11203                 .call = call_LDKFutureCallback_jcall,
11204                 .free = LDKFutureCallback_JCalls_free,
11205         };
11206         return ret;
11207 }
11208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
11209         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
11210         *res_ptr = LDKFutureCallback_init(env, clz, o);
11211         return tag_ptr(res_ptr, true);
11212 }
11213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
11214         void* this_arg_ptr = untag_ptr(this_arg);
11215         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11216         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
11217         (this_arg_conv->call)(this_arg_conv->this_arg);
11218 }
11219
11220 typedef struct LDKListen_JCalls {
11221         atomic_size_t refcnt;
11222         JavaVM *vm;
11223         jweak o;
11224         jmethodID filtered_block_connected_meth;
11225         jmethodID block_connected_meth;
11226         jmethodID block_disconnected_meth;
11227 } LDKListen_JCalls;
11228 static void LDKListen_JCalls_free(void* this_arg) {
11229         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11230         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11231                 JNIEnv *env;
11232                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11233                 if (get_jenv_res == JNI_EDETACHED) {
11234                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11235                 } else {
11236                         DO_ASSERT(get_jenv_res == JNI_OK);
11237                 }
11238                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11239                 if (get_jenv_res == JNI_EDETACHED) {
11240                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11241                 }
11242                 FREE(j_calls);
11243         }
11244 }
11245 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11246         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11247         JNIEnv *env;
11248         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11249         if (get_jenv_res == JNI_EDETACHED) {
11250                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11251         } else {
11252                 DO_ASSERT(get_jenv_res == JNI_OK);
11253         }
11254         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11255         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11256         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11257         int64_tArray txdata_arr = NULL;
11258         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11259         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11260         for (size_t c = 0; c < txdata_var.datalen; c++) {
11261                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11262                 *txdata_conv_28_conv = txdata_var.data[c];
11263                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11264         }
11265         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11266         FREE(txdata_var.data);
11267         int32_t height_conv = height;
11268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11269         CHECK(obj != NULL);
11270         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11271         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11272                 (*env)->ExceptionDescribe(env);
11273                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11274         }
11275         if (get_jenv_res == JNI_EDETACHED) {
11276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11277         }
11278 }
11279 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11280         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11281         JNIEnv *env;
11282         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11283         if (get_jenv_res == JNI_EDETACHED) {
11284                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11285         } else {
11286                 DO_ASSERT(get_jenv_res == JNI_OK);
11287         }
11288         LDKu8slice block_var = block;
11289         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11290         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11291         int32_t height_conv = height;
11292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11293         CHECK(obj != NULL);
11294         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11296                 (*env)->ExceptionDescribe(env);
11297                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11298         }
11299         if (get_jenv_res == JNI_EDETACHED) {
11300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11301         }
11302 }
11303 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11304         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11305         JNIEnv *env;
11306         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11307         if (get_jenv_res == JNI_EDETACHED) {
11308                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11309         } else {
11310                 DO_ASSERT(get_jenv_res == JNI_OK);
11311         }
11312         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11313         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11314         int32_t height_conv = height;
11315         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11316         CHECK(obj != NULL);
11317         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11318         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11319                 (*env)->ExceptionDescribe(env);
11320                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11321         }
11322         if (get_jenv_res == JNI_EDETACHED) {
11323                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11324         }
11325 }
11326 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11327         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11328         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11329 }
11330 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11331         jclass c = (*env)->GetObjectClass(env, o);
11332         CHECK(c != NULL);
11333         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11334         atomic_init(&calls->refcnt, 1);
11335         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11336         calls->o = (*env)->NewWeakGlobalRef(env, o);
11337         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11338         CHECK(calls->filtered_block_connected_meth != NULL);
11339         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11340         CHECK(calls->block_connected_meth != NULL);
11341         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11342         CHECK(calls->block_disconnected_meth != NULL);
11343
11344         LDKListen ret = {
11345                 .this_arg = (void*) calls,
11346                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11347                 .block_connected = block_connected_LDKListen_jcall,
11348                 .block_disconnected = block_disconnected_LDKListen_jcall,
11349                 .free = LDKListen_JCalls_free,
11350         };
11351         return ret;
11352 }
11353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11354         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11355         *res_ptr = LDKListen_init(env, clz, o);
11356         return tag_ptr(res_ptr, true);
11357 }
11358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11359         void* this_arg_ptr = untag_ptr(this_arg);
11360         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11361         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11362         unsigned char header_arr[80];
11363         CHECK((*env)->GetArrayLength(env, header) == 80);
11364         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11365         unsigned char (*header_ref)[80] = &header_arr;
11366         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11367         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11368         if (txdata_constr.datalen > 0)
11369                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11370         else
11371                 txdata_constr.data = NULL;
11372         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11373         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11374                 int64_t txdata_conv_28 = txdata_vals[c];
11375                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11376                 CHECK_ACCESS(txdata_conv_28_ptr);
11377                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11378                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11379                 txdata_constr.data[c] = txdata_conv_28_conv;
11380         }
11381         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11382         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11383 }
11384
11385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
11386         void* this_arg_ptr = untag_ptr(this_arg);
11387         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11388         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11389         LDKu8slice block_ref;
11390         block_ref.datalen = (*env)->GetArrayLength(env, block);
11391         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11392         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11393         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11394 }
11395
11396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
11397         void* this_arg_ptr = untag_ptr(this_arg);
11398         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11399         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11400         unsigned char header_arr[80];
11401         CHECK((*env)->GetArrayLength(env, header) == 80);
11402         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11403         unsigned char (*header_ref)[80] = &header_arr;
11404         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11405 }
11406
11407 typedef struct LDKConfirm_JCalls {
11408         atomic_size_t refcnt;
11409         JavaVM *vm;
11410         jweak o;
11411         jmethodID transactions_confirmed_meth;
11412         jmethodID transaction_unconfirmed_meth;
11413         jmethodID best_block_updated_meth;
11414         jmethodID get_relevant_txids_meth;
11415 } LDKConfirm_JCalls;
11416 static void LDKConfirm_JCalls_free(void* this_arg) {
11417         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11418         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11419                 JNIEnv *env;
11420                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11421                 if (get_jenv_res == JNI_EDETACHED) {
11422                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11423                 } else {
11424                         DO_ASSERT(get_jenv_res == JNI_OK);
11425                 }
11426                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11427                 if (get_jenv_res == JNI_EDETACHED) {
11428                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11429                 }
11430                 FREE(j_calls);
11431         }
11432 }
11433 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11434         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11435         JNIEnv *env;
11436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11437         if (get_jenv_res == JNI_EDETACHED) {
11438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11439         } else {
11440                 DO_ASSERT(get_jenv_res == JNI_OK);
11441         }
11442         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11443         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11444         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11445         int64_tArray txdata_arr = NULL;
11446         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11447         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11448         for (size_t c = 0; c < txdata_var.datalen; c++) {
11449                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11450                 *txdata_conv_28_conv = txdata_var.data[c];
11451                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11452         }
11453         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11454         FREE(txdata_var.data);
11455         int32_t height_conv = height;
11456         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11457         CHECK(obj != NULL);
11458         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11459         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11460                 (*env)->ExceptionDescribe(env);
11461                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11462         }
11463         if (get_jenv_res == JNI_EDETACHED) {
11464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11465         }
11466 }
11467 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11468         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11469         JNIEnv *env;
11470         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11471         if (get_jenv_res == JNI_EDETACHED) {
11472                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11473         } else {
11474                 DO_ASSERT(get_jenv_res == JNI_OK);
11475         }
11476         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11477         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11478         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11479         CHECK(obj != NULL);
11480         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11481         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11482                 (*env)->ExceptionDescribe(env);
11483                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11484         }
11485         if (get_jenv_res == JNI_EDETACHED) {
11486                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11487         }
11488 }
11489 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11490         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11491         JNIEnv *env;
11492         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11493         if (get_jenv_res == JNI_EDETACHED) {
11494                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11495         } else {
11496                 DO_ASSERT(get_jenv_res == JNI_OK);
11497         }
11498         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11499         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11500         int32_t height_conv = height;
11501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11502         CHECK(obj != NULL);
11503         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11504         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11505                 (*env)->ExceptionDescribe(env);
11506                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11507         }
11508         if (get_jenv_res == JNI_EDETACHED) {
11509                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11510         }
11511 }
11512 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11513         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11514         JNIEnv *env;
11515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11516         if (get_jenv_res == JNI_EDETACHED) {
11517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11518         } else {
11519                 DO_ASSERT(get_jenv_res == JNI_OK);
11520         }
11521         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11522         CHECK(obj != NULL);
11523         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11524         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11525                 (*env)->ExceptionDescribe(env);
11526                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11527         }
11528         LDKCVec_TxidZ ret_constr;
11529         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11530         if (ret_constr.datalen > 0)
11531                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11532         else
11533                 ret_constr.data = NULL;
11534         for (size_t i = 0; i < ret_constr.datalen; i++) {
11535                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11536                 LDKThirtyTwoBytes ret_conv_8_ref;
11537                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11538                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11539                 ret_constr.data[i] = ret_conv_8_ref;
11540         }
11541         if (get_jenv_res == JNI_EDETACHED) {
11542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11543         }
11544         return ret_constr;
11545 }
11546 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11547         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11548         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11549 }
11550 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11551         jclass c = (*env)->GetObjectClass(env, o);
11552         CHECK(c != NULL);
11553         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11554         atomic_init(&calls->refcnt, 1);
11555         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11556         calls->o = (*env)->NewWeakGlobalRef(env, o);
11557         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11558         CHECK(calls->transactions_confirmed_meth != NULL);
11559         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11560         CHECK(calls->transaction_unconfirmed_meth != NULL);
11561         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11562         CHECK(calls->best_block_updated_meth != NULL);
11563         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11564         CHECK(calls->get_relevant_txids_meth != NULL);
11565
11566         LDKConfirm ret = {
11567                 .this_arg = (void*) calls,
11568                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11569                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11570                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11571                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11572                 .free = LDKConfirm_JCalls_free,
11573         };
11574         return ret;
11575 }
11576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11577         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11578         *res_ptr = LDKConfirm_init(env, clz, o);
11579         return tag_ptr(res_ptr, true);
11580 }
11581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11582         void* this_arg_ptr = untag_ptr(this_arg);
11583         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11584         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11585         unsigned char header_arr[80];
11586         CHECK((*env)->GetArrayLength(env, header) == 80);
11587         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11588         unsigned char (*header_ref)[80] = &header_arr;
11589         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11590         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11591         if (txdata_constr.datalen > 0)
11592                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11593         else
11594                 txdata_constr.data = NULL;
11595         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11596         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11597                 int64_t txdata_conv_28 = txdata_vals[c];
11598                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11599                 CHECK_ACCESS(txdata_conv_28_ptr);
11600                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11601                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11602                 txdata_constr.data[c] = txdata_conv_28_conv;
11603         }
11604         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11605         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11606 }
11607
11608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11609         void* this_arg_ptr = untag_ptr(this_arg);
11610         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11611         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11612         unsigned char txid_arr[32];
11613         CHECK((*env)->GetArrayLength(env, txid) == 32);
11614         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11615         unsigned char (*txid_ref)[32] = &txid_arr;
11616         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11617 }
11618
11619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
11620         void* this_arg_ptr = untag_ptr(this_arg);
11621         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11622         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11623         unsigned char header_arr[80];
11624         CHECK((*env)->GetArrayLength(env, header) == 80);
11625         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11626         unsigned char (*header_ref)[80] = &header_arr;
11627         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11628 }
11629
11630 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11631         void* this_arg_ptr = untag_ptr(this_arg);
11632         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11633         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11634         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11635         jobjectArray ret_arr = NULL;
11636         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11637         ;
11638         for (size_t i = 0; i < ret_var.datalen; i++) {
11639                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11640                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11641                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11642         }
11643         
11644         FREE(ret_var.data);
11645         return ret_arr;
11646 }
11647
11648 typedef struct LDKPersist_JCalls {
11649         atomic_size_t refcnt;
11650         JavaVM *vm;
11651         jweak o;
11652         jmethodID persist_new_channel_meth;
11653         jmethodID update_persisted_channel_meth;
11654 } LDKPersist_JCalls;
11655 static void LDKPersist_JCalls_free(void* this_arg) {
11656         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11657         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11658                 JNIEnv *env;
11659                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11660                 if (get_jenv_res == JNI_EDETACHED) {
11661                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11662                 } else {
11663                         DO_ASSERT(get_jenv_res == JNI_OK);
11664                 }
11665                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11666                 if (get_jenv_res == JNI_EDETACHED) {
11667                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11668                 }
11669                 FREE(j_calls);
11670         }
11671 }
11672 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11673         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11674         JNIEnv *env;
11675         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11676         if (get_jenv_res == JNI_EDETACHED) {
11677                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11678         } else {
11679                 DO_ASSERT(get_jenv_res == JNI_OK);
11680         }
11681         LDKOutPoint channel_id_var = channel_id;
11682         int64_t channel_id_ref = 0;
11683         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11684         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11685         LDKChannelMonitor data_var = *data;
11686         int64_t data_ref = 0;
11687         data_var = ChannelMonitor_clone(&data_var);
11688         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11689         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11690         LDKMonitorUpdateId update_id_var = update_id;
11691         int64_t update_id_ref = 0;
11692         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11693         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11694         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11695         CHECK(obj != NULL);
11696         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11697         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11698                 (*env)->ExceptionDescribe(env);
11699                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11700         }
11701         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11702         if (get_jenv_res == JNI_EDETACHED) {
11703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11704         }
11705         return ret_conv;
11706 }
11707 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11708         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11709         JNIEnv *env;
11710         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11711         if (get_jenv_res == JNI_EDETACHED) {
11712                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11713         } else {
11714                 DO_ASSERT(get_jenv_res == JNI_OK);
11715         }
11716         LDKOutPoint channel_id_var = channel_id;
11717         int64_t channel_id_ref = 0;
11718         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11719         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11720         LDKChannelMonitorUpdate update_var = *update;
11721         int64_t update_ref = 0;
11722         update_var = ChannelMonitorUpdate_clone(&update_var);
11723         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11724         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
11725         LDKChannelMonitor data_var = *data;
11726         int64_t data_ref = 0;
11727         data_var = ChannelMonitor_clone(&data_var);
11728         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11729         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11730         LDKMonitorUpdateId update_id_var = update_id;
11731         int64_t update_id_ref = 0;
11732         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11733         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11735         CHECK(obj != NULL);
11736         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11737         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11738                 (*env)->ExceptionDescribe(env);
11739                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11740         }
11741         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11742         if (get_jenv_res == JNI_EDETACHED) {
11743                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11744         }
11745         return ret_conv;
11746 }
11747 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11748         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11749         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11750 }
11751 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11752         jclass c = (*env)->GetObjectClass(env, o);
11753         CHECK(c != NULL);
11754         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11755         atomic_init(&calls->refcnt, 1);
11756         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11757         calls->o = (*env)->NewWeakGlobalRef(env, o);
11758         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
11759         CHECK(calls->persist_new_channel_meth != NULL);
11760         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
11761         CHECK(calls->update_persisted_channel_meth != NULL);
11762
11763         LDKPersist ret = {
11764                 .this_arg = (void*) calls,
11765                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11766                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11767                 .free = LDKPersist_JCalls_free,
11768         };
11769         return ret;
11770 }
11771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11772         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11773         *res_ptr = LDKPersist_init(env, clz, o);
11774         return tag_ptr(res_ptr, true);
11775 }
11776 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
11777         void* this_arg_ptr = untag_ptr(this_arg);
11778         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11779         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11780         LDKOutPoint channel_id_conv;
11781         channel_id_conv.inner = untag_ptr(channel_id);
11782         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11783         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11784         channel_id_conv = OutPoint_clone(&channel_id_conv);
11785         LDKChannelMonitor data_conv;
11786         data_conv.inner = untag_ptr(data);
11787         data_conv.is_owned = ptr_is_owned(data);
11788         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11789         data_conv.is_owned = false;
11790         LDKMonitorUpdateId update_id_conv;
11791         update_id_conv.inner = untag_ptr(update_id);
11792         update_id_conv.is_owned = ptr_is_owned(update_id);
11793         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11794         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11795         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv));
11796         return ret_conv;
11797 }
11798
11799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
11800         void* this_arg_ptr = untag_ptr(this_arg);
11801         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11802         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11803         LDKOutPoint channel_id_conv;
11804         channel_id_conv.inner = untag_ptr(channel_id);
11805         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11806         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11807         channel_id_conv = OutPoint_clone(&channel_id_conv);
11808         LDKChannelMonitorUpdate update_conv;
11809         update_conv.inner = untag_ptr(update);
11810         update_conv.is_owned = ptr_is_owned(update);
11811         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11812         update_conv.is_owned = false;
11813         LDKChannelMonitor data_conv;
11814         data_conv.inner = untag_ptr(data);
11815         data_conv.is_owned = ptr_is_owned(data);
11816         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11817         data_conv.is_owned = false;
11818         LDKMonitorUpdateId update_id_conv;
11819         update_id_conv.inner = untag_ptr(update_id);
11820         update_id_conv.is_owned = ptr_is_owned(update_id);
11821         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11822         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11823         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv));
11824         return ret_conv;
11825 }
11826
11827 typedef struct LDKChannelMessageHandler_JCalls {
11828         atomic_size_t refcnt;
11829         JavaVM *vm;
11830         jweak o;
11831         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11832         jmethodID handle_open_channel_meth;
11833         jmethodID handle_accept_channel_meth;
11834         jmethodID handle_funding_created_meth;
11835         jmethodID handle_funding_signed_meth;
11836         jmethodID handle_channel_ready_meth;
11837         jmethodID handle_shutdown_meth;
11838         jmethodID handle_closing_signed_meth;
11839         jmethodID handle_update_add_htlc_meth;
11840         jmethodID handle_update_fulfill_htlc_meth;
11841         jmethodID handle_update_fail_htlc_meth;
11842         jmethodID handle_update_fail_malformed_htlc_meth;
11843         jmethodID handle_commitment_signed_meth;
11844         jmethodID handle_revoke_and_ack_meth;
11845         jmethodID handle_update_fee_meth;
11846         jmethodID handle_announcement_signatures_meth;
11847         jmethodID peer_disconnected_meth;
11848         jmethodID peer_connected_meth;
11849         jmethodID handle_channel_reestablish_meth;
11850         jmethodID handle_channel_update_meth;
11851         jmethodID handle_error_meth;
11852         jmethodID provided_node_features_meth;
11853         jmethodID provided_init_features_meth;
11854 } LDKChannelMessageHandler_JCalls;
11855 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11856         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11857         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11858                 JNIEnv *env;
11859                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11860                 if (get_jenv_res == JNI_EDETACHED) {
11861                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11862                 } else {
11863                         DO_ASSERT(get_jenv_res == JNI_OK);
11864                 }
11865                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11866                 if (get_jenv_res == JNI_EDETACHED) {
11867                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11868                 }
11869                 FREE(j_calls);
11870         }
11871 }
11872 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11873         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11874         JNIEnv *env;
11875         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11876         if (get_jenv_res == JNI_EDETACHED) {
11877                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11878         } else {
11879                 DO_ASSERT(get_jenv_res == JNI_OK);
11880         }
11881         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11882         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11883         LDKInitFeatures their_features_var = their_features;
11884         int64_t their_features_ref = 0;
11885         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11886         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11887         LDKOpenChannel msg_var = *msg;
11888         int64_t msg_ref = 0;
11889         msg_var = OpenChannel_clone(&msg_var);
11890         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11891         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11893         CHECK(obj != NULL);
11894         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11895         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11896                 (*env)->ExceptionDescribe(env);
11897                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11898         }
11899         if (get_jenv_res == JNI_EDETACHED) {
11900                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11901         }
11902 }
11903 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11904         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11905         JNIEnv *env;
11906         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11907         if (get_jenv_res == JNI_EDETACHED) {
11908                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11909         } else {
11910                 DO_ASSERT(get_jenv_res == JNI_OK);
11911         }
11912         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11913         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11914         LDKInitFeatures their_features_var = their_features;
11915         int64_t their_features_ref = 0;
11916         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11917         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11918         LDKAcceptChannel msg_var = *msg;
11919         int64_t msg_ref = 0;
11920         msg_var = AcceptChannel_clone(&msg_var);
11921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11922         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11923         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11924         CHECK(obj != NULL);
11925         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11926         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11927                 (*env)->ExceptionDescribe(env);
11928                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11929         }
11930         if (get_jenv_res == JNI_EDETACHED) {
11931                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11932         }
11933 }
11934 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11935         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11936         JNIEnv *env;
11937         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11938         if (get_jenv_res == JNI_EDETACHED) {
11939                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11940         } else {
11941                 DO_ASSERT(get_jenv_res == JNI_OK);
11942         }
11943         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11944         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11945         LDKFundingCreated msg_var = *msg;
11946         int64_t msg_ref = 0;
11947         msg_var = FundingCreated_clone(&msg_var);
11948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11949         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11950         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11951         CHECK(obj != NULL);
11952         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11953         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11954                 (*env)->ExceptionDescribe(env);
11955                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11956         }
11957         if (get_jenv_res == JNI_EDETACHED) {
11958                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11959         }
11960 }
11961 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11962         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11963         JNIEnv *env;
11964         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11965         if (get_jenv_res == JNI_EDETACHED) {
11966                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11967         } else {
11968                 DO_ASSERT(get_jenv_res == JNI_OK);
11969         }
11970         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11971         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11972         LDKFundingSigned msg_var = *msg;
11973         int64_t msg_ref = 0;
11974         msg_var = FundingSigned_clone(&msg_var);
11975         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11976         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11978         CHECK(obj != NULL);
11979         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11980         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11981                 (*env)->ExceptionDescribe(env);
11982                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11983         }
11984         if (get_jenv_res == JNI_EDETACHED) {
11985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11986         }
11987 }
11988 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11989         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11990         JNIEnv *env;
11991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11992         if (get_jenv_res == JNI_EDETACHED) {
11993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11994         } else {
11995                 DO_ASSERT(get_jenv_res == JNI_OK);
11996         }
11997         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11998         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11999         LDKChannelReady msg_var = *msg;
12000         int64_t msg_ref = 0;
12001         msg_var = ChannelReady_clone(&msg_var);
12002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12003         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12005         CHECK(obj != NULL);
12006         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12008                 (*env)->ExceptionDescribe(env);
12009                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12010         }
12011         if (get_jenv_res == JNI_EDETACHED) {
12012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12013         }
12014 }
12015 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12016         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12017         JNIEnv *env;
12018         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12019         if (get_jenv_res == JNI_EDETACHED) {
12020                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12021         } else {
12022                 DO_ASSERT(get_jenv_res == JNI_OK);
12023         }
12024         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12025         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12026         LDKInitFeatures their_features_var = *their_features;
12027         int64_t their_features_ref = 0;
12028         their_features_var = InitFeatures_clone(&their_features_var);
12029         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12030         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12031         LDKShutdown msg_var = *msg;
12032         int64_t msg_ref = 0;
12033         msg_var = Shutdown_clone(&msg_var);
12034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12035         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12036         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12037         CHECK(obj != NULL);
12038         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12039         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12040                 (*env)->ExceptionDescribe(env);
12041                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12042         }
12043         if (get_jenv_res == JNI_EDETACHED) {
12044                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12045         }
12046 }
12047 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12048         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12049         JNIEnv *env;
12050         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12051         if (get_jenv_res == JNI_EDETACHED) {
12052                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12053         } else {
12054                 DO_ASSERT(get_jenv_res == JNI_OK);
12055         }
12056         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12057         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12058         LDKClosingSigned msg_var = *msg;
12059         int64_t msg_ref = 0;
12060         msg_var = ClosingSigned_clone(&msg_var);
12061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12062         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12063         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12064         CHECK(obj != NULL);
12065         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12066         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12067                 (*env)->ExceptionDescribe(env);
12068                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12069         }
12070         if (get_jenv_res == JNI_EDETACHED) {
12071                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12072         }
12073 }
12074 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12075         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12076         JNIEnv *env;
12077         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12078         if (get_jenv_res == JNI_EDETACHED) {
12079                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12080         } else {
12081                 DO_ASSERT(get_jenv_res == JNI_OK);
12082         }
12083         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12084         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12085         LDKUpdateAddHTLC msg_var = *msg;
12086         int64_t msg_ref = 0;
12087         msg_var = UpdateAddHTLC_clone(&msg_var);
12088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12089         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12090         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12091         CHECK(obj != NULL);
12092         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12093         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12094                 (*env)->ExceptionDescribe(env);
12095                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12096         }
12097         if (get_jenv_res == JNI_EDETACHED) {
12098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12099         }
12100 }
12101 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12102         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12103         JNIEnv *env;
12104         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12105         if (get_jenv_res == JNI_EDETACHED) {
12106                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12107         } else {
12108                 DO_ASSERT(get_jenv_res == JNI_OK);
12109         }
12110         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12111         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12112         LDKUpdateFulfillHTLC msg_var = *msg;
12113         int64_t msg_ref = 0;
12114         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12115         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12116         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12118         CHECK(obj != NULL);
12119         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12120         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12121                 (*env)->ExceptionDescribe(env);
12122                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12123         }
12124         if (get_jenv_res == JNI_EDETACHED) {
12125                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12126         }
12127 }
12128 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12129         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12130         JNIEnv *env;
12131         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12132         if (get_jenv_res == JNI_EDETACHED) {
12133                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12134         } else {
12135                 DO_ASSERT(get_jenv_res == JNI_OK);
12136         }
12137         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12138         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12139         LDKUpdateFailHTLC msg_var = *msg;
12140         int64_t msg_ref = 0;
12141         msg_var = UpdateFailHTLC_clone(&msg_var);
12142         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12143         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12144         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12145         CHECK(obj != NULL);
12146         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12147         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12148                 (*env)->ExceptionDescribe(env);
12149                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12150         }
12151         if (get_jenv_res == JNI_EDETACHED) {
12152                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12153         }
12154 }
12155 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12156         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12157         JNIEnv *env;
12158         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12159         if (get_jenv_res == JNI_EDETACHED) {
12160                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12161         } else {
12162                 DO_ASSERT(get_jenv_res == JNI_OK);
12163         }
12164         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12165         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12166         LDKUpdateFailMalformedHTLC msg_var = *msg;
12167         int64_t msg_ref = 0;
12168         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12169         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12170         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12171         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12172         CHECK(obj != NULL);
12173         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12174         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12175                 (*env)->ExceptionDescribe(env);
12176                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12177         }
12178         if (get_jenv_res == JNI_EDETACHED) {
12179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12180         }
12181 }
12182 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12183         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12184         JNIEnv *env;
12185         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12186         if (get_jenv_res == JNI_EDETACHED) {
12187                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12188         } else {
12189                 DO_ASSERT(get_jenv_res == JNI_OK);
12190         }
12191         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12192         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12193         LDKCommitmentSigned msg_var = *msg;
12194         int64_t msg_ref = 0;
12195         msg_var = CommitmentSigned_clone(&msg_var);
12196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12197         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12199         CHECK(obj != NULL);
12200         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12202                 (*env)->ExceptionDescribe(env);
12203                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12204         }
12205         if (get_jenv_res == JNI_EDETACHED) {
12206                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12207         }
12208 }
12209 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12210         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12211         JNIEnv *env;
12212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12213         if (get_jenv_res == JNI_EDETACHED) {
12214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12215         } else {
12216                 DO_ASSERT(get_jenv_res == JNI_OK);
12217         }
12218         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12219         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12220         LDKRevokeAndACK msg_var = *msg;
12221         int64_t msg_ref = 0;
12222         msg_var = RevokeAndACK_clone(&msg_var);
12223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12224         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12225         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12226         CHECK(obj != NULL);
12227         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12229                 (*env)->ExceptionDescribe(env);
12230                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12231         }
12232         if (get_jenv_res == JNI_EDETACHED) {
12233                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12234         }
12235 }
12236 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12237         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12238         JNIEnv *env;
12239         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12240         if (get_jenv_res == JNI_EDETACHED) {
12241                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12242         } else {
12243                 DO_ASSERT(get_jenv_res == JNI_OK);
12244         }
12245         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12246         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12247         LDKUpdateFee msg_var = *msg;
12248         int64_t msg_ref = 0;
12249         msg_var = UpdateFee_clone(&msg_var);
12250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12251         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12252         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12253         CHECK(obj != NULL);
12254         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12255         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12256                 (*env)->ExceptionDescribe(env);
12257                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12258         }
12259         if (get_jenv_res == JNI_EDETACHED) {
12260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12261         }
12262 }
12263 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12264         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12265         JNIEnv *env;
12266         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12267         if (get_jenv_res == JNI_EDETACHED) {
12268                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12269         } else {
12270                 DO_ASSERT(get_jenv_res == JNI_OK);
12271         }
12272         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12273         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12274         LDKAnnouncementSignatures msg_var = *msg;
12275         int64_t msg_ref = 0;
12276         msg_var = AnnouncementSignatures_clone(&msg_var);
12277         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12278         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12279         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12280         CHECK(obj != NULL);
12281         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12282         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12283                 (*env)->ExceptionDescribe(env);
12284                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12285         }
12286         if (get_jenv_res == JNI_EDETACHED) {
12287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12288         }
12289 }
12290 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12291         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12292         JNIEnv *env;
12293         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12294         if (get_jenv_res == JNI_EDETACHED) {
12295                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12296         } else {
12297                 DO_ASSERT(get_jenv_res == JNI_OK);
12298         }
12299         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12300         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12301         jboolean no_connection_possible_conv = no_connection_possible;
12302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12303         CHECK(obj != NULL);
12304         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12306                 (*env)->ExceptionDescribe(env);
12307                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12308         }
12309         if (get_jenv_res == JNI_EDETACHED) {
12310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12311         }
12312 }
12313 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12314         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12315         JNIEnv *env;
12316         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12317         if (get_jenv_res == JNI_EDETACHED) {
12318                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12319         } else {
12320                 DO_ASSERT(get_jenv_res == JNI_OK);
12321         }
12322         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12323         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12324         LDKInit msg_var = *msg;
12325         int64_t msg_ref = 0;
12326         msg_var = Init_clone(&msg_var);
12327         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12328         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12330         CHECK(obj != NULL);
12331         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12332         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12333                 (*env)->ExceptionDescribe(env);
12334                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12335         }
12336         void* ret_ptr = untag_ptr(ret);
12337         CHECK_ACCESS(ret_ptr);
12338         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
12339         FREE(untag_ptr(ret));
12340         if (get_jenv_res == JNI_EDETACHED) {
12341                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12342         }
12343         return ret_conv;
12344 }
12345 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12346         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12347         JNIEnv *env;
12348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12349         if (get_jenv_res == JNI_EDETACHED) {
12350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12351         } else {
12352                 DO_ASSERT(get_jenv_res == JNI_OK);
12353         }
12354         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12355         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12356         LDKChannelReestablish msg_var = *msg;
12357         int64_t msg_ref = 0;
12358         msg_var = ChannelReestablish_clone(&msg_var);
12359         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12360         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12361         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12362         CHECK(obj != NULL);
12363         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12364         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12365                 (*env)->ExceptionDescribe(env);
12366                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12367         }
12368         if (get_jenv_res == JNI_EDETACHED) {
12369                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12370         }
12371 }
12372 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12373         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12374         JNIEnv *env;
12375         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12376         if (get_jenv_res == JNI_EDETACHED) {
12377                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12378         } else {
12379                 DO_ASSERT(get_jenv_res == JNI_OK);
12380         }
12381         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12382         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12383         LDKChannelUpdate msg_var = *msg;
12384         int64_t msg_ref = 0;
12385         msg_var = ChannelUpdate_clone(&msg_var);
12386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12387         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12389         CHECK(obj != NULL);
12390         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12391         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12392                 (*env)->ExceptionDescribe(env);
12393                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12394         }
12395         if (get_jenv_res == JNI_EDETACHED) {
12396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12397         }
12398 }
12399 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12400         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12401         JNIEnv *env;
12402         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12403         if (get_jenv_res == JNI_EDETACHED) {
12404                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12405         } else {
12406                 DO_ASSERT(get_jenv_res == JNI_OK);
12407         }
12408         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12409         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12410         LDKErrorMessage msg_var = *msg;
12411         int64_t msg_ref = 0;
12412         msg_var = ErrorMessage_clone(&msg_var);
12413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12414         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12415         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12416         CHECK(obj != NULL);
12417         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12418         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12419                 (*env)->ExceptionDescribe(env);
12420                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12421         }
12422         if (get_jenv_res == JNI_EDETACHED) {
12423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12424         }
12425 }
12426 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
12427         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12428         JNIEnv *env;
12429         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12430         if (get_jenv_res == JNI_EDETACHED) {
12431                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12432         } else {
12433                 DO_ASSERT(get_jenv_res == JNI_OK);
12434         }
12435         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12436         CHECK(obj != NULL);
12437         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
12438         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12439                 (*env)->ExceptionDescribe(env);
12440                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
12441         }
12442         LDKNodeFeatures ret_conv;
12443         ret_conv.inner = untag_ptr(ret);
12444         ret_conv.is_owned = ptr_is_owned(ret);
12445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12446         if (get_jenv_res == JNI_EDETACHED) {
12447                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12448         }
12449         return ret_conv;
12450 }
12451 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
12452         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12453         JNIEnv *env;
12454         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12455         if (get_jenv_res == JNI_EDETACHED) {
12456                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12457         } else {
12458                 DO_ASSERT(get_jenv_res == JNI_OK);
12459         }
12460         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12461         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12463         CHECK(obj != NULL);
12464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
12465         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12466                 (*env)->ExceptionDescribe(env);
12467                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
12468         }
12469         LDKInitFeatures ret_conv;
12470         ret_conv.inner = untag_ptr(ret);
12471         ret_conv.is_owned = ptr_is_owned(ret);
12472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12473         if (get_jenv_res == JNI_EDETACHED) {
12474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12475         }
12476         return ret_conv;
12477 }
12478 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12479         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12480         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12481         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12482 }
12483 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12484         jclass c = (*env)->GetObjectClass(env, o);
12485         CHECK(c != NULL);
12486         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12487         atomic_init(&calls->refcnt, 1);
12488         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12489         calls->o = (*env)->NewWeakGlobalRef(env, o);
12490         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12491         CHECK(calls->handle_open_channel_meth != NULL);
12492         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12493         CHECK(calls->handle_accept_channel_meth != NULL);
12494         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12495         CHECK(calls->handle_funding_created_meth != NULL);
12496         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12497         CHECK(calls->handle_funding_signed_meth != NULL);
12498         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12499         CHECK(calls->handle_channel_ready_meth != NULL);
12500         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12501         CHECK(calls->handle_shutdown_meth != NULL);
12502         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12503         CHECK(calls->handle_closing_signed_meth != NULL);
12504         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12505         CHECK(calls->handle_update_add_htlc_meth != NULL);
12506         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12507         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12508         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12509         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12510         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12511         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12512         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12513         CHECK(calls->handle_commitment_signed_meth != NULL);
12514         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12515         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12516         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12517         CHECK(calls->handle_update_fee_meth != NULL);
12518         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12519         CHECK(calls->handle_announcement_signatures_meth != NULL);
12520         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12521         CHECK(calls->peer_disconnected_meth != NULL);
12522         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
12523         CHECK(calls->peer_connected_meth != NULL);
12524         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12525         CHECK(calls->handle_channel_reestablish_meth != NULL);
12526         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12527         CHECK(calls->handle_channel_update_meth != NULL);
12528         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12529         CHECK(calls->handle_error_meth != NULL);
12530         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
12531         CHECK(calls->provided_node_features_meth != NULL);
12532         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
12533         CHECK(calls->provided_init_features_meth != NULL);
12534
12535         LDKChannelMessageHandler ret = {
12536                 .this_arg = (void*) calls,
12537                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12538                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12539                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12540                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12541                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12542                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12543                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12544                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12545                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12546                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12547                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12548                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12549                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12550                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12551                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12552                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12553                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12554                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12555                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12556                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12557                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
12558                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
12559                 .free = LDKChannelMessageHandler_JCalls_free,
12560                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12561         };
12562         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12563         return ret;
12564 }
12565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12566         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12567         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12568         return tag_ptr(res_ptr, true);
12569 }
12570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12571         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
12572         return tag_ptr(&inp->MessageSendEventsProvider, false);
12573 }
12574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
12575         void* this_arg_ptr = untag_ptr(this_arg);
12576         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12577         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12578         LDKPublicKey their_node_id_ref;
12579         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12580         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12581         LDKInitFeatures their_features_conv;
12582         their_features_conv.inner = untag_ptr(their_features);
12583         their_features_conv.is_owned = ptr_is_owned(their_features);
12584         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12585         their_features_conv = InitFeatures_clone(&their_features_conv);
12586         LDKOpenChannel msg_conv;
12587         msg_conv.inner = untag_ptr(msg);
12588         msg_conv.is_owned = ptr_is_owned(msg);
12589         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12590         msg_conv.is_owned = false;
12591         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12592 }
12593
12594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
12595         void* this_arg_ptr = untag_ptr(this_arg);
12596         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12597         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12598         LDKPublicKey their_node_id_ref;
12599         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12600         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12601         LDKInitFeatures their_features_conv;
12602         their_features_conv.inner = untag_ptr(their_features);
12603         their_features_conv.is_owned = ptr_is_owned(their_features);
12604         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12605         their_features_conv = InitFeatures_clone(&their_features_conv);
12606         LDKAcceptChannel msg_conv;
12607         msg_conv.inner = untag_ptr(msg);
12608         msg_conv.is_owned = ptr_is_owned(msg);
12609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12610         msg_conv.is_owned = false;
12611         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12612 }
12613
12614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12615         void* this_arg_ptr = untag_ptr(this_arg);
12616         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12617         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12618         LDKPublicKey their_node_id_ref;
12619         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12620         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12621         LDKFundingCreated msg_conv;
12622         msg_conv.inner = untag_ptr(msg);
12623         msg_conv.is_owned = ptr_is_owned(msg);
12624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12625         msg_conv.is_owned = false;
12626         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12627 }
12628
12629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12630         void* this_arg_ptr = untag_ptr(this_arg);
12631         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12632         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12633         LDKPublicKey their_node_id_ref;
12634         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12635         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12636         LDKFundingSigned msg_conv;
12637         msg_conv.inner = untag_ptr(msg);
12638         msg_conv.is_owned = ptr_is_owned(msg);
12639         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12640         msg_conv.is_owned = false;
12641         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12642 }
12643
12644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12645         void* this_arg_ptr = untag_ptr(this_arg);
12646         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12647         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12648         LDKPublicKey their_node_id_ref;
12649         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12650         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12651         LDKChannelReady msg_conv;
12652         msg_conv.inner = untag_ptr(msg);
12653         msg_conv.is_owned = ptr_is_owned(msg);
12654         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12655         msg_conv.is_owned = false;
12656         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12657 }
12658
12659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
12660         void* this_arg_ptr = untag_ptr(this_arg);
12661         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12662         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12663         LDKPublicKey their_node_id_ref;
12664         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12665         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12666         LDKInitFeatures their_features_conv;
12667         their_features_conv.inner = untag_ptr(their_features);
12668         their_features_conv.is_owned = ptr_is_owned(their_features);
12669         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12670         their_features_conv.is_owned = false;
12671         LDKShutdown msg_conv;
12672         msg_conv.inner = untag_ptr(msg);
12673         msg_conv.is_owned = ptr_is_owned(msg);
12674         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12675         msg_conv.is_owned = false;
12676         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12677 }
12678
12679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12680         void* this_arg_ptr = untag_ptr(this_arg);
12681         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12682         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12683         LDKPublicKey their_node_id_ref;
12684         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12685         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12686         LDKClosingSigned msg_conv;
12687         msg_conv.inner = untag_ptr(msg);
12688         msg_conv.is_owned = ptr_is_owned(msg);
12689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12690         msg_conv.is_owned = false;
12691         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12692 }
12693
12694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12695         void* this_arg_ptr = untag_ptr(this_arg);
12696         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12697         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12698         LDKPublicKey their_node_id_ref;
12699         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12700         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12701         LDKUpdateAddHTLC msg_conv;
12702         msg_conv.inner = untag_ptr(msg);
12703         msg_conv.is_owned = ptr_is_owned(msg);
12704         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12705         msg_conv.is_owned = false;
12706         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12707 }
12708
12709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12710         void* this_arg_ptr = untag_ptr(this_arg);
12711         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12712         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12713         LDKPublicKey their_node_id_ref;
12714         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12715         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12716         LDKUpdateFulfillHTLC msg_conv;
12717         msg_conv.inner = untag_ptr(msg);
12718         msg_conv.is_owned = ptr_is_owned(msg);
12719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12720         msg_conv.is_owned = false;
12721         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12722 }
12723
12724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12725         void* this_arg_ptr = untag_ptr(this_arg);
12726         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12727         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12728         LDKPublicKey their_node_id_ref;
12729         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12730         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12731         LDKUpdateFailHTLC msg_conv;
12732         msg_conv.inner = untag_ptr(msg);
12733         msg_conv.is_owned = ptr_is_owned(msg);
12734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12735         msg_conv.is_owned = false;
12736         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12737 }
12738
12739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12740         void* this_arg_ptr = untag_ptr(this_arg);
12741         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12742         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12743         LDKPublicKey their_node_id_ref;
12744         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12745         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12746         LDKUpdateFailMalformedHTLC msg_conv;
12747         msg_conv.inner = untag_ptr(msg);
12748         msg_conv.is_owned = ptr_is_owned(msg);
12749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12750         msg_conv.is_owned = false;
12751         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12752 }
12753
12754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12755         void* this_arg_ptr = untag_ptr(this_arg);
12756         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12758         LDKPublicKey their_node_id_ref;
12759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12761         LDKCommitmentSigned msg_conv;
12762         msg_conv.inner = untag_ptr(msg);
12763         msg_conv.is_owned = ptr_is_owned(msg);
12764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12765         msg_conv.is_owned = false;
12766         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12767 }
12768
12769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12770         void* this_arg_ptr = untag_ptr(this_arg);
12771         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12772         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12773         LDKPublicKey their_node_id_ref;
12774         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12775         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12776         LDKRevokeAndACK msg_conv;
12777         msg_conv.inner = untag_ptr(msg);
12778         msg_conv.is_owned = ptr_is_owned(msg);
12779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12780         msg_conv.is_owned = false;
12781         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12782 }
12783
12784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12785         void* this_arg_ptr = untag_ptr(this_arg);
12786         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12787         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12788         LDKPublicKey their_node_id_ref;
12789         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12790         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12791         LDKUpdateFee msg_conv;
12792         msg_conv.inner = untag_ptr(msg);
12793         msg_conv.is_owned = ptr_is_owned(msg);
12794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12795         msg_conv.is_owned = false;
12796         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12797 }
12798
12799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12800         void* this_arg_ptr = untag_ptr(this_arg);
12801         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12802         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12803         LDKPublicKey their_node_id_ref;
12804         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12805         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12806         LDKAnnouncementSignatures msg_conv;
12807         msg_conv.inner = untag_ptr(msg);
12808         msg_conv.is_owned = ptr_is_owned(msg);
12809         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12810         msg_conv.is_owned = false;
12811         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12812 }
12813
12814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
12815         void* this_arg_ptr = untag_ptr(this_arg);
12816         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12817         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12818         LDKPublicKey their_node_id_ref;
12819         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12820         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12821         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12822 }
12823
12824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12825         void* this_arg_ptr = untag_ptr(this_arg);
12826         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12827         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12828         LDKPublicKey their_node_id_ref;
12829         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12830         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12831         LDKInit msg_conv;
12832         msg_conv.inner = untag_ptr(msg);
12833         msg_conv.is_owned = ptr_is_owned(msg);
12834         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12835         msg_conv.is_owned = false;
12836         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
12837         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12838         return tag_ptr(ret_conv, true);
12839 }
12840
12841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12842         void* this_arg_ptr = untag_ptr(this_arg);
12843         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12844         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12845         LDKPublicKey their_node_id_ref;
12846         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12847         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12848         LDKChannelReestablish msg_conv;
12849         msg_conv.inner = untag_ptr(msg);
12850         msg_conv.is_owned = ptr_is_owned(msg);
12851         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12852         msg_conv.is_owned = false;
12853         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12854 }
12855
12856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12857         void* this_arg_ptr = untag_ptr(this_arg);
12858         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12859         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12860         LDKPublicKey their_node_id_ref;
12861         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12862         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12863         LDKChannelUpdate msg_conv;
12864         msg_conv.inner = untag_ptr(msg);
12865         msg_conv.is_owned = ptr_is_owned(msg);
12866         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12867         msg_conv.is_owned = false;
12868         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12869 }
12870
12871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12872         void* this_arg_ptr = untag_ptr(this_arg);
12873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12874         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12875         LDKPublicKey their_node_id_ref;
12876         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12877         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12878         LDKErrorMessage msg_conv;
12879         msg_conv.inner = untag_ptr(msg);
12880         msg_conv.is_owned = ptr_is_owned(msg);
12881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12882         msg_conv.is_owned = false;
12883         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12884 }
12885
12886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
12887         void* this_arg_ptr = untag_ptr(this_arg);
12888         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12890         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
12891         int64_t ret_ref = 0;
12892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12894         return ret_ref;
12895 }
12896
12897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
12898         void* this_arg_ptr = untag_ptr(this_arg);
12899         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12901         LDKPublicKey their_node_id_ref;
12902         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12903         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12904         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
12905         int64_t ret_ref = 0;
12906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12908         return ret_ref;
12909 }
12910
12911 typedef struct LDKRoutingMessageHandler_JCalls {
12912         atomic_size_t refcnt;
12913         JavaVM *vm;
12914         jweak o;
12915         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12916         jmethodID handle_node_announcement_meth;
12917         jmethodID handle_channel_announcement_meth;
12918         jmethodID handle_channel_update_meth;
12919         jmethodID get_next_channel_announcement_meth;
12920         jmethodID get_next_node_announcement_meth;
12921         jmethodID peer_connected_meth;
12922         jmethodID handle_reply_channel_range_meth;
12923         jmethodID handle_reply_short_channel_ids_end_meth;
12924         jmethodID handle_query_channel_range_meth;
12925         jmethodID handle_query_short_channel_ids_meth;
12926         jmethodID provided_node_features_meth;
12927         jmethodID provided_init_features_meth;
12928 } LDKRoutingMessageHandler_JCalls;
12929 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12930         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12931         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12932                 JNIEnv *env;
12933                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12934                 if (get_jenv_res == JNI_EDETACHED) {
12935                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12936                 } else {
12937                         DO_ASSERT(get_jenv_res == JNI_OK);
12938                 }
12939                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12940                 if (get_jenv_res == JNI_EDETACHED) {
12941                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12942                 }
12943                 FREE(j_calls);
12944         }
12945 }
12946 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12947         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12948         JNIEnv *env;
12949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12950         if (get_jenv_res == JNI_EDETACHED) {
12951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12952         } else {
12953                 DO_ASSERT(get_jenv_res == JNI_OK);
12954         }
12955         LDKNodeAnnouncement msg_var = *msg;
12956         int64_t msg_ref = 0;
12957         msg_var = NodeAnnouncement_clone(&msg_var);
12958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12959         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12961         CHECK(obj != NULL);
12962         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12963         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12964                 (*env)->ExceptionDescribe(env);
12965                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12966         }
12967         void* ret_ptr = untag_ptr(ret);
12968         CHECK_ACCESS(ret_ptr);
12969         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12970         FREE(untag_ptr(ret));
12971         if (get_jenv_res == JNI_EDETACHED) {
12972                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12973         }
12974         return ret_conv;
12975 }
12976 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12977         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12978         JNIEnv *env;
12979         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12980         if (get_jenv_res == JNI_EDETACHED) {
12981                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12982         } else {
12983                 DO_ASSERT(get_jenv_res == JNI_OK);
12984         }
12985         LDKChannelAnnouncement msg_var = *msg;
12986         int64_t msg_ref = 0;
12987         msg_var = ChannelAnnouncement_clone(&msg_var);
12988         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12989         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12990         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12991         CHECK(obj != NULL);
12992         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12993         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12994                 (*env)->ExceptionDescribe(env);
12995                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12996         }
12997         void* ret_ptr = untag_ptr(ret);
12998         CHECK_ACCESS(ret_ptr);
12999         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13000         FREE(untag_ptr(ret));
13001         if (get_jenv_res == JNI_EDETACHED) {
13002                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13003         }
13004         return ret_conv;
13005 }
13006 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13007         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13008         JNIEnv *env;
13009         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13010         if (get_jenv_res == JNI_EDETACHED) {
13011                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13012         } else {
13013                 DO_ASSERT(get_jenv_res == JNI_OK);
13014         }
13015         LDKChannelUpdate msg_var = *msg;
13016         int64_t msg_ref = 0;
13017         msg_var = ChannelUpdate_clone(&msg_var);
13018         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13019         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13020         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13021         CHECK(obj != NULL);
13022         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13023         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13024                 (*env)->ExceptionDescribe(env);
13025                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13026         }
13027         void* ret_ptr = untag_ptr(ret);
13028         CHECK_ACCESS(ret_ptr);
13029         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13030         FREE(untag_ptr(ret));
13031         if (get_jenv_res == JNI_EDETACHED) {
13032                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13033         }
13034         return ret_conv;
13035 }
13036 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13037         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13038         JNIEnv *env;
13039         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13040         if (get_jenv_res == JNI_EDETACHED) {
13041                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13042         } else {
13043                 DO_ASSERT(get_jenv_res == JNI_OK);
13044         }
13045         int64_t starting_point_conv = starting_point;
13046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13047         CHECK(obj != NULL);
13048         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
13049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13050                 (*env)->ExceptionDescribe(env);
13051                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13052         }
13053         void* ret_ptr = untag_ptr(ret);
13054         CHECK_ACCESS(ret_ptr);
13055         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13056         FREE(untag_ptr(ret));
13057         if (get_jenv_res == JNI_EDETACHED) {
13058                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13059         }
13060         return ret_conv;
13061 }
13062 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
13063         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13064         JNIEnv *env;
13065         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13066         if (get_jenv_res == JNI_EDETACHED) {
13067                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13068         } else {
13069                 DO_ASSERT(get_jenv_res == JNI_OK);
13070         }
13071         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13072         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13073         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13074         CHECK(obj != NULL);
13075         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_arr);
13076         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13077                 (*env)->ExceptionDescribe(env);
13078                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13079         }
13080         LDKNodeAnnouncement ret_conv;
13081         ret_conv.inner = untag_ptr(ret);
13082         ret_conv.is_owned = ptr_is_owned(ret);
13083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13084         if (get_jenv_res == JNI_EDETACHED) {
13085                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13086         }
13087         return ret_conv;
13088 }
13089 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13090         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13091         JNIEnv *env;
13092         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13093         if (get_jenv_res == JNI_EDETACHED) {
13094                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13095         } else {
13096                 DO_ASSERT(get_jenv_res == JNI_OK);
13097         }
13098         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13099         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13100         LDKInit init_var = *init;
13101         int64_t init_ref = 0;
13102         init_var = Init_clone(&init_var);
13103         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13104         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13105         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13106         CHECK(obj != NULL);
13107         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13108         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13109                 (*env)->ExceptionDescribe(env);
13110                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13111         }
13112         void* ret_ptr = untag_ptr(ret);
13113         CHECK_ACCESS(ret_ptr);
13114         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13115         FREE(untag_ptr(ret));
13116         if (get_jenv_res == JNI_EDETACHED) {
13117                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13118         }
13119         return ret_conv;
13120 }
13121 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13122         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13123         JNIEnv *env;
13124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13125         if (get_jenv_res == JNI_EDETACHED) {
13126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13127         } else {
13128                 DO_ASSERT(get_jenv_res == JNI_OK);
13129         }
13130         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13131         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13132         LDKReplyChannelRange msg_var = msg;
13133         int64_t msg_ref = 0;
13134         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13135         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13137         CHECK(obj != NULL);
13138         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13139         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13140                 (*env)->ExceptionDescribe(env);
13141                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13142         }
13143         void* ret_ptr = untag_ptr(ret);
13144         CHECK_ACCESS(ret_ptr);
13145         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13146         FREE(untag_ptr(ret));
13147         if (get_jenv_res == JNI_EDETACHED) {
13148                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13149         }
13150         return ret_conv;
13151 }
13152 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13153         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13154         JNIEnv *env;
13155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13156         if (get_jenv_res == JNI_EDETACHED) {
13157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13158         } else {
13159                 DO_ASSERT(get_jenv_res == JNI_OK);
13160         }
13161         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13162         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13163         LDKReplyShortChannelIdsEnd msg_var = msg;
13164         int64_t msg_ref = 0;
13165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13166         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13167         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13168         CHECK(obj != NULL);
13169         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13170         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13171                 (*env)->ExceptionDescribe(env);
13172                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13173         }
13174         void* ret_ptr = untag_ptr(ret);
13175         CHECK_ACCESS(ret_ptr);
13176         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13177         FREE(untag_ptr(ret));
13178         if (get_jenv_res == JNI_EDETACHED) {
13179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13180         }
13181         return ret_conv;
13182 }
13183 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13184         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13185         JNIEnv *env;
13186         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13187         if (get_jenv_res == JNI_EDETACHED) {
13188                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13189         } else {
13190                 DO_ASSERT(get_jenv_res == JNI_OK);
13191         }
13192         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13193         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13194         LDKQueryChannelRange msg_var = msg;
13195         int64_t msg_ref = 0;
13196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13197         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13199         CHECK(obj != NULL);
13200         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13202                 (*env)->ExceptionDescribe(env);
13203                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13204         }
13205         void* ret_ptr = untag_ptr(ret);
13206         CHECK_ACCESS(ret_ptr);
13207         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13208         FREE(untag_ptr(ret));
13209         if (get_jenv_res == JNI_EDETACHED) {
13210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13211         }
13212         return ret_conv;
13213 }
13214 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13215         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13216         JNIEnv *env;
13217         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13218         if (get_jenv_res == JNI_EDETACHED) {
13219                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13220         } else {
13221                 DO_ASSERT(get_jenv_res == JNI_OK);
13222         }
13223         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13224         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13225         LDKQueryShortChannelIds msg_var = msg;
13226         int64_t msg_ref = 0;
13227         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13228         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13229         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13230         CHECK(obj != NULL);
13231         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13232         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13233                 (*env)->ExceptionDescribe(env);
13234                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13235         }
13236         void* ret_ptr = untag_ptr(ret);
13237         CHECK_ACCESS(ret_ptr);
13238         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13239         FREE(untag_ptr(ret));
13240         if (get_jenv_res == JNI_EDETACHED) {
13241                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13242         }
13243         return ret_conv;
13244 }
13245 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
13246         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13247         JNIEnv *env;
13248         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13249         if (get_jenv_res == JNI_EDETACHED) {
13250                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13251         } else {
13252                 DO_ASSERT(get_jenv_res == JNI_OK);
13253         }
13254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13255         CHECK(obj != NULL);
13256         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13257         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13258                 (*env)->ExceptionDescribe(env);
13259                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
13260         }
13261         LDKNodeFeatures ret_conv;
13262         ret_conv.inner = untag_ptr(ret);
13263         ret_conv.is_owned = ptr_is_owned(ret);
13264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13265         if (get_jenv_res == JNI_EDETACHED) {
13266                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13267         }
13268         return ret_conv;
13269 }
13270 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13271         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13272         JNIEnv *env;
13273         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13274         if (get_jenv_res == JNI_EDETACHED) {
13275                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13276         } else {
13277                 DO_ASSERT(get_jenv_res == JNI_OK);
13278         }
13279         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13280         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13282         CHECK(obj != NULL);
13283         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13285                 (*env)->ExceptionDescribe(env);
13286                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
13287         }
13288         LDKInitFeatures ret_conv;
13289         ret_conv.inner = untag_ptr(ret);
13290         ret_conv.is_owned = ptr_is_owned(ret);
13291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13292         if (get_jenv_res == JNI_EDETACHED) {
13293                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13294         }
13295         return ret_conv;
13296 }
13297 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13298         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13299         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13300         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13301 }
13302 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13303         jclass c = (*env)->GetObjectClass(env, o);
13304         CHECK(c != NULL);
13305         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13306         atomic_init(&calls->refcnt, 1);
13307         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13308         calls->o = (*env)->NewWeakGlobalRef(env, o);
13309         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13310         CHECK(calls->handle_node_announcement_meth != NULL);
13311         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13312         CHECK(calls->handle_channel_announcement_meth != NULL);
13313         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13314         CHECK(calls->handle_channel_update_meth != NULL);
13315         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
13316         CHECK(calls->get_next_channel_announcement_meth != NULL);
13317         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "([B)J");
13318         CHECK(calls->get_next_node_announcement_meth != NULL);
13319         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13320         CHECK(calls->peer_connected_meth != NULL);
13321         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13322         CHECK(calls->handle_reply_channel_range_meth != NULL);
13323         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13324         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13325         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13326         CHECK(calls->handle_query_channel_range_meth != NULL);
13327         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13328         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13329         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13330         CHECK(calls->provided_node_features_meth != NULL);
13331         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13332         CHECK(calls->provided_init_features_meth != NULL);
13333
13334         LDKRoutingMessageHandler ret = {
13335                 .this_arg = (void*) calls,
13336                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13337                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13338                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13339                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
13340                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
13341                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13342                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13343                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13344                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13345                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13346                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
13347                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
13348                 .free = LDKRoutingMessageHandler_JCalls_free,
13349                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13350         };
13351         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13352         return ret;
13353 }
13354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13355         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13356         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13357         return tag_ptr(res_ptr, true);
13358 }
13359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13360         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
13361         return tag_ptr(&inp->MessageSendEventsProvider, false);
13362 }
13363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13364         void* this_arg_ptr = untag_ptr(this_arg);
13365         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13366         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13367         LDKNodeAnnouncement msg_conv;
13368         msg_conv.inner = untag_ptr(msg);
13369         msg_conv.is_owned = ptr_is_owned(msg);
13370         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13371         msg_conv.is_owned = false;
13372         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13373         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13374         return tag_ptr(ret_conv, true);
13375 }
13376
13377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13378         void* this_arg_ptr = untag_ptr(this_arg);
13379         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13380         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13381         LDKChannelAnnouncement msg_conv;
13382         msg_conv.inner = untag_ptr(msg);
13383         msg_conv.is_owned = ptr_is_owned(msg);
13384         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13385         msg_conv.is_owned = false;
13386         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13387         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13388         return tag_ptr(ret_conv, true);
13389 }
13390
13391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13392         void* this_arg_ptr = untag_ptr(this_arg);
13393         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13394         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13395         LDKChannelUpdate msg_conv;
13396         msg_conv.inner = untag_ptr(msg);
13397         msg_conv.is_owned = ptr_is_owned(msg);
13398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13399         msg_conv.is_owned = false;
13400         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13401         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13402         return tag_ptr(ret_conv, true);
13403 }
13404
13405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point) {
13406         void* this_arg_ptr = untag_ptr(this_arg);
13407         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13408         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13409         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
13410         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
13411         int64_t ret_ref = tag_ptr(ret_copy, true);
13412         return ret_ref;
13413 }
13414
13415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point) {
13416         void* this_arg_ptr = untag_ptr(this_arg);
13417         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13418         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13419         LDKPublicKey starting_point_ref;
13420         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13421         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13422         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
13423         int64_t ret_ref = 0;
13424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13426         return ret_ref;
13427 }
13428
13429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13430         void* this_arg_ptr = untag_ptr(this_arg);
13431         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13432         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13433         LDKPublicKey their_node_id_ref;
13434         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13435         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13436         LDKInit init_conv;
13437         init_conv.inner = untag_ptr(init);
13438         init_conv.is_owned = ptr_is_owned(init);
13439         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13440         init_conv.is_owned = false;
13441         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13442         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13443         return tag_ptr(ret_conv, true);
13444 }
13445
13446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13447         void* this_arg_ptr = untag_ptr(this_arg);
13448         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13449         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13450         LDKPublicKey their_node_id_ref;
13451         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13452         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13453         LDKReplyChannelRange msg_conv;
13454         msg_conv.inner = untag_ptr(msg);
13455         msg_conv.is_owned = ptr_is_owned(msg);
13456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13457         msg_conv = ReplyChannelRange_clone(&msg_conv);
13458         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13459         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13460         return tag_ptr(ret_conv, true);
13461 }
13462
13463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13464         void* this_arg_ptr = untag_ptr(this_arg);
13465         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13466         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13467         LDKPublicKey their_node_id_ref;
13468         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13469         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13470         LDKReplyShortChannelIdsEnd msg_conv;
13471         msg_conv.inner = untag_ptr(msg);
13472         msg_conv.is_owned = ptr_is_owned(msg);
13473         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13474         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13475         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13476         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13477         return tag_ptr(ret_conv, true);
13478 }
13479
13480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13481         void* this_arg_ptr = untag_ptr(this_arg);
13482         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13483         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13484         LDKPublicKey their_node_id_ref;
13485         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13486         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13487         LDKQueryChannelRange msg_conv;
13488         msg_conv.inner = untag_ptr(msg);
13489         msg_conv.is_owned = ptr_is_owned(msg);
13490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13491         msg_conv = QueryChannelRange_clone(&msg_conv);
13492         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13493         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13494         return tag_ptr(ret_conv, true);
13495 }
13496
13497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13498         void* this_arg_ptr = untag_ptr(this_arg);
13499         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13500         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13501         LDKPublicKey their_node_id_ref;
13502         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13503         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13504         LDKQueryShortChannelIds msg_conv;
13505         msg_conv.inner = untag_ptr(msg);
13506         msg_conv.is_owned = ptr_is_owned(msg);
13507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13508         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13509         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13510         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13511         return tag_ptr(ret_conv, true);
13512 }
13513
13514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13515         void* this_arg_ptr = untag_ptr(this_arg);
13516         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13517         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13518         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13519         int64_t ret_ref = 0;
13520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13522         return ret_ref;
13523 }
13524
13525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13526         void* this_arg_ptr = untag_ptr(this_arg);
13527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13528         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13529         LDKPublicKey their_node_id_ref;
13530         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13531         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13532         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13533         int64_t ret_ref = 0;
13534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13536         return ret_ref;
13537 }
13538
13539 typedef struct LDKOnionMessageHandler_JCalls {
13540         atomic_size_t refcnt;
13541         JavaVM *vm;
13542         jweak o;
13543         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
13544         jmethodID handle_onion_message_meth;
13545         jmethodID peer_connected_meth;
13546         jmethodID peer_disconnected_meth;
13547         jmethodID provided_node_features_meth;
13548         jmethodID provided_init_features_meth;
13549 } LDKOnionMessageHandler_JCalls;
13550 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
13551         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13552         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13553                 JNIEnv *env;
13554                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13555                 if (get_jenv_res == JNI_EDETACHED) {
13556                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13557                 } else {
13558                         DO_ASSERT(get_jenv_res == JNI_OK);
13559                 }
13560                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13561                 if (get_jenv_res == JNI_EDETACHED) {
13562                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13563                 }
13564                 FREE(j_calls);
13565         }
13566 }
13567 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
13568         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13569         JNIEnv *env;
13570         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13571         if (get_jenv_res == JNI_EDETACHED) {
13572                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13573         } else {
13574                 DO_ASSERT(get_jenv_res == JNI_OK);
13575         }
13576         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
13577         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
13578         LDKOnionMessage msg_var = *msg;
13579         int64_t msg_ref = 0;
13580         msg_var = OnionMessage_clone(&msg_var);
13581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13582         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13584         CHECK(obj != NULL);
13585         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
13586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13587                 (*env)->ExceptionDescribe(env);
13588                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
13589         }
13590         if (get_jenv_res == JNI_EDETACHED) {
13591                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13592         }
13593 }
13594 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13595         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13596         JNIEnv *env;
13597         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13598         if (get_jenv_res == JNI_EDETACHED) {
13599                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13600         } else {
13601                 DO_ASSERT(get_jenv_res == JNI_OK);
13602         }
13603         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13604         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13605         LDKInit init_var = *init;
13606         int64_t init_ref = 0;
13607         init_var = Init_clone(&init_var);
13608         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13609         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13610         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13611         CHECK(obj != NULL);
13612         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13613         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13614                 (*env)->ExceptionDescribe(env);
13615                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
13616         }
13617         void* ret_ptr = untag_ptr(ret);
13618         CHECK_ACCESS(ret_ptr);
13619         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13620         FREE(untag_ptr(ret));
13621         if (get_jenv_res == JNI_EDETACHED) {
13622                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13623         }
13624         return ret_conv;
13625 }
13626 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
13627         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13628         JNIEnv *env;
13629         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13630         if (get_jenv_res == JNI_EDETACHED) {
13631                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13632         } else {
13633                 DO_ASSERT(get_jenv_res == JNI_OK);
13634         }
13635         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13636         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13637         jboolean no_connection_possible_conv = no_connection_possible;
13638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13639         CHECK(obj != NULL);
13640         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
13641         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13642                 (*env)->ExceptionDescribe(env);
13643                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
13644         }
13645         if (get_jenv_res == JNI_EDETACHED) {
13646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13647         }
13648 }
13649 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
13650         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13651         JNIEnv *env;
13652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13653         if (get_jenv_res == JNI_EDETACHED) {
13654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13655         } else {
13656                 DO_ASSERT(get_jenv_res == JNI_OK);
13657         }
13658         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13659         CHECK(obj != NULL);
13660         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13661         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13662                 (*env)->ExceptionDescribe(env);
13663                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
13664         }
13665         LDKNodeFeatures ret_conv;
13666         ret_conv.inner = untag_ptr(ret);
13667         ret_conv.is_owned = ptr_is_owned(ret);
13668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13669         if (get_jenv_res == JNI_EDETACHED) {
13670                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13671         }
13672         return ret_conv;
13673 }
13674 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13675         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13676         JNIEnv *env;
13677         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13678         if (get_jenv_res == JNI_EDETACHED) {
13679                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13680         } else {
13681                 DO_ASSERT(get_jenv_res == JNI_OK);
13682         }
13683         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13684         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13685         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13686         CHECK(obj != NULL);
13687         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13688         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13689                 (*env)->ExceptionDescribe(env);
13690                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
13691         }
13692         LDKInitFeatures ret_conv;
13693         ret_conv.inner = untag_ptr(ret);
13694         ret_conv.is_owned = ptr_is_owned(ret);
13695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13696         if (get_jenv_res == JNI_EDETACHED) {
13697                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13698         }
13699         return ret_conv;
13700 }
13701 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
13702         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
13703         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13704         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
13705 }
13706 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13707         jclass c = (*env)->GetObjectClass(env, o);
13708         CHECK(c != NULL);
13709         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
13710         atomic_init(&calls->refcnt, 1);
13711         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13712         calls->o = (*env)->NewWeakGlobalRef(env, o);
13713         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
13714         CHECK(calls->handle_onion_message_meth != NULL);
13715         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13716         CHECK(calls->peer_connected_meth != NULL);
13717         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
13718         CHECK(calls->peer_disconnected_meth != NULL);
13719         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13720         CHECK(calls->provided_node_features_meth != NULL);
13721         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13722         CHECK(calls->provided_init_features_meth != NULL);
13723
13724         LDKOnionMessageHandler ret = {
13725                 .this_arg = (void*) calls,
13726                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
13727                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
13728                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
13729                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
13730                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
13731                 .free = LDKOnionMessageHandler_JCalls_free,
13732                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
13733         };
13734         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
13735         return ret;
13736 }
13737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13738         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
13739         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
13740         return tag_ptr(res_ptr, true);
13741 }
13742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
13743         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
13744         return tag_ptr(&inp->OnionMessageProvider, false);
13745 }
13746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1handle_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id, int64_t msg) {
13747         void* this_arg_ptr = untag_ptr(this_arg);
13748         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13749         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13750         LDKPublicKey peer_node_id_ref;
13751         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
13752         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
13753         LDKOnionMessage msg_conv;
13754         msg_conv.inner = untag_ptr(msg);
13755         msg_conv.is_owned = ptr_is_owned(msg);
13756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13757         msg_conv.is_owned = false;
13758         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
13759 }
13760
13761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13762         void* this_arg_ptr = untag_ptr(this_arg);
13763         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13764         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13765         LDKPublicKey their_node_id_ref;
13766         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13767         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13768         LDKInit init_conv;
13769         init_conv.inner = untag_ptr(init);
13770         init_conv.is_owned = ptr_is_owned(init);
13771         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13772         init_conv.is_owned = false;
13773         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13774         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13775         return tag_ptr(ret_conv, true);
13776 }
13777
13778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
13779         void* this_arg_ptr = untag_ptr(this_arg);
13780         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13781         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13782         LDKPublicKey their_node_id_ref;
13783         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13784         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13785         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
13786 }
13787
13788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13789         void* this_arg_ptr = untag_ptr(this_arg);
13790         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13791         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13792         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13793         int64_t ret_ref = 0;
13794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13796         return ret_ref;
13797 }
13798
13799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13800         void* this_arg_ptr = untag_ptr(this_arg);
13801         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13802         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13803         LDKPublicKey their_node_id_ref;
13804         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13805         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13806         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13807         int64_t ret_ref = 0;
13808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13810         return ret_ref;
13811 }
13812
13813 typedef struct LDKCustomMessageReader_JCalls {
13814         atomic_size_t refcnt;
13815         JavaVM *vm;
13816         jweak o;
13817         jmethodID read_meth;
13818 } LDKCustomMessageReader_JCalls;
13819 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13820         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13821         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13822                 JNIEnv *env;
13823                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13824                 if (get_jenv_res == JNI_EDETACHED) {
13825                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13826                 } else {
13827                         DO_ASSERT(get_jenv_res == JNI_OK);
13828                 }
13829                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13830                 if (get_jenv_res == JNI_EDETACHED) {
13831                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13832                 }
13833                 FREE(j_calls);
13834         }
13835 }
13836 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13837         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13838         JNIEnv *env;
13839         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13840         if (get_jenv_res == JNI_EDETACHED) {
13841                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13842         } else {
13843                 DO_ASSERT(get_jenv_res == JNI_OK);
13844         }
13845         int16_t message_type_conv = message_type;
13846         LDKu8slice buffer_var = buffer;
13847         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13848         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13849         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13850         CHECK(obj != NULL);
13851         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13852         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13853                 (*env)->ExceptionDescribe(env);
13854                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13855         }
13856         void* ret_ptr = untag_ptr(ret);
13857         CHECK_ACCESS(ret_ptr);
13858         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13859         FREE(untag_ptr(ret));
13860         if (get_jenv_res == JNI_EDETACHED) {
13861                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13862         }
13863         return ret_conv;
13864 }
13865 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13866         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13867         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13868 }
13869 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13870         jclass c = (*env)->GetObjectClass(env, o);
13871         CHECK(c != NULL);
13872         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13873         atomic_init(&calls->refcnt, 1);
13874         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13875         calls->o = (*env)->NewWeakGlobalRef(env, o);
13876         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13877         CHECK(calls->read_meth != NULL);
13878
13879         LDKCustomMessageReader ret = {
13880                 .this_arg = (void*) calls,
13881                 .read = read_LDKCustomMessageReader_jcall,
13882                 .free = LDKCustomMessageReader_JCalls_free,
13883         };
13884         return ret;
13885 }
13886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13887         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13888         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13889         return tag_ptr(res_ptr, true);
13890 }
13891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) {
13892         void* this_arg_ptr = untag_ptr(this_arg);
13893         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13894         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13895         LDKu8slice buffer_ref;
13896         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13897         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13898         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13899         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13900         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13901         return tag_ptr(ret_conv, true);
13902 }
13903
13904 typedef struct LDKCustomMessageHandler_JCalls {
13905         atomic_size_t refcnt;
13906         JavaVM *vm;
13907         jweak o;
13908         LDKCustomMessageReader_JCalls* CustomMessageReader;
13909         jmethodID handle_custom_message_meth;
13910         jmethodID get_and_clear_pending_msg_meth;
13911 } LDKCustomMessageHandler_JCalls;
13912 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13913         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13914         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13915                 JNIEnv *env;
13916                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13917                 if (get_jenv_res == JNI_EDETACHED) {
13918                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13919                 } else {
13920                         DO_ASSERT(get_jenv_res == JNI_OK);
13921                 }
13922                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13923                 if (get_jenv_res == JNI_EDETACHED) {
13924                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13925                 }
13926                 FREE(j_calls);
13927         }
13928 }
13929 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13930         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13931         JNIEnv *env;
13932         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13933         if (get_jenv_res == JNI_EDETACHED) {
13934                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13935         } else {
13936                 DO_ASSERT(get_jenv_res == JNI_OK);
13937         }
13938         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13939         *msg_ret = msg;
13940         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13941         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13942         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13943         CHECK(obj != NULL);
13944         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
13945         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13946                 (*env)->ExceptionDescribe(env);
13947                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13948         }
13949         void* ret_ptr = untag_ptr(ret);
13950         CHECK_ACCESS(ret_ptr);
13951         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13952         FREE(untag_ptr(ret));
13953         if (get_jenv_res == JNI_EDETACHED) {
13954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13955         }
13956         return ret_conv;
13957 }
13958 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13959         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13960         JNIEnv *env;
13961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13962         if (get_jenv_res == JNI_EDETACHED) {
13963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13964         } else {
13965                 DO_ASSERT(get_jenv_res == JNI_OK);
13966         }
13967         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13968         CHECK(obj != NULL);
13969         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13970         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13971                 (*env)->ExceptionDescribe(env);
13972                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13973         }
13974         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13975         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13976         if (ret_constr.datalen > 0)
13977                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13978         else
13979                 ret_constr.data = NULL;
13980         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13981         for (size_t z = 0; z < ret_constr.datalen; z++) {
13982                 int64_t ret_conv_25 = ret_vals[z];
13983                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
13984                 CHECK_ACCESS(ret_conv_25_ptr);
13985                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13986                 FREE(untag_ptr(ret_conv_25));
13987                 ret_constr.data[z] = ret_conv_25_conv;
13988         }
13989         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13990         if (get_jenv_res == JNI_EDETACHED) {
13991                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13992         }
13993         return ret_constr;
13994 }
13995 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13996         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13997         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13998         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13999 }
14000 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14001         jclass c = (*env)->GetObjectClass(env, o);
14002         CHECK(c != NULL);
14003         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14004         atomic_init(&calls->refcnt, 1);
14005         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14006         calls->o = (*env)->NewWeakGlobalRef(env, o);
14007         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
14008         CHECK(calls->handle_custom_message_meth != NULL);
14009         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
14010         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
14011
14012         LDKCustomMessageHandler ret = {
14013                 .this_arg = (void*) calls,
14014                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14015                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14016                 .free = LDKCustomMessageHandler_JCalls_free,
14017                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
14018         };
14019         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14020         return ret;
14021 }
14022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14023         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14024         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
14025         return tag_ptr(res_ptr, true);
14026 }
14027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
14028         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
14029         return tag_ptr(&inp->CustomMessageReader, false);
14030 }
14031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
14032         void* this_arg_ptr = untag_ptr(this_arg);
14033         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14034         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14035         void* msg_ptr = untag_ptr(msg);
14036         CHECK_ACCESS(msg_ptr);
14037         LDKType msg_conv = *(LDKType*)(msg_ptr);
14038         if (msg_conv.free == LDKType_JCalls_free) {
14039                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14040                 LDKType_JCalls_cloned(&msg_conv);
14041         }
14042         LDKPublicKey sender_node_id_ref;
14043         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
14044         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
14045         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14046         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14047         return tag_ptr(ret_conv, true);
14048 }
14049
14050 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
14051         void* this_arg_ptr = untag_ptr(this_arg);
14052         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14053         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14054         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14055         int64_tArray ret_arr = NULL;
14056         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14057         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14058         for (size_t z = 0; z < ret_var.datalen; z++) {
14059                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14060                 *ret_conv_25_conv = ret_var.data[z];
14061                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14062         }
14063         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14064         FREE(ret_var.data);
14065         return ret_arr;
14066 }
14067
14068 typedef struct LDKCustomOnionMessageHandler_JCalls {
14069         atomic_size_t refcnt;
14070         JavaVM *vm;
14071         jweak o;
14072         jmethodID handle_custom_message_meth;
14073         jmethodID read_custom_message_meth;
14074 } LDKCustomOnionMessageHandler_JCalls;
14075 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14076         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14077         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14078                 JNIEnv *env;
14079                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14080                 if (get_jenv_res == JNI_EDETACHED) {
14081                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14082                 } else {
14083                         DO_ASSERT(get_jenv_res == JNI_OK);
14084                 }
14085                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14086                 if (get_jenv_res == JNI_EDETACHED) {
14087                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14088                 }
14089                 FREE(j_calls);
14090         }
14091 }
14092 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
14093         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14094         JNIEnv *env;
14095         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14096         if (get_jenv_res == JNI_EDETACHED) {
14097                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14098         } else {
14099                 DO_ASSERT(get_jenv_res == JNI_OK);
14100         }
14101         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
14102         *msg_ret = msg;
14103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14104         CHECK(obj != NULL);
14105         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
14106         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14107                 (*env)->ExceptionDescribe(env);
14108                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14109         }
14110         if (get_jenv_res == JNI_EDETACHED) {
14111                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14112         }
14113 }
14114 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14115         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14116         JNIEnv *env;
14117         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14118         if (get_jenv_res == JNI_EDETACHED) {
14119                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14120         } else {
14121                 DO_ASSERT(get_jenv_res == JNI_OK);
14122         }
14123         int64_t message_type_conv = message_type;
14124         LDKu8slice buffer_var = buffer;
14125         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14126         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14128         CHECK(obj != NULL);
14129         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
14130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14131                 (*env)->ExceptionDescribe(env);
14132                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14133         }
14134         void* ret_ptr = untag_ptr(ret);
14135         CHECK_ACCESS(ret_ptr);
14136         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14137         FREE(untag_ptr(ret));
14138         if (get_jenv_res == JNI_EDETACHED) {
14139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14140         }
14141         return ret_conv;
14142 }
14143 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14144         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14145         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14146 }
14147 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
14148         jclass c = (*env)->GetObjectClass(env, o);
14149         CHECK(c != NULL);
14150         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14151         atomic_init(&calls->refcnt, 1);
14152         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14153         calls->o = (*env)->NewWeakGlobalRef(env, o);
14154         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
14155         CHECK(calls->handle_custom_message_meth != NULL);
14156         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
14157         CHECK(calls->read_custom_message_meth != NULL);
14158
14159         LDKCustomOnionMessageHandler ret = {
14160                 .this_arg = (void*) calls,
14161                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14162                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14163                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14164         };
14165         return ret;
14166 }
14167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
14168         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14169         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
14170         return tag_ptr(res_ptr, true);
14171 }
14172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14173         void* this_arg_ptr = untag_ptr(this_arg);
14174         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14175         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14176         void* msg_ptr = untag_ptr(msg);
14177         CHECK_ACCESS(msg_ptr);
14178         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
14179         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
14180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14181                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
14182         }
14183         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14184 }
14185
14186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1read_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t message_type, int8_tArray buffer) {
14187         void* this_arg_ptr = untag_ptr(this_arg);
14188         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14189         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14190         LDKu8slice buffer_ref;
14191         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14192         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14193         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
14194         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14195         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14196         return tag_ptr(ret_conv, true);
14197 }
14198
14199 typedef struct LDKSocketDescriptor_JCalls {
14200         atomic_size_t refcnt;
14201         JavaVM *vm;
14202         jweak o;
14203         jmethodID send_data_meth;
14204         jmethodID disconnect_socket_meth;
14205         jmethodID eq_meth;
14206         jmethodID hash_meth;
14207 } LDKSocketDescriptor_JCalls;
14208 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14209         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14210         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14211                 JNIEnv *env;
14212                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14213                 if (get_jenv_res == JNI_EDETACHED) {
14214                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14215                 } else {
14216                         DO_ASSERT(get_jenv_res == JNI_OK);
14217                 }
14218                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14219                 if (get_jenv_res == JNI_EDETACHED) {
14220                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14221                 }
14222                 FREE(j_calls);
14223         }
14224 }
14225 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14226         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14227         JNIEnv *env;
14228         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14229         if (get_jenv_res == JNI_EDETACHED) {
14230                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14231         } else {
14232                 DO_ASSERT(get_jenv_res == JNI_OK);
14233         }
14234         LDKu8slice data_var = data;
14235         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
14236         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
14237         jboolean resume_read_conv = resume_read;
14238         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14239         CHECK(obj != NULL);
14240         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
14241         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14242                 (*env)->ExceptionDescribe(env);
14243                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
14244         }
14245         if (get_jenv_res == JNI_EDETACHED) {
14246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14247         }
14248         return ret;
14249 }
14250 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14251         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14252         JNIEnv *env;
14253         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14254         if (get_jenv_res == JNI_EDETACHED) {
14255                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14256         } else {
14257                 DO_ASSERT(get_jenv_res == JNI_OK);
14258         }
14259         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14260         CHECK(obj != NULL);
14261         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
14262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14263                 (*env)->ExceptionDescribe(env);
14264                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
14265         }
14266         if (get_jenv_res == JNI_EDETACHED) {
14267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14268         }
14269 }
14270 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14271         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14272         JNIEnv *env;
14273         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14274         if (get_jenv_res == JNI_EDETACHED) {
14275                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14276         } else {
14277                 DO_ASSERT(get_jenv_res == JNI_OK);
14278         }
14279         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14280         *other_arg_clone = SocketDescriptor_clone(other_arg);
14281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14282         CHECK(obj != NULL);
14283         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
14284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14285                 (*env)->ExceptionDescribe(env);
14286                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
14287         }
14288         if (get_jenv_res == JNI_EDETACHED) {
14289                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14290         }
14291         return ret;
14292 }
14293 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14294         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14295         JNIEnv *env;
14296         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14297         if (get_jenv_res == JNI_EDETACHED) {
14298                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14299         } else {
14300                 DO_ASSERT(get_jenv_res == JNI_OK);
14301         }
14302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14303         CHECK(obj != NULL);
14304         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
14305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14306                 (*env)->ExceptionDescribe(env);
14307                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
14308         }
14309         if (get_jenv_res == JNI_EDETACHED) {
14310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14311         }
14312         return ret;
14313 }
14314 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14315         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14316         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14317 }
14318 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
14319         jclass c = (*env)->GetObjectClass(env, o);
14320         CHECK(c != NULL);
14321         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14322         atomic_init(&calls->refcnt, 1);
14323         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14324         calls->o = (*env)->NewWeakGlobalRef(env, o);
14325         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
14326         CHECK(calls->send_data_meth != NULL);
14327         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
14328         CHECK(calls->disconnect_socket_meth != NULL);
14329         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
14330         CHECK(calls->eq_meth != NULL);
14331         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
14332         CHECK(calls->hash_meth != NULL);
14333
14334         LDKSocketDescriptor ret = {
14335                 .this_arg = (void*) calls,
14336                 .send_data = send_data_LDKSocketDescriptor_jcall,
14337                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14338                 .eq = eq_LDKSocketDescriptor_jcall,
14339                 .hash = hash_LDKSocketDescriptor_jcall,
14340                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14341                 .free = LDKSocketDescriptor_JCalls_free,
14342         };
14343         return ret;
14344 }
14345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
14346         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14347         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
14348         return tag_ptr(res_ptr, true);
14349 }
14350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
14351         void* this_arg_ptr = untag_ptr(this_arg);
14352         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14353         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14354         LDKu8slice data_ref;
14355         data_ref.datalen = (*env)->GetArrayLength(env, data);
14356         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14357         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14358         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14359         return ret_conv;
14360 }
14361
14362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14363         void* this_arg_ptr = untag_ptr(this_arg);
14364         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14365         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14366         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14367 }
14368
14369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14370         void* this_arg_ptr = untag_ptr(this_arg);
14371         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14372         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14373         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14374         return ret_conv;
14375 }
14376
14377 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14378 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14379 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14380 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14381 static jclass LDKEffectiveCapacity_Total_class = NULL;
14382 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14383 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14384 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14385 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14386 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14388         LDKEffectiveCapacity_ExactLiquidity_class =
14389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14390         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14391         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14392         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14393         LDKEffectiveCapacity_MaximumHTLC_class =
14394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14395         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14396         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14397         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14398         LDKEffectiveCapacity_Total_class =
14399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14400         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14401         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14402         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14403         LDKEffectiveCapacity_Infinite_class =
14404                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14405         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14406         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14407         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14408         LDKEffectiveCapacity_Unknown_class =
14409                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14410         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14411         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14412         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14413 }
14414 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14415         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14416         switch(obj->tag) {
14417                 case LDKEffectiveCapacity_ExactLiquidity: {
14418                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14419                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14420                 }
14421                 case LDKEffectiveCapacity_MaximumHTLC: {
14422                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14423                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14424                 }
14425                 case LDKEffectiveCapacity_Total: {
14426                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14427                         int64_t htlc_maximum_msat_ref = tag_ptr(&obj->total.htlc_maximum_msat, false);
14428                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14429                 }
14430                 case LDKEffectiveCapacity_Infinite: {
14431                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14432                 }
14433                 case LDKEffectiveCapacity_Unknown: {
14434                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14435                 }
14436                 default: abort();
14437         }
14438 }
14439 static jclass LDKDestination_Node_class = NULL;
14440 static jmethodID LDKDestination_Node_meth = NULL;
14441 static jclass LDKDestination_BlindedRoute_class = NULL;
14442 static jmethodID LDKDestination_BlindedRoute_meth = NULL;
14443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
14444         LDKDestination_Node_class =
14445                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
14446         CHECK(LDKDestination_Node_class != NULL);
14447         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
14448         CHECK(LDKDestination_Node_meth != NULL);
14449         LDKDestination_BlindedRoute_class =
14450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedRoute"));
14451         CHECK(LDKDestination_BlindedRoute_class != NULL);
14452         LDKDestination_BlindedRoute_meth = (*env)->GetMethodID(env, LDKDestination_BlindedRoute_class, "<init>", "(J)V");
14453         CHECK(LDKDestination_BlindedRoute_meth != NULL);
14454 }
14455 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14456         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
14457         switch(obj->tag) {
14458                 case LDKDestination_Node: {
14459                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
14460                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
14461                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
14462                 }
14463                 case LDKDestination_BlindedRoute: {
14464                         LDKBlindedRoute blinded_route_var = obj->blinded_route;
14465                         int64_t blinded_route_ref = 0;
14466                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_route_var);
14467                         blinded_route_ref = tag_ptr(blinded_route_var.inner, false);
14468                         return (*env)->NewObject(env, LDKDestination_BlindedRoute_class, LDKDestination_BlindedRoute_meth, blinded_route_ref);
14469                 }
14470                 default: abort();
14471         }
14472 }
14473 static jclass LDKGossipSync_P2P_class = NULL;
14474 static jmethodID LDKGossipSync_P2P_meth = NULL;
14475 static jclass LDKGossipSync_Rapid_class = NULL;
14476 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14477 static jclass LDKGossipSync_None_class = NULL;
14478 static jmethodID LDKGossipSync_None_meth = NULL;
14479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14480         LDKGossipSync_P2P_class =
14481                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14482         CHECK(LDKGossipSync_P2P_class != NULL);
14483         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14484         CHECK(LDKGossipSync_P2P_meth != NULL);
14485         LDKGossipSync_Rapid_class =
14486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14487         CHECK(LDKGossipSync_Rapid_class != NULL);
14488         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14489         CHECK(LDKGossipSync_Rapid_meth != NULL);
14490         LDKGossipSync_None_class =
14491                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14492         CHECK(LDKGossipSync_None_class != NULL);
14493         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14494         CHECK(LDKGossipSync_None_meth != NULL);
14495 }
14496 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14497         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
14498         switch(obj->tag) {
14499                 case LDKGossipSync_P2P: {
14500                         LDKP2PGossipSync p2p_var = obj->p2p;
14501                         int64_t p2p_ref = 0;
14502                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14503                         p2p_ref = tag_ptr(p2p_var.inner, false);
14504                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14505                 }
14506                 case LDKGossipSync_Rapid: {
14507                         LDKRapidGossipSync rapid_var = obj->rapid;
14508                         int64_t rapid_ref = 0;
14509                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14510                         rapid_ref = tag_ptr(rapid_var.inner, false);
14511                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14512                 }
14513                 case LDKGossipSync_None: {
14514                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14515                 }
14516                 default: abort();
14517         }
14518 }
14519 static jclass LDKFallback_SegWitProgram_class = NULL;
14520 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14521 static jclass LDKFallback_PubKeyHash_class = NULL;
14522 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14523 static jclass LDKFallback_ScriptHash_class = NULL;
14524 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14526         LDKFallback_SegWitProgram_class =
14527                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14528         CHECK(LDKFallback_SegWitProgram_class != NULL);
14529         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14530         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14531         LDKFallback_PubKeyHash_class =
14532                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14533         CHECK(LDKFallback_PubKeyHash_class != NULL);
14534         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14535         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14536         LDKFallback_ScriptHash_class =
14537                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14538         CHECK(LDKFallback_ScriptHash_class != NULL);
14539         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14540         CHECK(LDKFallback_ScriptHash_meth != NULL);
14541 }
14542 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14543         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
14544         switch(obj->tag) {
14545                 case LDKFallback_SegWitProgram: {
14546                         uint8_t version_val = obj->seg_wit_program.version._0;
14547                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14548                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14549                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14550                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14551                 }
14552                 case LDKFallback_PubKeyHash: {
14553                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14554                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14555                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14556                 }
14557                 case LDKFallback_ScriptHash: {
14558                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14559                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14560                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14561                 }
14562                 default: abort();
14563         }
14564 }
14565 typedef struct LDKPayer_JCalls {
14566         atomic_size_t refcnt;
14567         JavaVM *vm;
14568         jweak o;
14569         jmethodID node_id_meth;
14570         jmethodID first_hops_meth;
14571         jmethodID send_payment_meth;
14572         jmethodID send_spontaneous_payment_meth;
14573         jmethodID retry_payment_meth;
14574         jmethodID abandon_payment_meth;
14575 } LDKPayer_JCalls;
14576 static void LDKPayer_JCalls_free(void* this_arg) {
14577         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14578         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14579                 JNIEnv *env;
14580                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14581                 if (get_jenv_res == JNI_EDETACHED) {
14582                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14583                 } else {
14584                         DO_ASSERT(get_jenv_res == JNI_OK);
14585                 }
14586                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14587                 if (get_jenv_res == JNI_EDETACHED) {
14588                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14589                 }
14590                 FREE(j_calls);
14591         }
14592 }
14593 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14594         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14595         JNIEnv *env;
14596         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14597         if (get_jenv_res == JNI_EDETACHED) {
14598                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14599         } else {
14600                 DO_ASSERT(get_jenv_res == JNI_OK);
14601         }
14602         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14603         CHECK(obj != NULL);
14604         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14605         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14606                 (*env)->ExceptionDescribe(env);
14607                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14608         }
14609         LDKPublicKey ret_ref;
14610         CHECK((*env)->GetArrayLength(env, ret) == 33);
14611         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14612         if (get_jenv_res == JNI_EDETACHED) {
14613                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14614         }
14615         return ret_ref;
14616 }
14617 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14618         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14619         JNIEnv *env;
14620         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14621         if (get_jenv_res == JNI_EDETACHED) {
14622                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14623         } else {
14624                 DO_ASSERT(get_jenv_res == JNI_OK);
14625         }
14626         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14627         CHECK(obj != NULL);
14628         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14629         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14630                 (*env)->ExceptionDescribe(env);
14631                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14632         }
14633         LDKCVec_ChannelDetailsZ ret_constr;
14634         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14635         if (ret_constr.datalen > 0)
14636                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14637         else
14638                 ret_constr.data = NULL;
14639         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14640         for (size_t q = 0; q < ret_constr.datalen; q++) {
14641                 int64_t ret_conv_16 = ret_vals[q];
14642                 LDKChannelDetails ret_conv_16_conv;
14643                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
14644                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
14645                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14646                 ret_constr.data[q] = ret_conv_16_conv;
14647         }
14648         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14649         if (get_jenv_res == JNI_EDETACHED) {
14650                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14651         }
14652         return ret_constr;
14653 }
14654 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14655         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14656         JNIEnv *env;
14657         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14658         if (get_jenv_res == JNI_EDETACHED) {
14659                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14660         } else {
14661                 DO_ASSERT(get_jenv_res == JNI_OK);
14662         }
14663         LDKRoute route_var = *route;
14664         int64_t route_ref = 0;
14665         route_var = Route_clone(&route_var);
14666         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14667         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14668         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14669         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14670         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14671         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14673         CHECK(obj != NULL);
14674         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14676                 (*env)->ExceptionDescribe(env);
14677                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14678         }
14679         void* ret_ptr = untag_ptr(ret);
14680         CHECK_ACCESS(ret_ptr);
14681         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14682         FREE(untag_ptr(ret));
14683         if (get_jenv_res == JNI_EDETACHED) {
14684                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14685         }
14686         return ret_conv;
14687 }
14688 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14689         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14690         JNIEnv *env;
14691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14692         if (get_jenv_res == JNI_EDETACHED) {
14693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14694         } else {
14695                 DO_ASSERT(get_jenv_res == JNI_OK);
14696         }
14697         LDKRoute route_var = *route;
14698         int64_t route_ref = 0;
14699         route_var = Route_clone(&route_var);
14700         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14701         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14702         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14703         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14704         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14705         CHECK(obj != NULL);
14706         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14707         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14708                 (*env)->ExceptionDescribe(env);
14709                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14710         }
14711         void* ret_ptr = untag_ptr(ret);
14712         CHECK_ACCESS(ret_ptr);
14713         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14714         FREE(untag_ptr(ret));
14715         if (get_jenv_res == JNI_EDETACHED) {
14716                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14717         }
14718         return ret_conv;
14719 }
14720 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14721         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14722         JNIEnv *env;
14723         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14724         if (get_jenv_res == JNI_EDETACHED) {
14725                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14726         } else {
14727                 DO_ASSERT(get_jenv_res == JNI_OK);
14728         }
14729         LDKRoute route_var = *route;
14730         int64_t route_ref = 0;
14731         route_var = Route_clone(&route_var);
14732         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14733         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14734         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14735         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14737         CHECK(obj != NULL);
14738         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14740                 (*env)->ExceptionDescribe(env);
14741                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14742         }
14743         void* ret_ptr = untag_ptr(ret);
14744         CHECK_ACCESS(ret_ptr);
14745         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14746         FREE(untag_ptr(ret));
14747         if (get_jenv_res == JNI_EDETACHED) {
14748                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14749         }
14750         return ret_conv;
14751 }
14752 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14753         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14754         JNIEnv *env;
14755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14756         if (get_jenv_res == JNI_EDETACHED) {
14757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14758         } else {
14759                 DO_ASSERT(get_jenv_res == JNI_OK);
14760         }
14761         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14762         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14764         CHECK(obj != NULL);
14765         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14766         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14767                 (*env)->ExceptionDescribe(env);
14768                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14769         }
14770         if (get_jenv_res == JNI_EDETACHED) {
14771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14772         }
14773 }
14774 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14775         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14776         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14777 }
14778 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14779         jclass c = (*env)->GetObjectClass(env, o);
14780         CHECK(c != NULL);
14781         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14782         atomic_init(&calls->refcnt, 1);
14783         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14784         calls->o = (*env)->NewWeakGlobalRef(env, o);
14785         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14786         CHECK(calls->node_id_meth != NULL);
14787         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14788         CHECK(calls->first_hops_meth != NULL);
14789         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14790         CHECK(calls->send_payment_meth != NULL);
14791         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14792         CHECK(calls->send_spontaneous_payment_meth != NULL);
14793         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14794         CHECK(calls->retry_payment_meth != NULL);
14795         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14796         CHECK(calls->abandon_payment_meth != NULL);
14797
14798         LDKPayer ret = {
14799                 .this_arg = (void*) calls,
14800                 .node_id = node_id_LDKPayer_jcall,
14801                 .first_hops = first_hops_LDKPayer_jcall,
14802                 .send_payment = send_payment_LDKPayer_jcall,
14803                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14804                 .retry_payment = retry_payment_LDKPayer_jcall,
14805                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14806                 .free = LDKPayer_JCalls_free,
14807         };
14808         return ret;
14809 }
14810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14811         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14812         *res_ptr = LDKPayer_init(env, clz, o);
14813         return tag_ptr(res_ptr, true);
14814 }
14815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14816         void* this_arg_ptr = untag_ptr(this_arg);
14817         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14818         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14819         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14821         return ret_arr;
14822 }
14823
14824 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14825         void* this_arg_ptr = untag_ptr(this_arg);
14826         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14827         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14828         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14829         int64_tArray ret_arr = NULL;
14830         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14831         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14832         for (size_t q = 0; q < ret_var.datalen; q++) {
14833                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14834                 int64_t ret_conv_16_ref = 0;
14835                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14836                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
14837                 ret_arr_ptr[q] = ret_conv_16_ref;
14838         }
14839         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14840         FREE(ret_var.data);
14841         return ret_arr;
14842 }
14843
14844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
14845         void* this_arg_ptr = untag_ptr(this_arg);
14846         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14847         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14848         LDKRoute route_conv;
14849         route_conv.inner = untag_ptr(route);
14850         route_conv.is_owned = ptr_is_owned(route);
14851         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14852         route_conv.is_owned = false;
14853         LDKThirtyTwoBytes payment_hash_ref;
14854         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14855         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14856         LDKThirtyTwoBytes payment_secret_ref;
14857         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14858         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14859         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14860         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14861         return tag_ptr(ret_conv, true);
14862 }
14863
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
14865         void* this_arg_ptr = untag_ptr(this_arg);
14866         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14867         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14868         LDKRoute route_conv;
14869         route_conv.inner = untag_ptr(route);
14870         route_conv.is_owned = ptr_is_owned(route);
14871         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14872         route_conv.is_owned = false;
14873         LDKThirtyTwoBytes payment_preimage_ref;
14874         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14875         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14876         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14877         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14878         return tag_ptr(ret_conv, true);
14879 }
14880
14881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
14882         void* this_arg_ptr = untag_ptr(this_arg);
14883         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14884         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14885         LDKRoute route_conv;
14886         route_conv.inner = untag_ptr(route);
14887         route_conv.is_owned = ptr_is_owned(route);
14888         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14889         route_conv.is_owned = false;
14890         LDKThirtyTwoBytes payment_id_ref;
14891         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14892         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14893         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14894         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14895         return tag_ptr(ret_conv, true);
14896 }
14897
14898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14899         void* this_arg_ptr = untag_ptr(this_arg);
14900         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14901         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14902         LDKThirtyTwoBytes payment_id_ref;
14903         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14904         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14905         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14906 }
14907
14908 typedef struct LDKRouter_JCalls {
14909         atomic_size_t refcnt;
14910         JavaVM *vm;
14911         jweak o;
14912         jmethodID find_route_meth;
14913         jmethodID notify_payment_path_failed_meth;
14914         jmethodID notify_payment_path_successful_meth;
14915         jmethodID notify_payment_probe_successful_meth;
14916         jmethodID notify_payment_probe_failed_meth;
14917 } LDKRouter_JCalls;
14918 static void LDKRouter_JCalls_free(void* this_arg) {
14919         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14920         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14921                 JNIEnv *env;
14922                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14923                 if (get_jenv_res == JNI_EDETACHED) {
14924                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14925                 } else {
14926                         DO_ASSERT(get_jenv_res == JNI_OK);
14927                 }
14928                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14929                 if (get_jenv_res == JNI_EDETACHED) {
14930                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14931                 }
14932                 FREE(j_calls);
14933         }
14934 }
14935 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
14936         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14937         JNIEnv *env;
14938         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14939         if (get_jenv_res == JNI_EDETACHED) {
14940                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14941         } else {
14942                 DO_ASSERT(get_jenv_res == JNI_OK);
14943         }
14944         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14945         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14946         LDKRouteParameters route_params_var = *route_params;
14947         int64_t route_params_ref = 0;
14948         route_params_var = RouteParameters_clone(&route_params_var);
14949         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14950         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14951         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14952         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14953         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14954         int64_tArray first_hops_arr = NULL;
14955         if (first_hops != NULL) {
14956                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14957                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14958                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14959                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14960                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14961                         int64_t first_hops_conv_16_ref = 0;
14962                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14963                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14964                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14965                 }
14966                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14967         }
14968         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14969         int64_t inflight_htlcs_ref = 0;
14970         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14971         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14973         CHECK(obj != NULL);
14974         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, inflight_htlcs_ref);
14975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14976                 (*env)->ExceptionDescribe(env);
14977                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14978         }
14979         void* ret_ptr = untag_ptr(ret);
14980         CHECK_ACCESS(ret_ptr);
14981         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14982         FREE(untag_ptr(ret));
14983         if (get_jenv_res == JNI_EDETACHED) {
14984                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14985         }
14986         return ret_conv;
14987 }
14988 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14989         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14990         JNIEnv *env;
14991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14992         if (get_jenv_res == JNI_EDETACHED) {
14993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14994         } else {
14995                 DO_ASSERT(get_jenv_res == JNI_OK);
14996         }
14997         LDKCVec_RouteHopZ path_var = path;
14998         int64_tArray path_arr = NULL;
14999         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15000         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15001         for (size_t k = 0; k < path_var.datalen; k++) {
15002                 LDKRouteHop path_conv_10_var = path_var.data[k];
15003                 int64_t path_conv_10_ref = 0;
15004                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15005                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15006                 path_arr_ptr[k] = path_conv_10_ref;
15007         }
15008         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15009         FREE(path_var.data);
15010         int64_t short_channel_id_conv = short_channel_id;
15011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15012         CHECK(obj != NULL);
15013         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
15014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15015                 (*env)->ExceptionDescribe(env);
15016                 (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
15017         }
15018         if (get_jenv_res == JNI_EDETACHED) {
15019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15020         }
15021 }
15022 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
15023         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15024         JNIEnv *env;
15025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15026         if (get_jenv_res == JNI_EDETACHED) {
15027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15028         } else {
15029                 DO_ASSERT(get_jenv_res == JNI_OK);
15030         }
15031         LDKCVec_RouteHopZ path_var = path;
15032         int64_tArray path_arr = NULL;
15033         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15034         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15035         for (size_t k = 0; k < path_var.datalen; k++) {
15036                 LDKRouteHop path_conv_10_var = path_var.data[k];
15037                 int64_t path_conv_10_ref = 0;
15038                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15039                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15040                 path_arr_ptr[k] = path_conv_10_ref;
15041         }
15042         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15043         FREE(path_var.data);
15044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15045         CHECK(obj != NULL);
15046         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_successful_meth, path_arr);
15047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15048                 (*env)->ExceptionDescribe(env);
15049                 (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
15050         }
15051         if (get_jenv_res == JNI_EDETACHED) {
15052                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15053         }
15054 }
15055 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
15056         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15057         JNIEnv *env;
15058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15059         if (get_jenv_res == JNI_EDETACHED) {
15060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15061         } else {
15062                 DO_ASSERT(get_jenv_res == JNI_OK);
15063         }
15064         LDKCVec_RouteHopZ path_var = path;
15065         int64_tArray path_arr = NULL;
15066         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15067         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15068         for (size_t k = 0; k < path_var.datalen; k++) {
15069                 LDKRouteHop path_conv_10_var = path_var.data[k];
15070                 int64_t path_conv_10_ref = 0;
15071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15072                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15073                 path_arr_ptr[k] = path_conv_10_ref;
15074         }
15075         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15076         FREE(path_var.data);
15077         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15078         CHECK(obj != NULL);
15079         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_successful_meth, path_arr);
15080         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15081                 (*env)->ExceptionDescribe(env);
15082                 (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
15083         }
15084         if (get_jenv_res == JNI_EDETACHED) {
15085                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15086         }
15087 }
15088 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
15089         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15090         JNIEnv *env;
15091         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15092         if (get_jenv_res == JNI_EDETACHED) {
15093                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15094         } else {
15095                 DO_ASSERT(get_jenv_res == JNI_OK);
15096         }
15097         LDKCVec_RouteHopZ path_var = path;
15098         int64_tArray path_arr = NULL;
15099         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15100         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15101         for (size_t k = 0; k < path_var.datalen; k++) {
15102                 LDKRouteHop path_conv_10_var = path_var.data[k];
15103                 int64_t path_conv_10_ref = 0;
15104                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15105                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15106                 path_arr_ptr[k] = path_conv_10_ref;
15107         }
15108         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15109         FREE(path_var.data);
15110         int64_t short_channel_id_conv = short_channel_id;
15111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15112         CHECK(obj != NULL);
15113         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
15114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15115                 (*env)->ExceptionDescribe(env);
15116                 (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
15117         }
15118         if (get_jenv_res == JNI_EDETACHED) {
15119                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15120         }
15121 }
15122 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
15123         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
15124         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15125 }
15126 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
15127         jclass c = (*env)->GetObjectClass(env, o);
15128         CHECK(c != NULL);
15129         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
15130         atomic_init(&calls->refcnt, 1);
15131         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15132         calls->o = (*env)->NewWeakGlobalRef(env, o);
15133         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
15134         CHECK(calls->find_route_meth != NULL);
15135         calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
15136         CHECK(calls->notify_payment_path_failed_meth != NULL);
15137         calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
15138         CHECK(calls->notify_payment_path_successful_meth != NULL);
15139         calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
15140         CHECK(calls->notify_payment_probe_successful_meth != NULL);
15141         calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
15142         CHECK(calls->notify_payment_probe_failed_meth != NULL);
15143
15144         LDKRouter ret = {
15145                 .this_arg = (void*) calls,
15146                 .find_route = find_route_LDKRouter_jcall,
15147                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
15148                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
15149                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
15150                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
15151                 .free = LDKRouter_JCalls_free,
15152         };
15153         return ret;
15154 }
15155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
15156         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
15157         *res_ptr = LDKRouter_init(env, clz, o);
15158         return tag_ptr(res_ptr, true);
15159 }
15160 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, int8_tArray payment_hash, int64_tArray first_hops, int64_t inflight_htlcs) {
15161         void* this_arg_ptr = untag_ptr(this_arg);
15162         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15163         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15164         LDKPublicKey payer_ref;
15165         CHECK((*env)->GetArrayLength(env, payer) == 33);
15166         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15167         LDKRouteParameters route_params_conv;
15168         route_params_conv.inner = untag_ptr(route_params);
15169         route_params_conv.is_owned = ptr_is_owned(route_params);
15170         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15171         route_params_conv.is_owned = false;
15172         unsigned char payment_hash_arr[32];
15173         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15174         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
15175         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15176         LDKCVec_ChannelDetailsZ first_hops_constr;
15177         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15178         if (first_hops != NULL) {
15179                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15180                 if (first_hops_constr.datalen > 0)
15181                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15182                 else
15183                         first_hops_constr.data = NULL;
15184                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15185                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15186                         int64_t first_hops_conv_16 = first_hops_vals[q];
15187                         LDKChannelDetails first_hops_conv_16_conv;
15188                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15189                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15190                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15191                         first_hops_conv_16_conv.is_owned = false;
15192                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15193                 }
15194                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15195                 first_hops_ptr = &first_hops_constr;
15196         }
15197         LDKInFlightHtlcs inflight_htlcs_conv;
15198         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15199         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15200         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15201         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
15202         
15203         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15204         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, inflight_htlcs_conv);
15205         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15206         return tag_ptr(ret_conv, true);
15207 }
15208
15209 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) {
15210         void* this_arg_ptr = untag_ptr(this_arg);
15211         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15212         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15213         LDKCVec_RouteHopZ path_constr;
15214         path_constr.datalen = (*env)->GetArrayLength(env, path);
15215         if (path_constr.datalen > 0)
15216                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15217         else
15218                 path_constr.data = NULL;
15219         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15220         for (size_t k = 0; k < path_constr.datalen; k++) {
15221                 int64_t path_conv_10 = path_vals[k];
15222                 LDKRouteHop path_conv_10_conv;
15223                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15224                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15226                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15227                 path_constr.data[k] = path_conv_10_conv;
15228         }
15229         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15230         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15231 }
15232
15233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15234         void* this_arg_ptr = untag_ptr(this_arg);
15235         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15236         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15237         LDKCVec_RouteHopZ path_constr;
15238         path_constr.datalen = (*env)->GetArrayLength(env, path);
15239         if (path_constr.datalen > 0)
15240                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15241         else
15242                 path_constr.data = NULL;
15243         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15244         for (size_t k = 0; k < path_constr.datalen; k++) {
15245                 int64_t path_conv_10 = path_vals[k];
15246                 LDKRouteHop path_conv_10_conv;
15247                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15248                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15249                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15250                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15251                 path_constr.data[k] = path_conv_10_conv;
15252         }
15253         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15254         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
15255 }
15256
15257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15258         void* this_arg_ptr = untag_ptr(this_arg);
15259         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15260         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15261         LDKCVec_RouteHopZ path_constr;
15262         path_constr.datalen = (*env)->GetArrayLength(env, path);
15263         if (path_constr.datalen > 0)
15264                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15265         else
15266                 path_constr.data = NULL;
15267         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15268         for (size_t k = 0; k < path_constr.datalen; k++) {
15269                 int64_t path_conv_10 = path_vals[k];
15270                 LDKRouteHop path_conv_10_conv;
15271                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15272                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15273                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15274                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15275                 path_constr.data[k] = path_conv_10_conv;
15276         }
15277         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15278         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
15279 }
15280
15281 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) {
15282         void* this_arg_ptr = untag_ptr(this_arg);
15283         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15284         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15285         LDKCVec_RouteHopZ path_constr;
15286         path_constr.datalen = (*env)->GetArrayLength(env, path);
15287         if (path_constr.datalen > 0)
15288                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15289         else
15290                 path_constr.data = NULL;
15291         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15292         for (size_t k = 0; k < path_constr.datalen; k++) {
15293                 int64_t path_conv_10 = path_vals[k];
15294                 LDKRouteHop path_conv_10_conv;
15295                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15296                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15297                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15298                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15299                 path_constr.data[k] = path_conv_10_conv;
15300         }
15301         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15302         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15303 }
15304
15305 static jclass LDKRetry_Attempts_class = NULL;
15306 static jmethodID LDKRetry_Attempts_meth = NULL;
15307 static jclass LDKRetry_Timeout_class = NULL;
15308 static jmethodID LDKRetry_Timeout_meth = NULL;
15309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
15310         LDKRetry_Attempts_class =
15311                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
15312         CHECK(LDKRetry_Attempts_class != NULL);
15313         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
15314         CHECK(LDKRetry_Attempts_meth != NULL);
15315         LDKRetry_Timeout_class =
15316                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
15317         CHECK(LDKRetry_Timeout_class != NULL);
15318         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
15319         CHECK(LDKRetry_Timeout_meth != NULL);
15320 }
15321 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15322         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
15323         switch(obj->tag) {
15324                 case LDKRetry_Attempts: {
15325                         int64_t attempts_conv = obj->attempts;
15326                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
15327                 }
15328                 case LDKRetry_Timeout: {
15329                         int64_t timeout_conv = obj->timeout;
15330                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
15331                 }
15332                 default: abort();
15333         }
15334 }
15335 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15336         LDKStr ret_str = _ldk_get_compiled_version();
15337         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15338         Str_free(ret_str);
15339         return ret_conv;
15340 }
15341
15342 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15343         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15344         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15345         Str_free(ret_str);
15346         return ret_conv;
15347 }
15348
15349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15350         LDKThirtyTwoBytes big_endian_bytes_ref;
15351         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15352         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15353         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15354         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15355         return tag_ptr(ret_ref, true);
15356 }
15357
15358 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15359         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15360         *ret_copy = Bech32Error_clone(arg);
15361         int64_t ret_ref = tag_ptr(ret_copy, true);
15362         return ret_ref;
15363 }
15364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15365         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15366         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15367         return ret_conv;
15368 }
15369
15370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15371         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15372         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15373         *ret_copy = Bech32Error_clone(orig_conv);
15374         int64_t ret_ref = tag_ptr(ret_copy, true);
15375         return ret_ref;
15376 }
15377
15378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15379         if (!ptr_is_owned(o)) return;
15380         void* o_ptr = untag_ptr(o);
15381         CHECK_ACCESS(o_ptr);
15382         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15383         FREE(untag_ptr(o));
15384         Bech32Error_free(o_conv);
15385 }
15386
15387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15388         LDKTransaction _res_ref;
15389         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15390         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15391         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15392         _res_ref.data_is_owned = true;
15393         Transaction_free(_res_ref);
15394 }
15395
15396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15397         LDKCVec_u8Z script_pubkey_ref;
15398         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15399         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15400         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15401         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15402         *ret_ref = TxOut_new(script_pubkey_ref, value);
15403         return tag_ptr(ret_ref, true);
15404 }
15405
15406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15407         if (!ptr_is_owned(_res)) return;
15408         void* _res_ptr = untag_ptr(_res);
15409         CHECK_ACCESS(_res_ptr);
15410         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15411         FREE(untag_ptr(_res));
15412         TxOut_free(_res_conv);
15413 }
15414
15415 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15416         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15417         *ret_ref = TxOut_clone(arg);
15418         return tag_ptr(ret_ref, true);
15419 }
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15421         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15422         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15423         return ret_conv;
15424 }
15425
15426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15427         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15428         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15429         *ret_ref = TxOut_clone(orig_conv);
15430         return tag_ptr(ret_ref, true);
15431 }
15432
15433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15434         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15435         Str_free(dummy);
15436 }
15437
15438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15439         LDKCVec_PublicKeyZ _res_constr;
15440         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15441         if (_res_constr.datalen > 0)
15442                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15443         else
15444                 _res_constr.data = NULL;
15445         for (size_t i = 0; i < _res_constr.datalen; i++) {
15446                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15447                 LDKPublicKey _res_conv_8_ref;
15448                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
15449                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
15450                 _res_constr.data[i] = _res_conv_8_ref;
15451         }
15452         CVec_PublicKeyZ_free(_res_constr);
15453 }
15454
15455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15456         LDKBlindedRoute o_conv;
15457         o_conv.inner = untag_ptr(o);
15458         o_conv.is_owned = ptr_is_owned(o);
15459         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15460         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15461         
15462         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15463         *ret_conv = CResult_BlindedRouteNoneZ_ok(o_conv);
15464         return tag_ptr(ret_conv, true);
15465 }
15466
15467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1err(JNIEnv *env, jclass clz) {
15468         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15469         *ret_conv = CResult_BlindedRouteNoneZ_err();
15470         return tag_ptr(ret_conv, true);
15471 }
15472
15473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15474         LDKCResult_BlindedRouteNoneZ* o_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(o);
15475         jboolean ret_conv = CResult_BlindedRouteNoneZ_is_ok(o_conv);
15476         return ret_conv;
15477 }
15478
15479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15480         if (!ptr_is_owned(_res)) return;
15481         void* _res_ptr = untag_ptr(_res);
15482         CHECK_ACCESS(_res_ptr);
15483         LDKCResult_BlindedRouteNoneZ _res_conv = *(LDKCResult_BlindedRouteNoneZ*)(_res_ptr);
15484         FREE(untag_ptr(_res));
15485         CResult_BlindedRouteNoneZ_free(_res_conv);
15486 }
15487
15488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15489         LDKBlindedRoute o_conv;
15490         o_conv.inner = untag_ptr(o);
15491         o_conv.is_owned = ptr_is_owned(o);
15492         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15493         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15494         
15495         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15496         *ret_conv = CResult_BlindedRouteDecodeErrorZ_ok(o_conv);
15497         return tag_ptr(ret_conv, true);
15498 }
15499
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15501         void* e_ptr = untag_ptr(e);
15502         CHECK_ACCESS(e_ptr);
15503         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15504         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15505         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15506         *ret_conv = CResult_BlindedRouteDecodeErrorZ_err(e_conv);
15507         return tag_ptr(ret_conv, true);
15508 }
15509
15510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15511         LDKCResult_BlindedRouteDecodeErrorZ* o_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(o);
15512         jboolean ret_conv = CResult_BlindedRouteDecodeErrorZ_is_ok(o_conv);
15513         return ret_conv;
15514 }
15515
15516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15517         if (!ptr_is_owned(_res)) return;
15518         void* _res_ptr = untag_ptr(_res);
15519         CHECK_ACCESS(_res_ptr);
15520         LDKCResult_BlindedRouteDecodeErrorZ _res_conv = *(LDKCResult_BlindedRouteDecodeErrorZ*)(_res_ptr);
15521         FREE(untag_ptr(_res));
15522         CResult_BlindedRouteDecodeErrorZ_free(_res_conv);
15523 }
15524
15525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15526         LDKBlindedHop o_conv;
15527         o_conv.inner = untag_ptr(o);
15528         o_conv.is_owned = ptr_is_owned(o);
15529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15530         // WARNING: we need a move here but no clone is available for LDKBlindedHop
15531         
15532         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15533         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
15534         return tag_ptr(ret_conv, true);
15535 }
15536
15537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15538         void* e_ptr = untag_ptr(e);
15539         CHECK_ACCESS(e_ptr);
15540         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15541         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15542         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15543         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
15544         return tag_ptr(ret_conv, true);
15545 }
15546
15547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15548         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
15549         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
15550         return ret_conv;
15551 }
15552
15553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15554         if (!ptr_is_owned(_res)) return;
15555         void* _res_ptr = untag_ptr(_res);
15556         CHECK_ACCESS(_res_ptr);
15557         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
15558         FREE(untag_ptr(_res));
15559         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
15560 }
15561
15562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15563         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15564         *ret_conv = CResult_NoneNoneZ_ok();
15565         return tag_ptr(ret_conv, true);
15566 }
15567
15568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15569         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15570         *ret_conv = CResult_NoneNoneZ_err();
15571         return tag_ptr(ret_conv, true);
15572 }
15573
15574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15575         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15576         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15577         return ret_conv;
15578 }
15579
15580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15581         if (!ptr_is_owned(_res)) return;
15582         void* _res_ptr = untag_ptr(_res);
15583         CHECK_ACCESS(_res_ptr);
15584         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15585         FREE(untag_ptr(_res));
15586         CResult_NoneNoneZ_free(_res_conv);
15587 }
15588
15589 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15590         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15591         *ret_conv = CResult_NoneNoneZ_clone(arg);
15592         return tag_ptr(ret_conv, true);
15593 }
15594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15595         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
15596         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
15597         return ret_conv;
15598 }
15599
15600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15601         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
15602         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15603         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15604         return tag_ptr(ret_conv, true);
15605 }
15606
15607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15608         LDKCounterpartyCommitmentSecrets o_conv;
15609         o_conv.inner = untag_ptr(o);
15610         o_conv.is_owned = ptr_is_owned(o);
15611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15612         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
15613         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15614         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
15615         return tag_ptr(ret_conv, true);
15616 }
15617
15618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15619         void* e_ptr = untag_ptr(e);
15620         CHECK_ACCESS(e_ptr);
15621         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15622         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15623         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15624         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
15625         return tag_ptr(ret_conv, true);
15626 }
15627
15628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15629         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
15630         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
15631         return ret_conv;
15632 }
15633
15634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15635         if (!ptr_is_owned(_res)) return;
15636         void* _res_ptr = untag_ptr(_res);
15637         CHECK_ACCESS(_res_ptr);
15638         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
15639         FREE(untag_ptr(_res));
15640         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
15641 }
15642
15643 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
15644         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15645         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
15646         return tag_ptr(ret_conv, true);
15647 }
15648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15649         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
15650         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
15651         return ret_conv;
15652 }
15653
15654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15655         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
15656         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15657         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15658         return tag_ptr(ret_conv, true);
15659 }
15660
15661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15662         LDKSecretKey o_ref;
15663         CHECK((*env)->GetArrayLength(env, o) == 32);
15664         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15665         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15666         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15667         return tag_ptr(ret_conv, true);
15668 }
15669
15670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15671         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15672         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15673         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15674         return tag_ptr(ret_conv, true);
15675 }
15676
15677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15678         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(o);
15679         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15680         return ret_conv;
15681 }
15682
15683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15684         if (!ptr_is_owned(_res)) return;
15685         void* _res_ptr = untag_ptr(_res);
15686         CHECK_ACCESS(_res_ptr);
15687         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15688         FREE(untag_ptr(_res));
15689         CResult_SecretKeyErrorZ_free(_res_conv);
15690 }
15691
15692 static inline uint64_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15693         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15694         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15695         return tag_ptr(ret_conv, true);
15696 }
15697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15698         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(arg);
15699         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15700         return ret_conv;
15701 }
15702
15703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15704         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(orig);
15705         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15706         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15707         return tag_ptr(ret_conv, true);
15708 }
15709
15710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15711         LDKPublicKey o_ref;
15712         CHECK((*env)->GetArrayLength(env, o) == 33);
15713         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15714         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15715         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15716         return tag_ptr(ret_conv, true);
15717 }
15718
15719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15720         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15721         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15722         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15723         return tag_ptr(ret_conv, true);
15724 }
15725
15726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15727         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
15728         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15729         return ret_conv;
15730 }
15731
15732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15733         if (!ptr_is_owned(_res)) return;
15734         void* _res_ptr = untag_ptr(_res);
15735         CHECK_ACCESS(_res_ptr);
15736         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15737         FREE(untag_ptr(_res));
15738         CResult_PublicKeyErrorZ_free(_res_conv);
15739 }
15740
15741 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15742         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15743         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15744         return tag_ptr(ret_conv, true);
15745 }
15746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15747         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
15748         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15749         return ret_conv;
15750 }
15751
15752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15753         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
15754         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15755         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15756         return tag_ptr(ret_conv, true);
15757 }
15758
15759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15760         LDKTxCreationKeys o_conv;
15761         o_conv.inner = untag_ptr(o);
15762         o_conv.is_owned = ptr_is_owned(o);
15763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15764         o_conv = TxCreationKeys_clone(&o_conv);
15765         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15766         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15767         return tag_ptr(ret_conv, true);
15768 }
15769
15770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15771         void* e_ptr = untag_ptr(e);
15772         CHECK_ACCESS(e_ptr);
15773         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15774         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15775         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15776         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15777         return tag_ptr(ret_conv, true);
15778 }
15779
15780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15781         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
15782         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15783         return ret_conv;
15784 }
15785
15786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15787         if (!ptr_is_owned(_res)) return;
15788         void* _res_ptr = untag_ptr(_res);
15789         CHECK_ACCESS(_res_ptr);
15790         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15791         FREE(untag_ptr(_res));
15792         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15793 }
15794
15795 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15796         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15797         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15798         return tag_ptr(ret_conv, true);
15799 }
15800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15801         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
15802         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15803         return ret_conv;
15804 }
15805
15806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15807         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
15808         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15809         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15810         return tag_ptr(ret_conv, true);
15811 }
15812
15813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15814         LDKChannelPublicKeys o_conv;
15815         o_conv.inner = untag_ptr(o);
15816         o_conv.is_owned = ptr_is_owned(o);
15817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15818         o_conv = ChannelPublicKeys_clone(&o_conv);
15819         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15820         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15821         return tag_ptr(ret_conv, true);
15822 }
15823
15824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15825         void* e_ptr = untag_ptr(e);
15826         CHECK_ACCESS(e_ptr);
15827         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15828         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15829         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15830         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15831         return tag_ptr(ret_conv, true);
15832 }
15833
15834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15835         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
15836         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15837         return ret_conv;
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15841         if (!ptr_is_owned(_res)) return;
15842         void* _res_ptr = untag_ptr(_res);
15843         CHECK_ACCESS(_res_ptr);
15844         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15845         FREE(untag_ptr(_res));
15846         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15847 }
15848
15849 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15850         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15851         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15852         return tag_ptr(ret_conv, true);
15853 }
15854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15855         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
15856         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15857         return ret_conv;
15858 }
15859
15860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15861         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
15862         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15863         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15864         return tag_ptr(ret_conv, true);
15865 }
15866
15867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15868         LDKTxCreationKeys o_conv;
15869         o_conv.inner = untag_ptr(o);
15870         o_conv.is_owned = ptr_is_owned(o);
15871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15872         o_conv = TxCreationKeys_clone(&o_conv);
15873         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15874         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15875         return tag_ptr(ret_conv, true);
15876 }
15877
15878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15879         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15880         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15881         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15882         return tag_ptr(ret_conv, true);
15883 }
15884
15885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15886         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(o);
15887         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15888         return ret_conv;
15889 }
15890
15891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15892         if (!ptr_is_owned(_res)) return;
15893         void* _res_ptr = untag_ptr(_res);
15894         CHECK_ACCESS(_res_ptr);
15895         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15896         FREE(untag_ptr(_res));
15897         CResult_TxCreationKeysErrorZ_free(_res_conv);
15898 }
15899
15900 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15901         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15902         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15903         return tag_ptr(ret_conv, true);
15904 }
15905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15906         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(arg);
15907         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15908         return ret_conv;
15909 }
15910
15911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15912         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(orig);
15913         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15914         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15915         return tag_ptr(ret_conv, true);
15916 }
15917
15918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15919         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15920         *ret_copy = COption_u32Z_some(o);
15921         int64_t ret_ref = tag_ptr(ret_copy, true);
15922         return ret_ref;
15923 }
15924
15925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15926         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15927         *ret_copy = COption_u32Z_none();
15928         int64_t ret_ref = tag_ptr(ret_copy, true);
15929         return ret_ref;
15930 }
15931
15932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15933         if (!ptr_is_owned(_res)) return;
15934         void* _res_ptr = untag_ptr(_res);
15935         CHECK_ACCESS(_res_ptr);
15936         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15937         FREE(untag_ptr(_res));
15938         COption_u32Z_free(_res_conv);
15939 }
15940
15941 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15942         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15943         *ret_copy = COption_u32Z_clone(arg);
15944         int64_t ret_ref = tag_ptr(ret_copy, true);
15945         return ret_ref;
15946 }
15947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15948         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
15949         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15950         return ret_conv;
15951 }
15952
15953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15954         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
15955         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15956         *ret_copy = COption_u32Z_clone(orig_conv);
15957         int64_t ret_ref = tag_ptr(ret_copy, true);
15958         return ret_ref;
15959 }
15960
15961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15962         LDKHTLCOutputInCommitment o_conv;
15963         o_conv.inner = untag_ptr(o);
15964         o_conv.is_owned = ptr_is_owned(o);
15965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15966         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15967         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15968         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15969         return tag_ptr(ret_conv, true);
15970 }
15971
15972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15973         void* e_ptr = untag_ptr(e);
15974         CHECK_ACCESS(e_ptr);
15975         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15976         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15977         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15978         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15979         return tag_ptr(ret_conv, true);
15980 }
15981
15982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15983         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
15984         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15985         return ret_conv;
15986 }
15987
15988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15989         if (!ptr_is_owned(_res)) return;
15990         void* _res_ptr = untag_ptr(_res);
15991         CHECK_ACCESS(_res_ptr);
15992         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15993         FREE(untag_ptr(_res));
15994         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15995 }
15996
15997 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15998         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15999         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16000         return tag_ptr(ret_conv, true);
16001 }
16002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16003         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16004         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16005         return ret_conv;
16006 }
16007
16008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16009         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16010         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16011         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16012         return tag_ptr(ret_conv, true);
16013 }
16014
16015 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16016         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16017         return ret_conv;
16018 }
16019
16020 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16021         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16022         return ret_conv;
16023 }
16024
16025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16026         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16027         COption_NoneZ_free(_res_conv);
16028 }
16029
16030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16031         LDKCounterpartyChannelTransactionParameters o_conv;
16032         o_conv.inner = untag_ptr(o);
16033         o_conv.is_owned = ptr_is_owned(o);
16034         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16035         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16036         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16037         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16038         return tag_ptr(ret_conv, true);
16039 }
16040
16041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16042         void* e_ptr = untag_ptr(e);
16043         CHECK_ACCESS(e_ptr);
16044         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16045         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16046         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16047         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16048         return tag_ptr(ret_conv, true);
16049 }
16050
16051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16052         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16053         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16054         return ret_conv;
16055 }
16056
16057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16058         if (!ptr_is_owned(_res)) return;
16059         void* _res_ptr = untag_ptr(_res);
16060         CHECK_ACCESS(_res_ptr);
16061         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16062         FREE(untag_ptr(_res));
16063         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16064 }
16065
16066 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16067         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16068         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16069         return tag_ptr(ret_conv, true);
16070 }
16071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16072         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16073         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16074         return ret_conv;
16075 }
16076
16077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16078         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16079         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16080         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16081         return tag_ptr(ret_conv, true);
16082 }
16083
16084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16085         LDKChannelTransactionParameters o_conv;
16086         o_conv.inner = untag_ptr(o);
16087         o_conv.is_owned = ptr_is_owned(o);
16088         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16089         o_conv = ChannelTransactionParameters_clone(&o_conv);
16090         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16091         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16092         return tag_ptr(ret_conv, true);
16093 }
16094
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16096         void* e_ptr = untag_ptr(e);
16097         CHECK_ACCESS(e_ptr);
16098         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16099         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16100         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16101         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16102         return tag_ptr(ret_conv, true);
16103 }
16104
16105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16106         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16107         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16108         return ret_conv;
16109 }
16110
16111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16112         if (!ptr_is_owned(_res)) return;
16113         void* _res_ptr = untag_ptr(_res);
16114         CHECK_ACCESS(_res_ptr);
16115         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16116         FREE(untag_ptr(_res));
16117         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16118 }
16119
16120 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16121         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16122         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16123         return tag_ptr(ret_conv, true);
16124 }
16125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16126         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16127         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16128         return ret_conv;
16129 }
16130
16131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16132         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16133         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16134         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16135         return tag_ptr(ret_conv, true);
16136 }
16137
16138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16139         LDKCVec_SignatureZ _res_constr;
16140         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16141         if (_res_constr.datalen > 0)
16142                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16143         else
16144                 _res_constr.data = NULL;
16145         for (size_t i = 0; i < _res_constr.datalen; i++) {
16146                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16147                 LDKSignature _res_conv_8_ref;
16148                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16149                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16150                 _res_constr.data[i] = _res_conv_8_ref;
16151         }
16152         CVec_SignatureZ_free(_res_constr);
16153 }
16154
16155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16156         LDKHolderCommitmentTransaction o_conv;
16157         o_conv.inner = untag_ptr(o);
16158         o_conv.is_owned = ptr_is_owned(o);
16159         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16160         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16161         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16162         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16163         return tag_ptr(ret_conv, true);
16164 }
16165
16166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16167         void* e_ptr = untag_ptr(e);
16168         CHECK_ACCESS(e_ptr);
16169         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16170         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16171         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16172         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16173         return tag_ptr(ret_conv, true);
16174 }
16175
16176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16177         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16178         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16179         return ret_conv;
16180 }
16181
16182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16183         if (!ptr_is_owned(_res)) return;
16184         void* _res_ptr = untag_ptr(_res);
16185         CHECK_ACCESS(_res_ptr);
16186         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16187         FREE(untag_ptr(_res));
16188         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16189 }
16190
16191 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16192         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16193         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16194         return tag_ptr(ret_conv, true);
16195 }
16196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16197         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16198         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16199         return ret_conv;
16200 }
16201
16202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16203         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16204         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16205         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16206         return tag_ptr(ret_conv, true);
16207 }
16208
16209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16210         LDKBuiltCommitmentTransaction o_conv;
16211         o_conv.inner = untag_ptr(o);
16212         o_conv.is_owned = ptr_is_owned(o);
16213         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16214         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16215         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16216         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16217         return tag_ptr(ret_conv, true);
16218 }
16219
16220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16221         void* e_ptr = untag_ptr(e);
16222         CHECK_ACCESS(e_ptr);
16223         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16224         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16225         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16226         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
16227         return tag_ptr(ret_conv, true);
16228 }
16229
16230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16231         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16232         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16233         return ret_conv;
16234 }
16235
16236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16237         if (!ptr_is_owned(_res)) return;
16238         void* _res_ptr = untag_ptr(_res);
16239         CHECK_ACCESS(_res_ptr);
16240         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16241         FREE(untag_ptr(_res));
16242         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
16243 }
16244
16245 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16246         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16247         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
16248         return tag_ptr(ret_conv, true);
16249 }
16250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16251         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16252         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16253         return ret_conv;
16254 }
16255
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16257         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16258         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16259         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16260         return tag_ptr(ret_conv, true);
16261 }
16262
16263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16264         LDKTrustedClosingTransaction o_conv;
16265         o_conv.inner = untag_ptr(o);
16266         o_conv.is_owned = ptr_is_owned(o);
16267         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16268         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
16269         
16270         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16271         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
16272         return tag_ptr(ret_conv, true);
16273 }
16274
16275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16276         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16277         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
16278         return tag_ptr(ret_conv, true);
16279 }
16280
16281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16282         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
16283         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
16284         return ret_conv;
16285 }
16286
16287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16288         if (!ptr_is_owned(_res)) return;
16289         void* _res_ptr = untag_ptr(_res);
16290         CHECK_ACCESS(_res_ptr);
16291         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
16292         FREE(untag_ptr(_res));
16293         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
16294 }
16295
16296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16297         LDKCommitmentTransaction o_conv;
16298         o_conv.inner = untag_ptr(o);
16299         o_conv.is_owned = ptr_is_owned(o);
16300         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16301         o_conv = CommitmentTransaction_clone(&o_conv);
16302         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16303         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16304         return tag_ptr(ret_conv, true);
16305 }
16306
16307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16308         void* e_ptr = untag_ptr(e);
16309         CHECK_ACCESS(e_ptr);
16310         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16311         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16312         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16313         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16314         return tag_ptr(ret_conv, true);
16315 }
16316
16317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16318         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16319         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16320         return ret_conv;
16321 }
16322
16323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16324         if (!ptr_is_owned(_res)) return;
16325         void* _res_ptr = untag_ptr(_res);
16326         CHECK_ACCESS(_res_ptr);
16327         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16328         FREE(untag_ptr(_res));
16329         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16330 }
16331
16332 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16333         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16334         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16335         return tag_ptr(ret_conv, true);
16336 }
16337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16338         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16339         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16340         return ret_conv;
16341 }
16342
16343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16344         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16345         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16346         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16347         return tag_ptr(ret_conv, true);
16348 }
16349
16350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16351         LDKTrustedCommitmentTransaction o_conv;
16352         o_conv.inner = untag_ptr(o);
16353         o_conv.is_owned = ptr_is_owned(o);
16354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16355         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16356         
16357         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16358         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16359         return tag_ptr(ret_conv, true);
16360 }
16361
16362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16363         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16364         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16365         return tag_ptr(ret_conv, true);
16366 }
16367
16368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16369         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16370         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16371         return ret_conv;
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16375         if (!ptr_is_owned(_res)) return;
16376         void* _res_ptr = untag_ptr(_res);
16377         CHECK_ACCESS(_res_ptr);
16378         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16379         FREE(untag_ptr(_res));
16380         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16384         LDKCVec_SignatureZ o_constr;
16385         o_constr.datalen = (*env)->GetArrayLength(env, o);
16386         if (o_constr.datalen > 0)
16387                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16388         else
16389                 o_constr.data = NULL;
16390         for (size_t i = 0; i < o_constr.datalen; i++) {
16391                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16392                 LDKSignature o_conv_8_ref;
16393                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16394                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16395                 o_constr.data[i] = o_conv_8_ref;
16396         }
16397         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16398         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16399         return tag_ptr(ret_conv, true);
16400 }
16401
16402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16403         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16404         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16405         return tag_ptr(ret_conv, true);
16406 }
16407
16408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16409         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16410         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16411         return ret_conv;
16412 }
16413
16414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16415         if (!ptr_is_owned(_res)) return;
16416         void* _res_ptr = untag_ptr(_res);
16417         CHECK_ACCESS(_res_ptr);
16418         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16419         FREE(untag_ptr(_res));
16420         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16421 }
16422
16423 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16424         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16425         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16426         return tag_ptr(ret_conv, true);
16427 }
16428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16429         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16430         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16431         return ret_conv;
16432 }
16433
16434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16435         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16436         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16437         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16438         return tag_ptr(ret_conv, true);
16439 }
16440
16441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16442         LDKShutdownScript o_conv;
16443         o_conv.inner = untag_ptr(o);
16444         o_conv.is_owned = ptr_is_owned(o);
16445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16446         o_conv = ShutdownScript_clone(&o_conv);
16447         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16448         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16449         return tag_ptr(ret_conv, true);
16450 }
16451
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16453         void* e_ptr = untag_ptr(e);
16454         CHECK_ACCESS(e_ptr);
16455         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16456         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16457         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16458         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16459         return tag_ptr(ret_conv, true);
16460 }
16461
16462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16463         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16464         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16465         return ret_conv;
16466 }
16467
16468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16469         if (!ptr_is_owned(_res)) return;
16470         void* _res_ptr = untag_ptr(_res);
16471         CHECK_ACCESS(_res_ptr);
16472         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16473         FREE(untag_ptr(_res));
16474         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16475 }
16476
16477 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16478         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16479         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16480         return tag_ptr(ret_conv, true);
16481 }
16482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16483         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16484         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16485         return ret_conv;
16486 }
16487
16488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16489         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16490         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16491         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16492         return tag_ptr(ret_conv, true);
16493 }
16494
16495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16496         LDKShutdownScript o_conv;
16497         o_conv.inner = untag_ptr(o);
16498         o_conv.is_owned = ptr_is_owned(o);
16499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16500         o_conv = ShutdownScript_clone(&o_conv);
16501         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16502         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16503         return tag_ptr(ret_conv, true);
16504 }
16505
16506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16507         LDKInvalidShutdownScript e_conv;
16508         e_conv.inner = untag_ptr(e);
16509         e_conv.is_owned = ptr_is_owned(e);
16510         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16511         e_conv = InvalidShutdownScript_clone(&e_conv);
16512         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16513         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16514         return tag_ptr(ret_conv, true);
16515 }
16516
16517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16518         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16519         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16520         return ret_conv;
16521 }
16522
16523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16524         if (!ptr_is_owned(_res)) return;
16525         void* _res_ptr = untag_ptr(_res);
16526         CHECK_ACCESS(_res_ptr);
16527         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16528         FREE(untag_ptr(_res));
16529         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16530 }
16531
16532 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16533         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16534         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16535         return tag_ptr(ret_conv, true);
16536 }
16537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16538         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16539         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16540         return ret_conv;
16541 }
16542
16543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16544         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16545         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16546         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16547         return tag_ptr(ret_conv, true);
16548 }
16549
16550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16551         void* o_ptr = untag_ptr(o);
16552         CHECK_ACCESS(o_ptr);
16553         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16554         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16556                 LDKWriteableScore_JCalls_cloned(&o_conv);
16557         }
16558         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16559         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16560         int64_t ret_ref = tag_ptr(ret_copy, true);
16561         return ret_ref;
16562 }
16563
16564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
16565         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16566         *ret_copy = COption_WriteableScoreZ_none();
16567         int64_t ret_ref = tag_ptr(ret_copy, true);
16568         return ret_ref;
16569 }
16570
16571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16572         if (!ptr_is_owned(_res)) return;
16573         void* _res_ptr = untag_ptr(_res);
16574         CHECK_ACCESS(_res_ptr);
16575         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
16576         FREE(untag_ptr(_res));
16577         COption_WriteableScoreZ_free(_res_conv);
16578 }
16579
16580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
16581         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16582         *ret_conv = CResult_NoneErrorZ_ok();
16583         return tag_ptr(ret_conv, true);
16584 }
16585
16586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16587         LDKIOError e_conv = LDKIOError_from_java(env, e);
16588         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16589         *ret_conv = CResult_NoneErrorZ_err(e_conv);
16590         return tag_ptr(ret_conv, true);
16591 }
16592
16593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16594         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
16595         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
16596         return ret_conv;
16597 }
16598
16599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16600         if (!ptr_is_owned(_res)) return;
16601         void* _res_ptr = untag_ptr(_res);
16602         CHECK_ACCESS(_res_ptr);
16603         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
16604         FREE(untag_ptr(_res));
16605         CResult_NoneErrorZ_free(_res_conv);
16606 }
16607
16608 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
16609         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16610         *ret_conv = CResult_NoneErrorZ_clone(arg);
16611         return tag_ptr(ret_conv, true);
16612 }
16613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16614         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
16615         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
16616         return ret_conv;
16617 }
16618
16619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16620         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
16621         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16622         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
16623         return tag_ptr(ret_conv, true);
16624 }
16625
16626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16627         LDKRouteHop o_conv;
16628         o_conv.inner = untag_ptr(o);
16629         o_conv.is_owned = ptr_is_owned(o);
16630         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16631         o_conv = RouteHop_clone(&o_conv);
16632         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16633         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
16634         return tag_ptr(ret_conv, true);
16635 }
16636
16637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16638         void* e_ptr = untag_ptr(e);
16639         CHECK_ACCESS(e_ptr);
16640         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16641         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16642         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16643         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
16644         return tag_ptr(ret_conv, true);
16645 }
16646
16647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16648         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
16649         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
16650         return ret_conv;
16651 }
16652
16653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16654         if (!ptr_is_owned(_res)) return;
16655         void* _res_ptr = untag_ptr(_res);
16656         CHECK_ACCESS(_res_ptr);
16657         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
16658         FREE(untag_ptr(_res));
16659         CResult_RouteHopDecodeErrorZ_free(_res_conv);
16660 }
16661
16662 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
16663         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16664         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
16665         return tag_ptr(ret_conv, true);
16666 }
16667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16668         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
16669         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
16670         return ret_conv;
16671 }
16672
16673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16674         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
16675         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16676         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
16677         return tag_ptr(ret_conv, true);
16678 }
16679
16680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16681         LDKCVec_RouteHopZ _res_constr;
16682         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16683         if (_res_constr.datalen > 0)
16684                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16685         else
16686                 _res_constr.data = NULL;
16687         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16688         for (size_t k = 0; k < _res_constr.datalen; k++) {
16689                 int64_t _res_conv_10 = _res_vals[k];
16690                 LDKRouteHop _res_conv_10_conv;
16691                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
16692                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
16693                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16694                 _res_constr.data[k] = _res_conv_10_conv;
16695         }
16696         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16697         CVec_RouteHopZ_free(_res_constr);
16698 }
16699
16700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16701         LDKCVec_CVec_RouteHopZZ _res_constr;
16702         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16703         if (_res_constr.datalen > 0)
16704                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16705         else
16706                 _res_constr.data = NULL;
16707         for (size_t m = 0; m < _res_constr.datalen; m++) {
16708                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16709                 LDKCVec_RouteHopZ _res_conv_12_constr;
16710                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16711                 if (_res_conv_12_constr.datalen > 0)
16712                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16713                 else
16714                         _res_conv_12_constr.data = NULL;
16715                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16716                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16717                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16718                         LDKRouteHop _res_conv_12_conv_10_conv;
16719                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
16720                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
16721                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16722                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16723                 }
16724                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16725                 _res_constr.data[m] = _res_conv_12_constr;
16726         }
16727         CVec_CVec_RouteHopZZ_free(_res_constr);
16728 }
16729
16730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16731         LDKRoute o_conv;
16732         o_conv.inner = untag_ptr(o);
16733         o_conv.is_owned = ptr_is_owned(o);
16734         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16735         o_conv = Route_clone(&o_conv);
16736         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16737         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16738         return tag_ptr(ret_conv, true);
16739 }
16740
16741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16742         void* e_ptr = untag_ptr(e);
16743         CHECK_ACCESS(e_ptr);
16744         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16745         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16746         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16747         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16748         return tag_ptr(ret_conv, true);
16749 }
16750
16751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16752         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
16753         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16754         return ret_conv;
16755 }
16756
16757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16758         if (!ptr_is_owned(_res)) return;
16759         void* _res_ptr = untag_ptr(_res);
16760         CHECK_ACCESS(_res_ptr);
16761         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16762         FREE(untag_ptr(_res));
16763         CResult_RouteDecodeErrorZ_free(_res_conv);
16764 }
16765
16766 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16767         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16768         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16769         return tag_ptr(ret_conv, true);
16770 }
16771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16772         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
16773         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16774         return ret_conv;
16775 }
16776
16777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16778         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
16779         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16780         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16781         return tag_ptr(ret_conv, true);
16782 }
16783
16784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16785         LDKRouteParameters o_conv;
16786         o_conv.inner = untag_ptr(o);
16787         o_conv.is_owned = ptr_is_owned(o);
16788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16789         o_conv = RouteParameters_clone(&o_conv);
16790         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16791         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16792         return tag_ptr(ret_conv, true);
16793 }
16794
16795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16796         void* e_ptr = untag_ptr(e);
16797         CHECK_ACCESS(e_ptr);
16798         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16799         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16800         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16801         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16802         return tag_ptr(ret_conv, true);
16803 }
16804
16805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16806         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
16807         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16808         return ret_conv;
16809 }
16810
16811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16812         if (!ptr_is_owned(_res)) return;
16813         void* _res_ptr = untag_ptr(_res);
16814         CHECK_ACCESS(_res_ptr);
16815         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16816         FREE(untag_ptr(_res));
16817         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16818 }
16819
16820 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16821         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16822         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16823         return tag_ptr(ret_conv, true);
16824 }
16825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16826         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
16827         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16828         return ret_conv;
16829 }
16830
16831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16832         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
16833         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16834         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16835         return tag_ptr(ret_conv, true);
16836 }
16837
16838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16839         LDKCVec_RouteHintZ _res_constr;
16840         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16841         if (_res_constr.datalen > 0)
16842                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16843         else
16844                 _res_constr.data = NULL;
16845         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16846         for (size_t l = 0; l < _res_constr.datalen; l++) {
16847                 int64_t _res_conv_11 = _res_vals[l];
16848                 LDKRouteHint _res_conv_11_conv;
16849                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
16850                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
16851                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16852                 _res_constr.data[l] = _res_conv_11_conv;
16853         }
16854         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16855         CVec_RouteHintZ_free(_res_constr);
16856 }
16857
16858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16859         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16860         *ret_copy = COption_u64Z_some(o);
16861         int64_t ret_ref = tag_ptr(ret_copy, true);
16862         return ret_ref;
16863 }
16864
16865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16866         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16867         *ret_copy = COption_u64Z_none();
16868         int64_t ret_ref = tag_ptr(ret_copy, true);
16869         return ret_ref;
16870 }
16871
16872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16873         if (!ptr_is_owned(_res)) return;
16874         void* _res_ptr = untag_ptr(_res);
16875         CHECK_ACCESS(_res_ptr);
16876         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16877         FREE(untag_ptr(_res));
16878         COption_u64Z_free(_res_conv);
16879 }
16880
16881 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16882         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16883         *ret_copy = COption_u64Z_clone(arg);
16884         int64_t ret_ref = tag_ptr(ret_copy, true);
16885         return ret_ref;
16886 }
16887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16888         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
16889         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16890         return ret_conv;
16891 }
16892
16893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16894         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
16895         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16896         *ret_copy = COption_u64Z_clone(orig_conv);
16897         int64_t ret_ref = tag_ptr(ret_copy, true);
16898         return ret_ref;
16899 }
16900
16901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16902         LDKCVec_u64Z _res_constr;
16903         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16904         if (_res_constr.datalen > 0)
16905                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16906         else
16907                 _res_constr.data = NULL;
16908         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16909         for (size_t g = 0; g < _res_constr.datalen; g++) {
16910                 int64_t _res_conv_6 = _res_vals[g];
16911                 _res_constr.data[g] = _res_conv_6;
16912         }
16913         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16914         CVec_u64Z_free(_res_constr);
16915 }
16916
16917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16918         LDKPaymentParameters o_conv;
16919         o_conv.inner = untag_ptr(o);
16920         o_conv.is_owned = ptr_is_owned(o);
16921         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16922         o_conv = PaymentParameters_clone(&o_conv);
16923         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16924         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16925         return tag_ptr(ret_conv, true);
16926 }
16927
16928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16929         void* e_ptr = untag_ptr(e);
16930         CHECK_ACCESS(e_ptr);
16931         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16932         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16933         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16934         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16935         return tag_ptr(ret_conv, true);
16936 }
16937
16938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16939         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
16940         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16941         return ret_conv;
16942 }
16943
16944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16945         if (!ptr_is_owned(_res)) return;
16946         void* _res_ptr = untag_ptr(_res);
16947         CHECK_ACCESS(_res_ptr);
16948         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16949         FREE(untag_ptr(_res));
16950         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16951 }
16952
16953 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16954         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16955         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16956         return tag_ptr(ret_conv, true);
16957 }
16958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16959         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
16960         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16961         return ret_conv;
16962 }
16963
16964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16965         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
16966         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16967         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16968         return tag_ptr(ret_conv, true);
16969 }
16970
16971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16972         LDKCVec_RouteHintHopZ _res_constr;
16973         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16974         if (_res_constr.datalen > 0)
16975                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16976         else
16977                 _res_constr.data = NULL;
16978         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16979         for (size_t o = 0; o < _res_constr.datalen; o++) {
16980                 int64_t _res_conv_14 = _res_vals[o];
16981                 LDKRouteHintHop _res_conv_14_conv;
16982                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
16983                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
16984                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16985                 _res_constr.data[o] = _res_conv_14_conv;
16986         }
16987         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16988         CVec_RouteHintHopZ_free(_res_constr);
16989 }
16990
16991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16992         LDKRouteHint o_conv;
16993         o_conv.inner = untag_ptr(o);
16994         o_conv.is_owned = ptr_is_owned(o);
16995         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16996         o_conv = RouteHint_clone(&o_conv);
16997         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16998         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
16999         return tag_ptr(ret_conv, true);
17000 }
17001
17002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17003         void* e_ptr = untag_ptr(e);
17004         CHECK_ACCESS(e_ptr);
17005         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17006         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17007         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17008         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
17009         return tag_ptr(ret_conv, true);
17010 }
17011
17012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17013         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
17014         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
17015         return ret_conv;
17016 }
17017
17018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17019         if (!ptr_is_owned(_res)) return;
17020         void* _res_ptr = untag_ptr(_res);
17021         CHECK_ACCESS(_res_ptr);
17022         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
17023         FREE(untag_ptr(_res));
17024         CResult_RouteHintDecodeErrorZ_free(_res_conv);
17025 }
17026
17027 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
17028         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17029         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
17030         return tag_ptr(ret_conv, true);
17031 }
17032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17033         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
17034         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
17035         return ret_conv;
17036 }
17037
17038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17039         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
17040         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17041         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
17042         return tag_ptr(ret_conv, true);
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17046         LDKRouteHintHop o_conv;
17047         o_conv.inner = untag_ptr(o);
17048         o_conv.is_owned = ptr_is_owned(o);
17049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17050         o_conv = RouteHintHop_clone(&o_conv);
17051         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17052         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
17053         return tag_ptr(ret_conv, true);
17054 }
17055
17056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17057         void* e_ptr = untag_ptr(e);
17058         CHECK_ACCESS(e_ptr);
17059         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17060         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17061         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17062         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
17063         return tag_ptr(ret_conv, true);
17064 }
17065
17066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17067         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
17068         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
17069         return ret_conv;
17070 }
17071
17072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17073         if (!ptr_is_owned(_res)) return;
17074         void* _res_ptr = untag_ptr(_res);
17075         CHECK_ACCESS(_res_ptr);
17076         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
17077         FREE(untag_ptr(_res));
17078         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
17079 }
17080
17081 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
17082         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17083         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
17084         return tag_ptr(ret_conv, true);
17085 }
17086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17087         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
17088         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
17089         return ret_conv;
17090 }
17091
17092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17093         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
17094         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17095         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
17096         return tag_ptr(ret_conv, true);
17097 }
17098
17099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17100         LDKCVec_ChannelDetailsZ _res_constr;
17101         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17102         if (_res_constr.datalen > 0)
17103                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17104         else
17105                 _res_constr.data = NULL;
17106         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17107         for (size_t q = 0; q < _res_constr.datalen; q++) {
17108                 int64_t _res_conv_16 = _res_vals[q];
17109                 LDKChannelDetails _res_conv_16_conv;
17110                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17111                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17112                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17113                 _res_constr.data[q] = _res_conv_16_conv;
17114         }
17115         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17116         CVec_ChannelDetailsZ_free(_res_constr);
17117 }
17118
17119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17120         LDKRoute o_conv;
17121         o_conv.inner = untag_ptr(o);
17122         o_conv.is_owned = ptr_is_owned(o);
17123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17124         o_conv = Route_clone(&o_conv);
17125         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17126         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17127         return tag_ptr(ret_conv, true);
17128 }
17129
17130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17131         LDKLightningError e_conv;
17132         e_conv.inner = untag_ptr(e);
17133         e_conv.is_owned = ptr_is_owned(e);
17134         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17135         e_conv = LightningError_clone(&e_conv);
17136         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17137         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17138         return tag_ptr(ret_conv, true);
17139 }
17140
17141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17142         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17143         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17144         return ret_conv;
17145 }
17146
17147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17148         if (!ptr_is_owned(_res)) return;
17149         void* _res_ptr = untag_ptr(_res);
17150         CHECK_ACCESS(_res_ptr);
17151         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17152         FREE(untag_ptr(_res));
17153         CResult_RouteLightningErrorZ_free(_res_conv);
17154 }
17155
17156 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17157         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17158         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17159         return tag_ptr(ret_conv, true);
17160 }
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17162         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17163         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17164         return ret_conv;
17165 }
17166
17167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17168         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17169         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17170         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17171         return tag_ptr(ret_conv, true);
17172 }
17173
17174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17175         void* o_ptr = untag_ptr(o);
17176         CHECK_ACCESS(o_ptr);
17177         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
17178         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
17179         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17180         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
17181         return tag_ptr(ret_conv, true);
17182 }
17183
17184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17185         void* e_ptr = untag_ptr(e);
17186         CHECK_ACCESS(e_ptr);
17187         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17188         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17189         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17190         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
17191         return tag_ptr(ret_conv, true);
17192 }
17193
17194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17195         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
17196         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
17197         return ret_conv;
17198 }
17199
17200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17201         if (!ptr_is_owned(_res)) return;
17202         void* _res_ptr = untag_ptr(_res);
17203         CHECK_ACCESS(_res_ptr);
17204         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
17205         FREE(untag_ptr(_res));
17206         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
17207 }
17208
17209 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
17210         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17211         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
17212         return tag_ptr(ret_conv, true);
17213 }
17214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17215         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
17216         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
17217         return ret_conv;
17218 }
17219
17220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17221         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
17222         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17223         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
17224         return tag_ptr(ret_conv, true);
17225 }
17226
17227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17228         void* o_ptr = untag_ptr(o);
17229         CHECK_ACCESS(o_ptr);
17230         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
17231         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
17232         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17233         *ret_copy = COption_ClosureReasonZ_some(o_conv);
17234         int64_t ret_ref = tag_ptr(ret_copy, true);
17235         return ret_ref;
17236 }
17237
17238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
17239         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17240         *ret_copy = COption_ClosureReasonZ_none();
17241         int64_t ret_ref = tag_ptr(ret_copy, true);
17242         return ret_ref;
17243 }
17244
17245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17246         if (!ptr_is_owned(_res)) return;
17247         void* _res_ptr = untag_ptr(_res);
17248         CHECK_ACCESS(_res_ptr);
17249         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
17250         FREE(untag_ptr(_res));
17251         COption_ClosureReasonZ_free(_res_conv);
17252 }
17253
17254 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
17255         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17256         *ret_copy = COption_ClosureReasonZ_clone(arg);
17257         int64_t ret_ref = tag_ptr(ret_copy, true);
17258         return ret_ref;
17259 }
17260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17261         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
17262         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
17263         return ret_conv;
17264 }
17265
17266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17267         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
17268         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17269         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
17270         int64_t ret_ref = tag_ptr(ret_copy, true);
17271         return ret_ref;
17272 }
17273
17274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17275         void* o_ptr = untag_ptr(o);
17276         CHECK_ACCESS(o_ptr);
17277         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
17278         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
17279         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17280         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
17281         return tag_ptr(ret_conv, true);
17282 }
17283
17284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17285         void* e_ptr = untag_ptr(e);
17286         CHECK_ACCESS(e_ptr);
17287         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17288         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17289         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17290         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17291         return tag_ptr(ret_conv, true);
17292 }
17293
17294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17295         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17296         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17297         return ret_conv;
17298 }
17299
17300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17301         if (!ptr_is_owned(_res)) return;
17302         void* _res_ptr = untag_ptr(_res);
17303         CHECK_ACCESS(_res_ptr);
17304         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17305         FREE(untag_ptr(_res));
17306         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17307 }
17308
17309 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17310         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17311         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17312         return tag_ptr(ret_conv, true);
17313 }
17314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17315         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17316         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17317         return ret_conv;
17318 }
17319
17320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17321         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17322         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17323         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17324         return tag_ptr(ret_conv, true);
17325 }
17326
17327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17328         void* o_ptr = untag_ptr(o);
17329         CHECK_ACCESS(o_ptr);
17330         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17331         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17332         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17333         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17334         int64_t ret_ref = tag_ptr(ret_copy, true);
17335         return ret_ref;
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17339         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17340         *ret_copy = COption_HTLCDestinationZ_none();
17341         int64_t ret_ref = tag_ptr(ret_copy, true);
17342         return ret_ref;
17343 }
17344
17345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17346         if (!ptr_is_owned(_res)) return;
17347         void* _res_ptr = untag_ptr(_res);
17348         CHECK_ACCESS(_res_ptr);
17349         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17350         FREE(untag_ptr(_res));
17351         COption_HTLCDestinationZ_free(_res_conv);
17352 }
17353
17354 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17355         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17356         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17357         int64_t ret_ref = tag_ptr(ret_copy, true);
17358         return ret_ref;
17359 }
17360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17361         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17362         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
17363         return ret_conv;
17364 }
17365
17366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17367         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
17368         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17369         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
17370         int64_t ret_ref = tag_ptr(ret_copy, true);
17371         return ret_ref;
17372 }
17373
17374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17375         void* o_ptr = untag_ptr(o);
17376         CHECK_ACCESS(o_ptr);
17377         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
17378         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
17379         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17380         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
17381         return tag_ptr(ret_conv, true);
17382 }
17383
17384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17385         void* e_ptr = untag_ptr(e);
17386         CHECK_ACCESS(e_ptr);
17387         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17388         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17389         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17390         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
17391         return tag_ptr(ret_conv, true);
17392 }
17393
17394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17395         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
17396         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
17397         return ret_conv;
17398 }
17399
17400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17401         if (!ptr_is_owned(_res)) return;
17402         void* _res_ptr = untag_ptr(_res);
17403         CHECK_ACCESS(_res_ptr);
17404         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
17405         FREE(untag_ptr(_res));
17406         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
17407 }
17408
17409 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
17410         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17411         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
17412         return tag_ptr(ret_conv, true);
17413 }
17414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17415         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
17416         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
17417         return ret_conv;
17418 }
17419
17420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17421         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
17422         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17423         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
17424         return tag_ptr(ret_conv, true);
17425 }
17426
17427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17428         void* o_ptr = untag_ptr(o);
17429         CHECK_ACCESS(o_ptr);
17430         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17431         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17432         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17433         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17434         int64_t ret_ref = tag_ptr(ret_copy, true);
17435         return ret_ref;
17436 }
17437
17438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17439         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17440         *ret_copy = COption_NetworkUpdateZ_none();
17441         int64_t ret_ref = tag_ptr(ret_copy, true);
17442         return ret_ref;
17443 }
17444
17445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17446         if (!ptr_is_owned(_res)) return;
17447         void* _res_ptr = untag_ptr(_res);
17448         CHECK_ACCESS(_res_ptr);
17449         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17450         FREE(untag_ptr(_res));
17451         COption_NetworkUpdateZ_free(_res_conv);
17452 }
17453
17454 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17455         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17456         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17457         int64_t ret_ref = tag_ptr(ret_copy, true);
17458         return ret_ref;
17459 }
17460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17461         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17462         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17463         return ret_conv;
17464 }
17465
17466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17467         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17468         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17469         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17470         int64_t ret_ref = tag_ptr(ret_copy, true);
17471         return ret_ref;
17472 }
17473
17474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17475         LDKCVec_SpendableOutputDescriptorZ _res_constr;
17476         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17477         if (_res_constr.datalen > 0)
17478                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17479         else
17480                 _res_constr.data = NULL;
17481         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17482         for (size_t b = 0; b < _res_constr.datalen; b++) {
17483                 int64_t _res_conv_27 = _res_vals[b];
17484                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
17485                 CHECK_ACCESS(_res_conv_27_ptr);
17486                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
17487                 FREE(untag_ptr(_res_conv_27));
17488                 _res_constr.data[b] = _res_conv_27_conv;
17489         }
17490         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17491         CVec_SpendableOutputDescriptorZ_free(_res_constr);
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17495         void* o_ptr = untag_ptr(o);
17496         CHECK_ACCESS(o_ptr);
17497         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
17498         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
17499         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17500         *ret_copy = COption_EventZ_some(o_conv);
17501         int64_t ret_ref = tag_ptr(ret_copy, true);
17502         return ret_ref;
17503 }
17504
17505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
17506         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17507         *ret_copy = COption_EventZ_none();
17508         int64_t ret_ref = tag_ptr(ret_copy, true);
17509         return ret_ref;
17510 }
17511
17512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17513         if (!ptr_is_owned(_res)) return;
17514         void* _res_ptr = untag_ptr(_res);
17515         CHECK_ACCESS(_res_ptr);
17516         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
17517         FREE(untag_ptr(_res));
17518         COption_EventZ_free(_res_conv);
17519 }
17520
17521 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
17522         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17523         *ret_copy = COption_EventZ_clone(arg);
17524         int64_t ret_ref = tag_ptr(ret_copy, true);
17525         return ret_ref;
17526 }
17527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17528         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
17529         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
17530         return ret_conv;
17531 }
17532
17533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17534         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
17535         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17536         *ret_copy = COption_EventZ_clone(orig_conv);
17537         int64_t ret_ref = tag_ptr(ret_copy, true);
17538         return ret_ref;
17539 }
17540
17541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17542         void* o_ptr = untag_ptr(o);
17543         CHECK_ACCESS(o_ptr);
17544         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
17545         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
17546         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17547         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
17548         return tag_ptr(ret_conv, true);
17549 }
17550
17551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17552         void* e_ptr = untag_ptr(e);
17553         CHECK_ACCESS(e_ptr);
17554         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17555         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17556         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17557         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
17558         return tag_ptr(ret_conv, true);
17559 }
17560
17561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17562         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
17563         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
17564         return ret_conv;
17565 }
17566
17567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17568         if (!ptr_is_owned(_res)) return;
17569         void* _res_ptr = untag_ptr(_res);
17570         CHECK_ACCESS(_res_ptr);
17571         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
17572         FREE(untag_ptr(_res));
17573         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
17574 }
17575
17576 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
17577         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17578         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
17579         return tag_ptr(ret_conv, true);
17580 }
17581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17582         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
17583         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
17584         return ret_conv;
17585 }
17586
17587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17588         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
17589         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17590         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
17591         return tag_ptr(ret_conv, true);
17592 }
17593
17594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17595         LDKCVec_MessageSendEventZ _res_constr;
17596         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17597         if (_res_constr.datalen > 0)
17598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
17599         else
17600                 _res_constr.data = NULL;
17601         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17602         for (size_t s = 0; s < _res_constr.datalen; s++) {
17603                 int64_t _res_conv_18 = _res_vals[s];
17604                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
17605                 CHECK_ACCESS(_res_conv_18_ptr);
17606                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
17607                 FREE(untag_ptr(_res_conv_18));
17608                 _res_constr.data[s] = _res_conv_18_conv;
17609         }
17610         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17611         CVec_MessageSendEventZ_free(_res_constr);
17612 }
17613
17614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17615         void* o_ptr = untag_ptr(o);
17616         CHECK_ACCESS(o_ptr);
17617         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
17618         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
17619         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17620         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
17621         return tag_ptr(ret_conv, true);
17622 }
17623
17624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17625         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
17626         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17627         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
17628         return tag_ptr(ret_conv, true);
17629 }
17630
17631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17632         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
17633         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
17634         return ret_conv;
17635 }
17636
17637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17638         if (!ptr_is_owned(_res)) return;
17639         void* _res_ptr = untag_ptr(_res);
17640         CHECK_ACCESS(_res_ptr);
17641         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
17642         FREE(untag_ptr(_res));
17643         CResult_TxOutAccessErrorZ_free(_res_conv);
17644 }
17645
17646 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
17647         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17648         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
17649         return tag_ptr(ret_conv, true);
17650 }
17651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17652         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
17653         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17654         return ret_conv;
17655 }
17656
17657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17658         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
17659         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17660         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17661         return tag_ptr(ret_conv, true);
17662 }
17663
17664 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17665         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17666         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17667         return tag_ptr(ret_conv, true);
17668 }
17669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17670         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
17671         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17672         return ret_conv;
17673 }
17674
17675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17676         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
17677         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17678         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17679         return tag_ptr(ret_conv, true);
17680 }
17681
17682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17683         LDKTransaction b_ref;
17684         b_ref.datalen = (*env)->GetArrayLength(env, b);
17685         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17686         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17687         b_ref.data_is_owned = true;
17688         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17689         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17690         return tag_ptr(ret_conv, true);
17691 }
17692
17693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17694         if (!ptr_is_owned(_res)) return;
17695         void* _res_ptr = untag_ptr(_res);
17696         CHECK_ACCESS(_res_ptr);
17697         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17698         FREE(untag_ptr(_res));
17699         C2Tuple_usizeTransactionZ_free(_res_conv);
17700 }
17701
17702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17703         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17704         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17705         if (_res_constr.datalen > 0)
17706                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17707         else
17708                 _res_constr.data = NULL;
17709         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17710         for (size_t c = 0; c < _res_constr.datalen; c++) {
17711                 int64_t _res_conv_28 = _res_vals[c];
17712                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
17713                 CHECK_ACCESS(_res_conv_28_ptr);
17714                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17715                 FREE(untag_ptr(_res_conv_28));
17716                 _res_constr.data[c] = _res_conv_28_conv;
17717         }
17718         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17719         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17720 }
17721
17722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17723         LDKCVec_TxidZ _res_constr;
17724         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17725         if (_res_constr.datalen > 0)
17726                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17727         else
17728                 _res_constr.data = NULL;
17729         for (size_t i = 0; i < _res_constr.datalen; i++) {
17730                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17731                 LDKThirtyTwoBytes _res_conv_8_ref;
17732                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17733                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17734                 _res_constr.data[i] = _res_conv_8_ref;
17735         }
17736         CVec_TxidZ_free(_res_constr);
17737 }
17738
17739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17740         LDKCVec_MonitorEventZ _res_constr;
17741         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17742         if (_res_constr.datalen > 0)
17743                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17744         else
17745                 _res_constr.data = NULL;
17746         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17747         for (size_t o = 0; o < _res_constr.datalen; o++) {
17748                 int64_t _res_conv_14 = _res_vals[o];
17749                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
17750                 CHECK_ACCESS(_res_conv_14_ptr);
17751                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17752                 FREE(untag_ptr(_res_conv_14));
17753                 _res_constr.data[o] = _res_conv_14_conv;
17754         }
17755         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17756         CVec_MonitorEventZ_free(_res_constr);
17757 }
17758
17759 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17760         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17761         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17762         return tag_ptr(ret_conv, true);
17763 }
17764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17765         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
17766         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17767         return ret_conv;
17768 }
17769
17770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17771         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
17772         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17773         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17774         return tag_ptr(ret_conv, true);
17775 }
17776
17777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b, int8_tArray c) {
17778         LDKOutPoint a_conv;
17779         a_conv.inner = untag_ptr(a);
17780         a_conv.is_owned = ptr_is_owned(a);
17781         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17782         a_conv = OutPoint_clone(&a_conv);
17783         LDKCVec_MonitorEventZ b_constr;
17784         b_constr.datalen = (*env)->GetArrayLength(env, b);
17785         if (b_constr.datalen > 0)
17786                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17787         else
17788                 b_constr.data = NULL;
17789         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17790         for (size_t o = 0; o < b_constr.datalen; o++) {
17791                 int64_t b_conv_14 = b_vals[o];
17792                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
17793                 CHECK_ACCESS(b_conv_14_ptr);
17794                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17795                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
17796                 b_constr.data[o] = b_conv_14_conv;
17797         }
17798         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17799         LDKPublicKey c_ref;
17800         CHECK((*env)->GetArrayLength(env, c) == 33);
17801         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17802         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17803         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17804         return tag_ptr(ret_conv, true);
17805 }
17806
17807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17808         if (!ptr_is_owned(_res)) return;
17809         void* _res_ptr = untag_ptr(_res);
17810         CHECK_ACCESS(_res_ptr);
17811         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17812         FREE(untag_ptr(_res));
17813         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17814 }
17815
17816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17817         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17818         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17819         if (_res_constr.datalen > 0)
17820                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17821         else
17822                 _res_constr.data = NULL;
17823         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17824         for (size_t x = 0; x < _res_constr.datalen; x++) {
17825                 int64_t _res_conv_49 = _res_vals[x];
17826                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
17827                 CHECK_ACCESS(_res_conv_49_ptr);
17828                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17829                 FREE(untag_ptr(_res_conv_49));
17830                 _res_constr.data[x] = _res_conv_49_conv;
17831         }
17832         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17833         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17834 }
17835
17836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17837         LDKFixedPenaltyScorer o_conv;
17838         o_conv.inner = untag_ptr(o);
17839         o_conv.is_owned = ptr_is_owned(o);
17840         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17841         o_conv = FixedPenaltyScorer_clone(&o_conv);
17842         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17843         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17844         return tag_ptr(ret_conv, true);
17845 }
17846
17847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17848         void* e_ptr = untag_ptr(e);
17849         CHECK_ACCESS(e_ptr);
17850         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17851         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17852         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17853         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17854         return tag_ptr(ret_conv, true);
17855 }
17856
17857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17858         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
17859         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17860         return ret_conv;
17861 }
17862
17863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17864         if (!ptr_is_owned(_res)) return;
17865         void* _res_ptr = untag_ptr(_res);
17866         CHECK_ACCESS(_res_ptr);
17867         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17868         FREE(untag_ptr(_res));
17869         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17870 }
17871
17872 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17873         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17874         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17875         return tag_ptr(ret_conv, true);
17876 }
17877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17878         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
17879         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17880         return ret_conv;
17881 }
17882
17883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17884         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
17885         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17886         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17887         return tag_ptr(ret_conv, true);
17888 }
17889
17890 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17891         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17892         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17893         return tag_ptr(ret_conv, true);
17894 }
17895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17896         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
17897         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17898         return ret_conv;
17899 }
17900
17901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17902         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
17903         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17904         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17905         return tag_ptr(ret_conv, true);
17906 }
17907
17908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17909         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17910         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17911         return tag_ptr(ret_conv, true);
17912 }
17913
17914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17915         if (!ptr_is_owned(_res)) return;
17916         void* _res_ptr = untag_ptr(_res);
17917         CHECK_ACCESS(_res_ptr);
17918         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17919         FREE(untag_ptr(_res));
17920         C2Tuple_u64u64Z_free(_res_conv);
17921 }
17922
17923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17924         void* o_ptr = untag_ptr(o);
17925         CHECK_ACCESS(o_ptr);
17926         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17927         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
17928         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17929         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17930         int64_t ret_ref = tag_ptr(ret_copy, true);
17931         return ret_ref;
17932 }
17933
17934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17935         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17936         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17937         int64_t ret_ref = tag_ptr(ret_copy, true);
17938         return ret_ref;
17939 }
17940
17941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17942         if (!ptr_is_owned(_res)) return;
17943         void* _res_ptr = untag_ptr(_res);
17944         CHECK_ACCESS(_res_ptr);
17945         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17946         FREE(untag_ptr(_res));
17947         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17948 }
17949
17950 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17951         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17952         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17953         int64_t ret_ref = tag_ptr(ret_copy, true);
17954         return ret_ref;
17955 }
17956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17957         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
17958         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17959         return ret_conv;
17960 }
17961
17962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17963         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
17964         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17965         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17966         int64_t ret_ref = tag_ptr(ret_copy, true);
17967         return ret_ref;
17968 }
17969
17970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17971         LDKCVec_NodeIdZ _res_constr;
17972         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17973         if (_res_constr.datalen > 0)
17974                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17975         else
17976                 _res_constr.data = NULL;
17977         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17978         for (size_t i = 0; i < _res_constr.datalen; i++) {
17979                 int64_t _res_conv_8 = _res_vals[i];
17980                 LDKNodeId _res_conv_8_conv;
17981                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
17982                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
17983                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17984                 _res_constr.data[i] = _res_conv_8_conv;
17985         }
17986         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17987         CVec_NodeIdZ_free(_res_constr);
17988 }
17989
17990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17991         LDKProbabilisticScorer o_conv;
17992         o_conv.inner = untag_ptr(o);
17993         o_conv.is_owned = ptr_is_owned(o);
17994         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17995         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17996         
17997         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17998         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
17999         return tag_ptr(ret_conv, true);
18000 }
18001
18002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18003         void* e_ptr = untag_ptr(e);
18004         CHECK_ACCESS(e_ptr);
18005         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18006         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18007         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18008         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18009         return tag_ptr(ret_conv, true);
18010 }
18011
18012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18013         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18014         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18015         return ret_conv;
18016 }
18017
18018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18019         if (!ptr_is_owned(_res)) return;
18020         void* _res_ptr = untag_ptr(_res);
18021         CHECK_ACCESS(_res_ptr);
18022         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18023         FREE(untag_ptr(_res));
18024         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18025 }
18026
18027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18028         LDKInitFeatures o_conv;
18029         o_conv.inner = untag_ptr(o);
18030         o_conv.is_owned = ptr_is_owned(o);
18031         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18032         o_conv = InitFeatures_clone(&o_conv);
18033         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18034         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18035         return tag_ptr(ret_conv, true);
18036 }
18037
18038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18039         void* e_ptr = untag_ptr(e);
18040         CHECK_ACCESS(e_ptr);
18041         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18042         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18043         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18044         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18045         return tag_ptr(ret_conv, true);
18046 }
18047
18048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18049         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18050         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18051         return ret_conv;
18052 }
18053
18054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18055         if (!ptr_is_owned(_res)) return;
18056         void* _res_ptr = untag_ptr(_res);
18057         CHECK_ACCESS(_res_ptr);
18058         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18059         FREE(untag_ptr(_res));
18060         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18061 }
18062
18063 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18064         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18065         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18066         return tag_ptr(ret_conv, true);
18067 }
18068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18069         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18070         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18071         return ret_conv;
18072 }
18073
18074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18075         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18076         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18077         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18078         return tag_ptr(ret_conv, true);
18079 }
18080
18081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18082         LDKChannelFeatures o_conv;
18083         o_conv.inner = untag_ptr(o);
18084         o_conv.is_owned = ptr_is_owned(o);
18085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18086         o_conv = ChannelFeatures_clone(&o_conv);
18087         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18088         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18089         return tag_ptr(ret_conv, true);
18090 }
18091
18092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18093         void* e_ptr = untag_ptr(e);
18094         CHECK_ACCESS(e_ptr);
18095         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18096         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18097         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18098         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18099         return tag_ptr(ret_conv, true);
18100 }
18101
18102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18103         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18104         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18105         return ret_conv;
18106 }
18107
18108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18109         if (!ptr_is_owned(_res)) return;
18110         void* _res_ptr = untag_ptr(_res);
18111         CHECK_ACCESS(_res_ptr);
18112         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18113         FREE(untag_ptr(_res));
18114         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18115 }
18116
18117 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18118         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18119         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18120         return tag_ptr(ret_conv, true);
18121 }
18122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18123         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18124         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18125         return ret_conv;
18126 }
18127
18128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18129         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18130         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18131         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18132         return tag_ptr(ret_conv, true);
18133 }
18134
18135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18136         LDKNodeFeatures o_conv;
18137         o_conv.inner = untag_ptr(o);
18138         o_conv.is_owned = ptr_is_owned(o);
18139         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18140         o_conv = NodeFeatures_clone(&o_conv);
18141         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18142         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18143         return tag_ptr(ret_conv, true);
18144 }
18145
18146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18147         void* e_ptr = untag_ptr(e);
18148         CHECK_ACCESS(e_ptr);
18149         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18150         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18151         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18152         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18153         return tag_ptr(ret_conv, true);
18154 }
18155
18156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18157         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18158         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18159         return ret_conv;
18160 }
18161
18162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18163         if (!ptr_is_owned(_res)) return;
18164         void* _res_ptr = untag_ptr(_res);
18165         CHECK_ACCESS(_res_ptr);
18166         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18167         FREE(untag_ptr(_res));
18168         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18169 }
18170
18171 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18172         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18173         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18174         return tag_ptr(ret_conv, true);
18175 }
18176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18177         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18178         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18179         return ret_conv;
18180 }
18181
18182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18183         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18184         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18185         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18186         return tag_ptr(ret_conv, true);
18187 }
18188
18189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18190         LDKInvoiceFeatures o_conv;
18191         o_conv.inner = untag_ptr(o);
18192         o_conv.is_owned = ptr_is_owned(o);
18193         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18194         o_conv = InvoiceFeatures_clone(&o_conv);
18195         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18196         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18197         return tag_ptr(ret_conv, true);
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18201         void* e_ptr = untag_ptr(e);
18202         CHECK_ACCESS(e_ptr);
18203         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18204         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18205         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18206         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18207         return tag_ptr(ret_conv, true);
18208 }
18209
18210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18211         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18212         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18213         return ret_conv;
18214 }
18215
18216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18217         if (!ptr_is_owned(_res)) return;
18218         void* _res_ptr = untag_ptr(_res);
18219         CHECK_ACCESS(_res_ptr);
18220         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18221         FREE(untag_ptr(_res));
18222         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18223 }
18224
18225 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18226         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18227         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18228         return tag_ptr(ret_conv, true);
18229 }
18230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18231         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18232         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18233         return ret_conv;
18234 }
18235
18236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18237         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18238         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18239         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18240         return tag_ptr(ret_conv, true);
18241 }
18242
18243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18244         LDKChannelTypeFeatures o_conv;
18245         o_conv.inner = untag_ptr(o);
18246         o_conv.is_owned = ptr_is_owned(o);
18247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18248         o_conv = ChannelTypeFeatures_clone(&o_conv);
18249         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18250         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18251         return tag_ptr(ret_conv, true);
18252 }
18253
18254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18255         void* e_ptr = untag_ptr(e);
18256         CHECK_ACCESS(e_ptr);
18257         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18258         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18259         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18260         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18261         return tag_ptr(ret_conv, true);
18262 }
18263
18264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18265         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18266         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18267         return ret_conv;
18268 }
18269
18270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18271         if (!ptr_is_owned(_res)) return;
18272         void* _res_ptr = untag_ptr(_res);
18273         CHECK_ACCESS(_res_ptr);
18274         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18275         FREE(untag_ptr(_res));
18276         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18277 }
18278
18279 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18280         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18281         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18282         return tag_ptr(ret_conv, true);
18283 }
18284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18285         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
18286         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18287         return ret_conv;
18288 }
18289
18290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18291         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
18292         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18293         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
18294         return tag_ptr(ret_conv, true);
18295 }
18296
18297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18298         LDKNodeId o_conv;
18299         o_conv.inner = untag_ptr(o);
18300         o_conv.is_owned = ptr_is_owned(o);
18301         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18302         o_conv = NodeId_clone(&o_conv);
18303         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18304         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18305         return tag_ptr(ret_conv, true);
18306 }
18307
18308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18309         void* e_ptr = untag_ptr(e);
18310         CHECK_ACCESS(e_ptr);
18311         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18312         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18313         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18314         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18315         return tag_ptr(ret_conv, true);
18316 }
18317
18318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18319         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
18320         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18321         return ret_conv;
18322 }
18323
18324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18325         if (!ptr_is_owned(_res)) return;
18326         void* _res_ptr = untag_ptr(_res);
18327         CHECK_ACCESS(_res_ptr);
18328         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18329         FREE(untag_ptr(_res));
18330         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18331 }
18332
18333 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18334         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18335         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18336         return tag_ptr(ret_conv, true);
18337 }
18338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18339         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
18340         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18341         return ret_conv;
18342 }
18343
18344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18345         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
18346         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18347         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18348         return tag_ptr(ret_conv, true);
18349 }
18350
18351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18352         void* o_ptr = untag_ptr(o);
18353         CHECK_ACCESS(o_ptr);
18354         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
18355         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
18356         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18357         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
18358         return tag_ptr(ret_conv, true);
18359 }
18360
18361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18362         void* e_ptr = untag_ptr(e);
18363         CHECK_ACCESS(e_ptr);
18364         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18365         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18366         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18367         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
18368         return tag_ptr(ret_conv, true);
18369 }
18370
18371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18372         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
18373         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
18374         return ret_conv;
18375 }
18376
18377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18378         if (!ptr_is_owned(_res)) return;
18379         void* _res_ptr = untag_ptr(_res);
18380         CHECK_ACCESS(_res_ptr);
18381         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
18382         FREE(untag_ptr(_res));
18383         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
18384 }
18385
18386 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
18387         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18388         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
18389         return tag_ptr(ret_conv, true);
18390 }
18391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18392         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
18393         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
18394         return ret_conv;
18395 }
18396
18397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18398         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
18399         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18400         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
18401         return tag_ptr(ret_conv, true);
18402 }
18403
18404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18405         void* o_ptr = untag_ptr(o);
18406         CHECK_ACCESS(o_ptr);
18407         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
18408         if (o_conv.free == LDKAccess_JCalls_free) {
18409                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18410                 LDKAccess_JCalls_cloned(&o_conv);
18411         }
18412         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18413         *ret_copy = COption_AccessZ_some(o_conv);
18414         int64_t ret_ref = tag_ptr(ret_copy, true);
18415         return ret_ref;
18416 }
18417
18418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
18419         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18420         *ret_copy = COption_AccessZ_none();
18421         int64_t ret_ref = tag_ptr(ret_copy, true);
18422         return ret_ref;
18423 }
18424
18425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18426         if (!ptr_is_owned(_res)) return;
18427         void* _res_ptr = untag_ptr(_res);
18428         CHECK_ACCESS(_res_ptr);
18429         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
18430         FREE(untag_ptr(_res));
18431         COption_AccessZ_free(_res_conv);
18432 }
18433
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
18435         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18436         *ret_conv = CResult_boolLightningErrorZ_ok(o);
18437         return tag_ptr(ret_conv, true);
18438 }
18439
18440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18441         LDKLightningError e_conv;
18442         e_conv.inner = untag_ptr(e);
18443         e_conv.is_owned = ptr_is_owned(e);
18444         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18445         e_conv = LightningError_clone(&e_conv);
18446         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18447         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
18448         return tag_ptr(ret_conv, true);
18449 }
18450
18451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18452         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
18453         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
18454         return ret_conv;
18455 }
18456
18457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18458         if (!ptr_is_owned(_res)) return;
18459         void* _res_ptr = untag_ptr(_res);
18460         CHECK_ACCESS(_res_ptr);
18461         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
18462         FREE(untag_ptr(_res));
18463         CResult_boolLightningErrorZ_free(_res_conv);
18464 }
18465
18466 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
18467         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18468         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
18469         return tag_ptr(ret_conv, true);
18470 }
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18472         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
18473         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
18474         return ret_conv;
18475 }
18476
18477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18478         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
18479         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18480         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
18481         return tag_ptr(ret_conv, true);
18482 }
18483
18484 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
18485         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18486         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
18487         return tag_ptr(ret_conv, true);
18488 }
18489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18490         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
18491         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
18492         return ret_conv;
18493 }
18494
18495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18496         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
18497         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18498         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
18499         return tag_ptr(ret_conv, true);
18500 }
18501
18502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
18503         LDKChannelAnnouncement a_conv;
18504         a_conv.inner = untag_ptr(a);
18505         a_conv.is_owned = ptr_is_owned(a);
18506         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18507         a_conv = ChannelAnnouncement_clone(&a_conv);
18508         LDKChannelUpdate b_conv;
18509         b_conv.inner = untag_ptr(b);
18510         b_conv.is_owned = ptr_is_owned(b);
18511         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18512         b_conv = ChannelUpdate_clone(&b_conv);
18513         LDKChannelUpdate c_conv;
18514         c_conv.inner = untag_ptr(c);
18515         c_conv.is_owned = ptr_is_owned(c);
18516         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18517         c_conv = ChannelUpdate_clone(&c_conv);
18518         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18519         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
18520         return tag_ptr(ret_conv, true);
18521 }
18522
18523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18524         if (!ptr_is_owned(_res)) return;
18525         void* _res_ptr = untag_ptr(_res);
18526         CHECK_ACCESS(_res_ptr);
18527         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
18528         FREE(untag_ptr(_res));
18529         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
18530 }
18531
18532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18533         void* o_ptr = untag_ptr(o);
18534         CHECK_ACCESS(o_ptr);
18535         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
18536         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
18537         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18538         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
18539         int64_t ret_ref = tag_ptr(ret_copy, true);
18540         return ret_ref;
18541 }
18542
18543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
18544         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18545         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
18546         int64_t ret_ref = tag_ptr(ret_copy, true);
18547         return ret_ref;
18548 }
18549
18550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18551         if (!ptr_is_owned(_res)) return;
18552         void* _res_ptr = untag_ptr(_res);
18553         CHECK_ACCESS(_res_ptr);
18554         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
18555         FREE(untag_ptr(_res));
18556         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
18557 }
18558
18559 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
18560         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18561         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
18562         int64_t ret_ref = tag_ptr(ret_copy, true);
18563         return ret_ref;
18564 }
18565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18566         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
18567         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
18568         return ret_conv;
18569 }
18570
18571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18572         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
18573         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18574         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
18575         int64_t ret_ref = tag_ptr(ret_copy, true);
18576         return ret_ref;
18577 }
18578
18579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18580         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18581         *ret_conv = CResult_NoneLightningErrorZ_ok();
18582         return tag_ptr(ret_conv, true);
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18586         LDKLightningError e_conv;
18587         e_conv.inner = untag_ptr(e);
18588         e_conv.is_owned = ptr_is_owned(e);
18589         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18590         e_conv = LightningError_clone(&e_conv);
18591         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18592         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18593         return tag_ptr(ret_conv, true);
18594 }
18595
18596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18597         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
18598         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18599         return ret_conv;
18600 }
18601
18602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18603         if (!ptr_is_owned(_res)) return;
18604         void* _res_ptr = untag_ptr(_res);
18605         CHECK_ACCESS(_res_ptr);
18606         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18607         FREE(untag_ptr(_res));
18608         CResult_NoneLightningErrorZ_free(_res_conv);
18609 }
18610
18611 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18612         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18613         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18614         return tag_ptr(ret_conv, true);
18615 }
18616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18617         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
18618         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18619         return ret_conv;
18620 }
18621
18622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18623         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
18624         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18625         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18626         return tag_ptr(ret_conv, true);
18627 }
18628
18629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18630         LDKChannelUpdateInfo o_conv;
18631         o_conv.inner = untag_ptr(o);
18632         o_conv.is_owned = ptr_is_owned(o);
18633         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18634         o_conv = ChannelUpdateInfo_clone(&o_conv);
18635         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18636         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18637         return tag_ptr(ret_conv, true);
18638 }
18639
18640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18641         void* e_ptr = untag_ptr(e);
18642         CHECK_ACCESS(e_ptr);
18643         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18644         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18645         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18646         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18647         return tag_ptr(ret_conv, true);
18648 }
18649
18650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18651         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
18652         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18653         return ret_conv;
18654 }
18655
18656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18657         if (!ptr_is_owned(_res)) return;
18658         void* _res_ptr = untag_ptr(_res);
18659         CHECK_ACCESS(_res_ptr);
18660         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18661         FREE(untag_ptr(_res));
18662         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18663 }
18664
18665 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18666         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18667         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18668         return tag_ptr(ret_conv, true);
18669 }
18670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18671         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
18672         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18673         return ret_conv;
18674 }
18675
18676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18677         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
18678         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18679         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18680         return tag_ptr(ret_conv, true);
18681 }
18682
18683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18684         LDKChannelInfo o_conv;
18685         o_conv.inner = untag_ptr(o);
18686         o_conv.is_owned = ptr_is_owned(o);
18687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18688         o_conv = ChannelInfo_clone(&o_conv);
18689         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18690         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18691         return tag_ptr(ret_conv, true);
18692 }
18693
18694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18695         void* e_ptr = untag_ptr(e);
18696         CHECK_ACCESS(e_ptr);
18697         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18698         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18699         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18700         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18701         return tag_ptr(ret_conv, true);
18702 }
18703
18704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18705         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
18706         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18707         return ret_conv;
18708 }
18709
18710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18711         if (!ptr_is_owned(_res)) return;
18712         void* _res_ptr = untag_ptr(_res);
18713         CHECK_ACCESS(_res_ptr);
18714         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18715         FREE(untag_ptr(_res));
18716         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18717 }
18718
18719 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18720         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18721         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18722         return tag_ptr(ret_conv, true);
18723 }
18724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18725         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
18726         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18727         return ret_conv;
18728 }
18729
18730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18731         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
18732         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18733         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18734         return tag_ptr(ret_conv, true);
18735 }
18736
18737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18738         LDKRoutingFees o_conv;
18739         o_conv.inner = untag_ptr(o);
18740         o_conv.is_owned = ptr_is_owned(o);
18741         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18742         o_conv = RoutingFees_clone(&o_conv);
18743         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18744         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18745         return tag_ptr(ret_conv, true);
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18749         void* e_ptr = untag_ptr(e);
18750         CHECK_ACCESS(e_ptr);
18751         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18752         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18753         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18754         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18755         return tag_ptr(ret_conv, true);
18756 }
18757
18758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18759         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
18760         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18761         return ret_conv;
18762 }
18763
18764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18765         if (!ptr_is_owned(_res)) return;
18766         void* _res_ptr = untag_ptr(_res);
18767         CHECK_ACCESS(_res_ptr);
18768         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18769         FREE(untag_ptr(_res));
18770         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18771 }
18772
18773 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18774         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18775         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18776         return tag_ptr(ret_conv, true);
18777 }
18778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18779         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
18780         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18781         return ret_conv;
18782 }
18783
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18785         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
18786         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18787         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18788         return tag_ptr(ret_conv, true);
18789 }
18790
18791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18792         LDKCVec_NetAddressZ _res_constr;
18793         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18794         if (_res_constr.datalen > 0)
18795                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18796         else
18797                 _res_constr.data = NULL;
18798         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18799         for (size_t m = 0; m < _res_constr.datalen; m++) {
18800                 int64_t _res_conv_12 = _res_vals[m];
18801                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
18802                 CHECK_ACCESS(_res_conv_12_ptr);
18803                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18804                 FREE(untag_ptr(_res_conv_12));
18805                 _res_constr.data[m] = _res_conv_12_conv;
18806         }
18807         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18808         CVec_NetAddressZ_free(_res_constr);
18809 }
18810
18811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18812         LDKNodeAnnouncementInfo o_conv;
18813         o_conv.inner = untag_ptr(o);
18814         o_conv.is_owned = ptr_is_owned(o);
18815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18816         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18817         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18818         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18819         return tag_ptr(ret_conv, true);
18820 }
18821
18822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18823         void* e_ptr = untag_ptr(e);
18824         CHECK_ACCESS(e_ptr);
18825         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18826         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18827         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18828         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18829         return tag_ptr(ret_conv, true);
18830 }
18831
18832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18833         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
18834         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18835         return ret_conv;
18836 }
18837
18838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18839         if (!ptr_is_owned(_res)) return;
18840         void* _res_ptr = untag_ptr(_res);
18841         CHECK_ACCESS(_res_ptr);
18842         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18843         FREE(untag_ptr(_res));
18844         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18845 }
18846
18847 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18848         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18849         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18850         return tag_ptr(ret_conv, true);
18851 }
18852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18853         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
18854         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18855         return ret_conv;
18856 }
18857
18858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18859         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
18860         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18861         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18862         return tag_ptr(ret_conv, true);
18863 }
18864
18865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18866         LDKNodeAlias o_conv;
18867         o_conv.inner = untag_ptr(o);
18868         o_conv.is_owned = ptr_is_owned(o);
18869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18870         o_conv = NodeAlias_clone(&o_conv);
18871         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18872         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18873         return tag_ptr(ret_conv, true);
18874 }
18875
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18877         void* e_ptr = untag_ptr(e);
18878         CHECK_ACCESS(e_ptr);
18879         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18880         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18881         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18882         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18883         return tag_ptr(ret_conv, true);
18884 }
18885
18886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18887         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
18888         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18889         return ret_conv;
18890 }
18891
18892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18893         if (!ptr_is_owned(_res)) return;
18894         void* _res_ptr = untag_ptr(_res);
18895         CHECK_ACCESS(_res_ptr);
18896         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18897         FREE(untag_ptr(_res));
18898         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18899 }
18900
18901 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18902         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18903         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18904         return tag_ptr(ret_conv, true);
18905 }
18906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18907         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
18908         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18909         return ret_conv;
18910 }
18911
18912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18913         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
18914         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18915         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18916         return tag_ptr(ret_conv, true);
18917 }
18918
18919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18920         LDKNodeInfo o_conv;
18921         o_conv.inner = untag_ptr(o);
18922         o_conv.is_owned = ptr_is_owned(o);
18923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18924         o_conv = NodeInfo_clone(&o_conv);
18925         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18926         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18927         return tag_ptr(ret_conv, true);
18928 }
18929
18930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18931         void* e_ptr = untag_ptr(e);
18932         CHECK_ACCESS(e_ptr);
18933         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18934         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18935         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18936         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18937         return tag_ptr(ret_conv, true);
18938 }
18939
18940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18941         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
18942         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18943         return ret_conv;
18944 }
18945
18946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18947         if (!ptr_is_owned(_res)) return;
18948         void* _res_ptr = untag_ptr(_res);
18949         CHECK_ACCESS(_res_ptr);
18950         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18951         FREE(untag_ptr(_res));
18952         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18953 }
18954
18955 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18956         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18957         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18958         return tag_ptr(ret_conv, true);
18959 }
18960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18961         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
18962         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18963         return ret_conv;
18964 }
18965
18966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18967         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
18968         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18969         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18970         return tag_ptr(ret_conv, true);
18971 }
18972
18973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18974         LDKNetworkGraph o_conv;
18975         o_conv.inner = untag_ptr(o);
18976         o_conv.is_owned = ptr_is_owned(o);
18977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18978         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18979         
18980         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18981         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18982         return tag_ptr(ret_conv, true);
18983 }
18984
18985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18986         void* e_ptr = untag_ptr(e);
18987         CHECK_ACCESS(e_ptr);
18988         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18989         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18990         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18991         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18992         return tag_ptr(ret_conv, true);
18993 }
18994
18995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18996         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
18997         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18998         return ret_conv;
18999 }
19000
19001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19002         if (!ptr_is_owned(_res)) return;
19003         void* _res_ptr = untag_ptr(_res);
19004         CHECK_ACCESS(_res_ptr);
19005         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19006         FREE(untag_ptr(_res));
19007         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19008 }
19009
19010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19011         LDKCVec_NetAddressZ o_constr;
19012         o_constr.datalen = (*env)->GetArrayLength(env, o);
19013         if (o_constr.datalen > 0)
19014                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19015         else
19016                 o_constr.data = NULL;
19017         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19018         for (size_t m = 0; m < o_constr.datalen; m++) {
19019                 int64_t o_conv_12 = o_vals[m];
19020                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
19021                 CHECK_ACCESS(o_conv_12_ptr);
19022                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19023                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
19024                 o_constr.data[m] = o_conv_12_conv;
19025         }
19026         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19027         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19028         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19029         int64_t ret_ref = tag_ptr(ret_copy, true);
19030         return ret_ref;
19031 }
19032
19033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19034         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19035         *ret_copy = COption_CVec_NetAddressZZ_none();
19036         int64_t ret_ref = tag_ptr(ret_copy, true);
19037         return ret_ref;
19038 }
19039
19040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19041         if (!ptr_is_owned(_res)) return;
19042         void* _res_ptr = untag_ptr(_res);
19043         CHECK_ACCESS(_res_ptr);
19044         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19045         FREE(untag_ptr(_res));
19046         COption_CVec_NetAddressZZ_free(_res_conv);
19047 }
19048
19049 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19050         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19051         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19052         int64_t ret_ref = tag_ptr(ret_copy, true);
19053         return ret_ref;
19054 }
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19056         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
19057         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19058         return ret_conv;
19059 }
19060
19061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19062         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
19063         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19064         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19065         int64_t ret_ref = tag_ptr(ret_copy, true);
19066         return ret_ref;
19067 }
19068
19069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19070         LDKDelayedPaymentOutputDescriptor o_conv;
19071         o_conv.inner = untag_ptr(o);
19072         o_conv.is_owned = ptr_is_owned(o);
19073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19074         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
19075         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19076         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19077         return tag_ptr(ret_conv, true);
19078 }
19079
19080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19081         void* e_ptr = untag_ptr(e);
19082         CHECK_ACCESS(e_ptr);
19083         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19084         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19085         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19086         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19087         return tag_ptr(ret_conv, true);
19088 }
19089
19090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19091         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19092         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19093         return ret_conv;
19094 }
19095
19096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19097         if (!ptr_is_owned(_res)) return;
19098         void* _res_ptr = untag_ptr(_res);
19099         CHECK_ACCESS(_res_ptr);
19100         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19101         FREE(untag_ptr(_res));
19102         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19103 }
19104
19105 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19106         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19107         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19108         return tag_ptr(ret_conv, true);
19109 }
19110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19111         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19112         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19113         return ret_conv;
19114 }
19115
19116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19117         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19118         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19119         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19120         return tag_ptr(ret_conv, true);
19121 }
19122
19123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19124         LDKStaticPaymentOutputDescriptor o_conv;
19125         o_conv.inner = untag_ptr(o);
19126         o_conv.is_owned = ptr_is_owned(o);
19127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19128         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
19129         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19130         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19131         return tag_ptr(ret_conv, true);
19132 }
19133
19134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19135         void* e_ptr = untag_ptr(e);
19136         CHECK_ACCESS(e_ptr);
19137         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19138         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19139         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19140         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19141         return tag_ptr(ret_conv, true);
19142 }
19143
19144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19145         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19146         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19147         return ret_conv;
19148 }
19149
19150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19151         if (!ptr_is_owned(_res)) return;
19152         void* _res_ptr = untag_ptr(_res);
19153         CHECK_ACCESS(_res_ptr);
19154         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19155         FREE(untag_ptr(_res));
19156         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19157 }
19158
19159 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19160         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19161         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19162         return tag_ptr(ret_conv, true);
19163 }
19164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19165         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19166         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19167         return ret_conv;
19168 }
19169
19170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19171         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19172         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19173         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19174         return tag_ptr(ret_conv, true);
19175 }
19176
19177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19178         void* o_ptr = untag_ptr(o);
19179         CHECK_ACCESS(o_ptr);
19180         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
19181         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
19182         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19183         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
19184         return tag_ptr(ret_conv, true);
19185 }
19186
19187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19188         void* e_ptr = untag_ptr(e);
19189         CHECK_ACCESS(e_ptr);
19190         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19191         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19192         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19193         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
19194         return tag_ptr(ret_conv, true);
19195 }
19196
19197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19198         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19199         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19200         return ret_conv;
19201 }
19202
19203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19204         if (!ptr_is_owned(_res)) return;
19205         void* _res_ptr = untag_ptr(_res);
19206         CHECK_ACCESS(_res_ptr);
19207         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
19208         FREE(untag_ptr(_res));
19209         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
19210 }
19211
19212 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19213         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19214         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
19215         return tag_ptr(ret_conv, true);
19216 }
19217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19218         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19219         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19220         return ret_conv;
19221 }
19222
19223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19224         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19225         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19226         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
19227         return tag_ptr(ret_conv, true);
19228 }
19229
19230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19231         LDKCVec_PaymentPreimageZ _res_constr;
19232         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19233         if (_res_constr.datalen > 0)
19234                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
19235         else
19236                 _res_constr.data = NULL;
19237         for (size_t i = 0; i < _res_constr.datalen; i++) {
19238                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19239                 LDKThirtyTwoBytes _res_conv_8_ref;
19240                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19241                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19242                 _res_constr.data[i] = _res_conv_8_ref;
19243         }
19244         CVec_PaymentPreimageZ_free(_res_constr);
19245 }
19246
19247 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
19248         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19249         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
19250         return tag_ptr(ret_conv, true);
19251 }
19252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19253         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
19254         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
19255         return ret_conv;
19256 }
19257
19258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19259         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
19260         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19261         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
19262         return tag_ptr(ret_conv, true);
19263 }
19264
19265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
19266         LDKSignature a_ref;
19267         CHECK((*env)->GetArrayLength(env, a) == 64);
19268         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19269         LDKCVec_SignatureZ b_constr;
19270         b_constr.datalen = (*env)->GetArrayLength(env, b);
19271         if (b_constr.datalen > 0)
19272                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19273         else
19274                 b_constr.data = NULL;
19275         for (size_t i = 0; i < b_constr.datalen; i++) {
19276                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
19277                 LDKSignature b_conv_8_ref;
19278                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
19279                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
19280                 b_constr.data[i] = b_conv_8_ref;
19281         }
19282         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19283         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
19284         return tag_ptr(ret_conv, true);
19285 }
19286
19287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19288         if (!ptr_is_owned(_res)) return;
19289         void* _res_ptr = untag_ptr(_res);
19290         CHECK_ACCESS(_res_ptr);
19291         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
19292         FREE(untag_ptr(_res));
19293         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
19294 }
19295
19296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19297         void* o_ptr = untag_ptr(o);
19298         CHECK_ACCESS(o_ptr);
19299         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
19300         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
19301         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19302         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
19303         return tag_ptr(ret_conv, true);
19304 }
19305
19306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
19307         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19308         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
19309         return tag_ptr(ret_conv, true);
19310 }
19311
19312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19313         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
19314         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
19315         return ret_conv;
19316 }
19317
19318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19319         if (!ptr_is_owned(_res)) return;
19320         void* _res_ptr = untag_ptr(_res);
19321         CHECK_ACCESS(_res_ptr);
19322         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
19323         FREE(untag_ptr(_res));
19324         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
19325 }
19326
19327 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
19328         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19329         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
19330         return tag_ptr(ret_conv, true);
19331 }
19332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19333         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
19334         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
19335         return ret_conv;
19336 }
19337
19338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19339         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
19340         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19341         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
19342         return tag_ptr(ret_conv, true);
19343 }
19344
19345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19346         LDKSignature o_ref;
19347         CHECK((*env)->GetArrayLength(env, o) == 64);
19348         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
19349         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19350         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
19351         return tag_ptr(ret_conv, true);
19352 }
19353
19354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19355         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19356         *ret_conv = CResult_SignatureNoneZ_err();
19357         return tag_ptr(ret_conv, true);
19358 }
19359
19360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19361         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
19362         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
19363         return ret_conv;
19364 }
19365
19366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19367         if (!ptr_is_owned(_res)) return;
19368         void* _res_ptr = untag_ptr(_res);
19369         CHECK_ACCESS(_res_ptr);
19370         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
19371         FREE(untag_ptr(_res));
19372         CResult_SignatureNoneZ_free(_res_conv);
19373 }
19374
19375 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
19376         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19377         *ret_conv = CResult_SignatureNoneZ_clone(arg);
19378         return tag_ptr(ret_conv, true);
19379 }
19380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19381         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
19382         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
19383         return ret_conv;
19384 }
19385
19386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19387         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
19388         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19389         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
19390         return tag_ptr(ret_conv, true);
19391 }
19392
19393 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
19394         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19395         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
19396         return tag_ptr(ret_conv, true);
19397 }
19398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19399         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
19400         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
19401         return ret_conv;
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19405         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
19406         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19407         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
19408         return tag_ptr(ret_conv, true);
19409 }
19410
19411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19412         LDKSignature a_ref;
19413         CHECK((*env)->GetArrayLength(env, a) == 64);
19414         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19415         LDKSignature b_ref;
19416         CHECK((*env)->GetArrayLength(env, b) == 64);
19417         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
19418         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19419         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
19420         return tag_ptr(ret_conv, true);
19421 }
19422
19423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19424         if (!ptr_is_owned(_res)) return;
19425         void* _res_ptr = untag_ptr(_res);
19426         CHECK_ACCESS(_res_ptr);
19427         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
19428         FREE(untag_ptr(_res));
19429         C2Tuple_SignatureSignatureZ_free(_res_conv);
19430 }
19431
19432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19433         void* o_ptr = untag_ptr(o);
19434         CHECK_ACCESS(o_ptr);
19435         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
19436         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
19437         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19438         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
19439         return tag_ptr(ret_conv, true);
19440 }
19441
19442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
19443         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19444         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
19445         return tag_ptr(ret_conv, true);
19446 }
19447
19448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19449         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
19450         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
19451         return ret_conv;
19452 }
19453
19454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19455         if (!ptr_is_owned(_res)) return;
19456         void* _res_ptr = untag_ptr(_res);
19457         CHECK_ACCESS(_res_ptr);
19458         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
19459         FREE(untag_ptr(_res));
19460         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
19461 }
19462
19463 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
19464         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19465         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
19466         return tag_ptr(ret_conv, true);
19467 }
19468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19469         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
19470         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
19471         return ret_conv;
19472 }
19473
19474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19475         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
19476         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19477         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
19478         return tag_ptr(ret_conv, true);
19479 }
19480
19481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19482         LDKSecretKey o_ref;
19483         CHECK((*env)->GetArrayLength(env, o) == 32);
19484         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
19485         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19486         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
19487         return tag_ptr(ret_conv, true);
19488 }
19489
19490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
19491         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19492         *ret_conv = CResult_SecretKeyNoneZ_err();
19493         return tag_ptr(ret_conv, true);
19494 }
19495
19496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19497         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
19498         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
19499         return ret_conv;
19500 }
19501
19502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19503         if (!ptr_is_owned(_res)) return;
19504         void* _res_ptr = untag_ptr(_res);
19505         CHECK_ACCESS(_res_ptr);
19506         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
19507         FREE(untag_ptr(_res));
19508         CResult_SecretKeyNoneZ_free(_res_conv);
19509 }
19510
19511 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
19512         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19513         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
19514         return tag_ptr(ret_conv, true);
19515 }
19516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19517         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
19518         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
19519         return ret_conv;
19520 }
19521
19522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19523         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
19524         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19525         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
19526         return tag_ptr(ret_conv, true);
19527 }
19528
19529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19530         LDKPublicKey o_ref;
19531         CHECK((*env)->GetArrayLength(env, o) == 33);
19532         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
19533         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19534         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
19535         return tag_ptr(ret_conv, true);
19536 }
19537
19538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
19539         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19540         *ret_conv = CResult_PublicKeyNoneZ_err();
19541         return tag_ptr(ret_conv, true);
19542 }
19543
19544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19545         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
19546         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
19547         return ret_conv;
19548 }
19549
19550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19551         if (!ptr_is_owned(_res)) return;
19552         void* _res_ptr = untag_ptr(_res);
19553         CHECK_ACCESS(_res_ptr);
19554         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
19555         FREE(untag_ptr(_res));
19556         CResult_PublicKeyNoneZ_free(_res_conv);
19557 }
19558
19559 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
19560         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19561         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
19562         return tag_ptr(ret_conv, true);
19563 }
19564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19565         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
19566         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
19567         return ret_conv;
19568 }
19569
19570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19571         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
19572         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19573         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
19574         return tag_ptr(ret_conv, true);
19575 }
19576
19577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19578         void* o_ptr = untag_ptr(o);
19579         CHECK_ACCESS(o_ptr);
19580         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
19581         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
19582         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19583         *ret_copy = COption_ScalarZ_some(o_conv);
19584         int64_t ret_ref = tag_ptr(ret_copy, true);
19585         return ret_ref;
19586 }
19587
19588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
19589         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19590         *ret_copy = COption_ScalarZ_none();
19591         int64_t ret_ref = tag_ptr(ret_copy, true);
19592         return ret_ref;
19593 }
19594
19595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19596         if (!ptr_is_owned(_res)) return;
19597         void* _res_ptr = untag_ptr(_res);
19598         CHECK_ACCESS(_res_ptr);
19599         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
19600         FREE(untag_ptr(_res));
19601         COption_ScalarZ_free(_res_conv);
19602 }
19603
19604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19605         LDKThirtyTwoBytes o_ref;
19606         CHECK((*env)->GetArrayLength(env, o) == 32);
19607         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19608         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19609         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
19610         return tag_ptr(ret_conv, true);
19611 }
19612
19613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19614         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19615         *ret_conv = CResult_SharedSecretNoneZ_err();
19616         return tag_ptr(ret_conv, true);
19617 }
19618
19619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19620         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
19621         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
19622         return ret_conv;
19623 }
19624
19625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19626         if (!ptr_is_owned(_res)) return;
19627         void* _res_ptr = untag_ptr(_res);
19628         CHECK_ACCESS(_res_ptr);
19629         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
19630         FREE(untag_ptr(_res));
19631         CResult_SharedSecretNoneZ_free(_res_conv);
19632 }
19633
19634 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
19635         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19636         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
19637         return tag_ptr(ret_conv, true);
19638 }
19639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19640         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
19641         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
19642         return ret_conv;
19643 }
19644
19645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19646         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
19647         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19648         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
19649         return tag_ptr(ret_conv, true);
19650 }
19651
19652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19653         void* o_ptr = untag_ptr(o);
19654         CHECK_ACCESS(o_ptr);
19655         LDKSign o_conv = *(LDKSign*)(o_ptr);
19656         if (o_conv.free == LDKSign_JCalls_free) {
19657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19658                 LDKSign_JCalls_cloned(&o_conv);
19659         }
19660         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19661         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
19662         return tag_ptr(ret_conv, true);
19663 }
19664
19665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19666         void* e_ptr = untag_ptr(e);
19667         CHECK_ACCESS(e_ptr);
19668         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19669         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19670         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19671         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19672         return tag_ptr(ret_conv, true);
19673 }
19674
19675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19676         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
19677         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19678         return ret_conv;
19679 }
19680
19681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19682         if (!ptr_is_owned(_res)) return;
19683         void* _res_ptr = untag_ptr(_res);
19684         CHECK_ACCESS(_res_ptr);
19685         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19686         FREE(untag_ptr(_res));
19687         CResult_SignDecodeErrorZ_free(_res_conv);
19688 }
19689
19690 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19691         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19692         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19693         return tag_ptr(ret_conv, true);
19694 }
19695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19696         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
19697         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19698         return ret_conv;
19699 }
19700
19701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19702         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
19703         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19704         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19705         return tag_ptr(ret_conv, true);
19706 }
19707
19708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19709         LDKCVec_u5Z _res_constr;
19710         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19711         if (_res_constr.datalen > 0)
19712                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19713         else
19714                 _res_constr.data = NULL;
19715         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19716         for (size_t h = 0; h < _res_constr.datalen; h++) {
19717                 int8_t _res_conv_7 = _res_vals[h];
19718                 
19719                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19720         }
19721         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19722         CVec_u5Z_free(_res_constr);
19723 }
19724
19725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19726         LDKRecoverableSignature o_ref;
19727         CHECK((*env)->GetArrayLength(env, o) == 68);
19728         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19729         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19730         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19731         return tag_ptr(ret_conv, true);
19732 }
19733
19734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19735         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19736         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19737         return tag_ptr(ret_conv, true);
19738 }
19739
19740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19741         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
19742         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19743         return ret_conv;
19744 }
19745
19746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19747         if (!ptr_is_owned(_res)) return;
19748         void* _res_ptr = untag_ptr(_res);
19749         CHECK_ACCESS(_res_ptr);
19750         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19751         FREE(untag_ptr(_res));
19752         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19753 }
19754
19755 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19756         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19757         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19758         return tag_ptr(ret_conv, true);
19759 }
19760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19761         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
19762         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19763         return ret_conv;
19764 }
19765
19766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19767         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
19768         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19769         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19770         return tag_ptr(ret_conv, true);
19771 }
19772
19773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19774         LDKCVec_u8Z _res_ref;
19775         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19776         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19777         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19778         CVec_u8Z_free(_res_ref);
19779 }
19780
19781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19782         LDKCVec_CVec_u8ZZ _res_constr;
19783         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19784         if (_res_constr.datalen > 0)
19785                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19786         else
19787                 _res_constr.data = NULL;
19788         for (size_t i = 0; i < _res_constr.datalen; i++) {
19789                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19790                 LDKCVec_u8Z _res_conv_8_ref;
19791                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19792                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19793                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19794                 _res_constr.data[i] = _res_conv_8_ref;
19795         }
19796         CVec_CVec_u8ZZ_free(_res_constr);
19797 }
19798
19799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19800         LDKCVec_CVec_u8ZZ o_constr;
19801         o_constr.datalen = (*env)->GetArrayLength(env, o);
19802         if (o_constr.datalen > 0)
19803                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19804         else
19805                 o_constr.data = NULL;
19806         for (size_t i = 0; i < o_constr.datalen; i++) {
19807                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19808                 LDKCVec_u8Z o_conv_8_ref;
19809                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19810                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19811                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19812                 o_constr.data[i] = o_conv_8_ref;
19813         }
19814         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19815         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19816         return tag_ptr(ret_conv, true);
19817 }
19818
19819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19820         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19821         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19822         return tag_ptr(ret_conv, true);
19823 }
19824
19825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19826         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
19827         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19828         return ret_conv;
19829 }
19830
19831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19832         if (!ptr_is_owned(_res)) return;
19833         void* _res_ptr = untag_ptr(_res);
19834         CHECK_ACCESS(_res_ptr);
19835         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19836         FREE(untag_ptr(_res));
19837         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19838 }
19839
19840 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19841         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19842         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19843         return tag_ptr(ret_conv, true);
19844 }
19845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19846         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
19847         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19848         return ret_conv;
19849 }
19850
19851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19852         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
19853         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19854         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19855         return tag_ptr(ret_conv, true);
19856 }
19857
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19859         LDKInMemorySigner o_conv;
19860         o_conv.inner = untag_ptr(o);
19861         o_conv.is_owned = ptr_is_owned(o);
19862         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19863         o_conv = InMemorySigner_clone(&o_conv);
19864         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19865         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19866         return tag_ptr(ret_conv, true);
19867 }
19868
19869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19870         void* e_ptr = untag_ptr(e);
19871         CHECK_ACCESS(e_ptr);
19872         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19873         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19874         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19875         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19876         return tag_ptr(ret_conv, true);
19877 }
19878
19879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19880         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
19881         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19882         return ret_conv;
19883 }
19884
19885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19886         if (!ptr_is_owned(_res)) return;
19887         void* _res_ptr = untag_ptr(_res);
19888         CHECK_ACCESS(_res_ptr);
19889         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19890         FREE(untag_ptr(_res));
19891         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19892 }
19893
19894 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19895         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19896         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19897         return tag_ptr(ret_conv, true);
19898 }
19899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19900         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
19901         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19902         return ret_conv;
19903 }
19904
19905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19906         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
19907         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19908         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19909         return tag_ptr(ret_conv, true);
19910 }
19911
19912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19913         LDKCVec_TxOutZ _res_constr;
19914         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19915         if (_res_constr.datalen > 0)
19916                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19917         else
19918                 _res_constr.data = NULL;
19919         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19920         for (size_t h = 0; h < _res_constr.datalen; h++) {
19921                 int64_t _res_conv_7 = _res_vals[h];
19922                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
19923                 CHECK_ACCESS(_res_conv_7_ptr);
19924                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19925                 FREE(untag_ptr(_res_conv_7));
19926                 _res_constr.data[h] = _res_conv_7_conv;
19927         }
19928         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19929         CVec_TxOutZ_free(_res_constr);
19930 }
19931
19932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19933         LDKTransaction o_ref;
19934         o_ref.datalen = (*env)->GetArrayLength(env, o);
19935         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19936         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19937         o_ref.data_is_owned = true;
19938         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19939         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19940         return tag_ptr(ret_conv, true);
19941 }
19942
19943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19944         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19945         *ret_conv = CResult_TransactionNoneZ_err();
19946         return tag_ptr(ret_conv, true);
19947 }
19948
19949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19950         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
19951         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19952         return ret_conv;
19953 }
19954
19955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19956         if (!ptr_is_owned(_res)) return;
19957         void* _res_ptr = untag_ptr(_res);
19958         CHECK_ACCESS(_res_ptr);
19959         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19960         FREE(untag_ptr(_res));
19961         CResult_TransactionNoneZ_free(_res_conv);
19962 }
19963
19964 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19965         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19966         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19967         return tag_ptr(ret_conv, true);
19968 }
19969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19970         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
19971         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19972         return ret_conv;
19973 }
19974
19975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19976         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
19977         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19978         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19979         return tag_ptr(ret_conv, true);
19980 }
19981
19982 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19983         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19984         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19985         return tag_ptr(ret_conv, true);
19986 }
19987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19988         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
19989         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19990         return ret_conv;
19991 }
19992
19993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19994         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
19995         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19996         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19997         return tag_ptr(ret_conv, true);
19998 }
19999
20000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20001         LDKThirtyTwoBytes a_ref;
20002         CHECK((*env)->GetArrayLength(env, a) == 32);
20003         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20004         LDKChannelMonitor b_conv;
20005         b_conv.inner = untag_ptr(b);
20006         b_conv.is_owned = ptr_is_owned(b);
20007         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20008         b_conv = ChannelMonitor_clone(&b_conv);
20009         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20010         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
20011         return tag_ptr(ret_conv, true);
20012 }
20013
20014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20015         if (!ptr_is_owned(_res)) return;
20016         void* _res_ptr = untag_ptr(_res);
20017         CHECK_ACCESS(_res_ptr);
20018         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
20019         FREE(untag_ptr(_res));
20020         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
20021 }
20022
20023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20024         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
20025         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20026         if (_res_constr.datalen > 0)
20027                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20028         else
20029                 _res_constr.data = NULL;
20030         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20031         for (size_t j = 0; j < _res_constr.datalen; j++) {
20032                 int64_t _res_conv_35 = _res_vals[j];
20033                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
20034                 CHECK_ACCESS(_res_conv_35_ptr);
20035                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
20036                 FREE(untag_ptr(_res_conv_35));
20037                 _res_constr.data[j] = _res_conv_35_conv;
20038         }
20039         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20040         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
20041 }
20042
20043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
20044         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
20045         o_constr.datalen = (*env)->GetArrayLength(env, o);
20046         if (o_constr.datalen > 0)
20047                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20048         else
20049                 o_constr.data = NULL;
20050         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20051         for (size_t j = 0; j < o_constr.datalen; j++) {
20052                 int64_t o_conv_35 = o_vals[j];
20053                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
20054                 CHECK_ACCESS(o_conv_35_ptr);
20055                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
20056                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
20057                 o_constr.data[j] = o_conv_35_conv;
20058         }
20059         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20060         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20061         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
20062         return tag_ptr(ret_conv, true);
20063 }
20064
20065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20066         LDKIOError e_conv = LDKIOError_from_java(env, e);
20067         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20068         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
20069         return tag_ptr(ret_conv, true);
20070 }
20071
20072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20073         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
20074         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
20075         return ret_conv;
20076 }
20077
20078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20079         if (!ptr_is_owned(_res)) return;
20080         void* _res_ptr = untag_ptr(_res);
20081         CHECK_ACCESS(_res_ptr);
20082         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
20083         FREE(untag_ptr(_res));
20084         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
20085 }
20086
20087 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
20088         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20089         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
20090         return tag_ptr(ret_conv, true);
20091 }
20092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20093         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
20094         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
20095         return ret_conv;
20096 }
20097
20098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20099         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
20100         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20101         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
20102         return tag_ptr(ret_conv, true);
20103 }
20104
20105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
20106         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20107         *ret_copy = COption_u16Z_some(o);
20108         int64_t ret_ref = tag_ptr(ret_copy, true);
20109         return ret_ref;
20110 }
20111
20112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
20113         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20114         *ret_copy = COption_u16Z_none();
20115         int64_t ret_ref = tag_ptr(ret_copy, true);
20116         return ret_ref;
20117 }
20118
20119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
20120         if (!ptr_is_owned(_res)) return;
20121         void* _res_ptr = untag_ptr(_res);
20122         CHECK_ACCESS(_res_ptr);
20123         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
20124         FREE(untag_ptr(_res));
20125         COption_u16Z_free(_res_conv);
20126 }
20127
20128 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
20129         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20130         *ret_copy = COption_u16Z_clone(arg);
20131         int64_t ret_ref = tag_ptr(ret_copy, true);
20132         return ret_ref;
20133 }
20134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20135         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
20136         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
20137         return ret_conv;
20138 }
20139
20140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20141         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
20142         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20143         *ret_copy = COption_u16Z_clone(orig_conv);
20144         int64_t ret_ref = tag_ptr(ret_copy, true);
20145         return ret_ref;
20146 }
20147
20148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
20149         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20150         *ret_conv = CResult_NoneAPIErrorZ_ok();
20151         return tag_ptr(ret_conv, true);
20152 }
20153
20154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20155         void* e_ptr = untag_ptr(e);
20156         CHECK_ACCESS(e_ptr);
20157         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20158         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20159         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20160         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
20161         return tag_ptr(ret_conv, true);
20162 }
20163
20164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20165         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
20166         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
20167         return ret_conv;
20168 }
20169
20170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20171         if (!ptr_is_owned(_res)) return;
20172         void* _res_ptr = untag_ptr(_res);
20173         CHECK_ACCESS(_res_ptr);
20174         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
20175         FREE(untag_ptr(_res));
20176         CResult_NoneAPIErrorZ_free(_res_conv);
20177 }
20178
20179 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
20180         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20181         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
20182         return tag_ptr(ret_conv, true);
20183 }
20184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20185         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
20186         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
20187         return ret_conv;
20188 }
20189
20190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20191         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
20192         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20193         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
20194         return tag_ptr(ret_conv, true);
20195 }
20196
20197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20198         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
20199         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20200         if (_res_constr.datalen > 0)
20201                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
20202         else
20203                 _res_constr.data = NULL;
20204         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20205         for (size_t w = 0; w < _res_constr.datalen; w++) {
20206                 int64_t _res_conv_22 = _res_vals[w];
20207                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20208                 CHECK_ACCESS(_res_conv_22_ptr);
20209                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
20210                 FREE(untag_ptr(_res_conv_22));
20211                 _res_constr.data[w] = _res_conv_22_conv;
20212         }
20213         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20214         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
20215 }
20216
20217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20218         LDKCVec_APIErrorZ _res_constr;
20219         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20220         if (_res_constr.datalen > 0)
20221                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
20222         else
20223                 _res_constr.data = NULL;
20224         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20225         for (size_t k = 0; k < _res_constr.datalen; k++) {
20226                 int64_t _res_conv_10 = _res_vals[k];
20227                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
20228                 CHECK_ACCESS(_res_conv_10_ptr);
20229                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
20230                 FREE(untag_ptr(_res_conv_10));
20231                 _res_constr.data[k] = _res_conv_10_conv;
20232         }
20233         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20234         CVec_APIErrorZ_free(_res_constr);
20235 }
20236
20237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20238         LDKThirtyTwoBytes o_ref;
20239         CHECK((*env)->GetArrayLength(env, o) == 32);
20240         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20241         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20242         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
20243         return tag_ptr(ret_conv, true);
20244 }
20245
20246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20247         void* e_ptr = untag_ptr(e);
20248         CHECK_ACCESS(e_ptr);
20249         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20250         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20251         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20252         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
20253         return tag_ptr(ret_conv, true);
20254 }
20255
20256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20257         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
20258         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
20259         return ret_conv;
20260 }
20261
20262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20263         if (!ptr_is_owned(_res)) return;
20264         void* _res_ptr = untag_ptr(_res);
20265         CHECK_ACCESS(_res_ptr);
20266         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20267         FREE(untag_ptr(_res));
20268         CResult__u832APIErrorZ_free(_res_conv);
20269 }
20270
20271 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20272         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20273         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20274         return tag_ptr(ret_conv, true);
20275 }
20276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20277         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20278         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20279         return ret_conv;
20280 }
20281
20282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20283         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20284         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20285         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20286         return tag_ptr(ret_conv, true);
20287 }
20288
20289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20290         LDKThirtyTwoBytes o_ref;
20291         CHECK((*env)->GetArrayLength(env, o) == 32);
20292         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20293         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20294         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
20295         return tag_ptr(ret_conv, true);
20296 }
20297
20298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20299         void* e_ptr = untag_ptr(e);
20300         CHECK_ACCESS(e_ptr);
20301         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20302         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20303         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20304         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
20305         return tag_ptr(ret_conv, true);
20306 }
20307
20308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20309         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(o);
20310         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
20311         return ret_conv;
20312 }
20313
20314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20315         if (!ptr_is_owned(_res)) return;
20316         void* _res_ptr = untag_ptr(_res);
20317         CHECK_ACCESS(_res_ptr);
20318         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
20319         FREE(untag_ptr(_res));
20320         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
20321 }
20322
20323 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
20324         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20325         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
20326         return tag_ptr(ret_conv, true);
20327 }
20328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20329         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(arg);
20330         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
20331         return ret_conv;
20332 }
20333
20334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20335         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(orig);
20336         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20337         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
20338         return tag_ptr(ret_conv, true);
20339 }
20340
20341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20342         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20343         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20344         return tag_ptr(ret_conv, true);
20345 }
20346
20347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20348         void* e_ptr = untag_ptr(e);
20349         CHECK_ACCESS(e_ptr);
20350         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20351         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20352         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20353         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20354         return tag_ptr(ret_conv, true);
20355 }
20356
20357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20358         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20359         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20360         return ret_conv;
20361 }
20362
20363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20364         if (!ptr_is_owned(_res)) return;
20365         void* _res_ptr = untag_ptr(_res);
20366         CHECK_ACCESS(_res_ptr);
20367         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20368         FREE(untag_ptr(_res));
20369         CResult_NonePaymentSendFailureZ_free(_res_conv);
20370 }
20371
20372 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20373         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20374         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20375         return tag_ptr(ret_conv, true);
20376 }
20377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20378         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20379         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20380         return ret_conv;
20381 }
20382
20383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20384         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20385         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20386         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20387         return tag_ptr(ret_conv, true);
20388 }
20389
20390 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
20391         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20392         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
20393         return tag_ptr(ret_conv, true);
20394 }
20395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20396         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
20397         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
20398         return ret_conv;
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20402         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
20403         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20404         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
20405         return tag_ptr(ret_conv, true);
20406 }
20407
20408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20409         LDKThirtyTwoBytes a_ref;
20410         CHECK((*env)->GetArrayLength(env, a) == 32);
20411         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20412         LDKThirtyTwoBytes b_ref;
20413         CHECK((*env)->GetArrayLength(env, b) == 32);
20414         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20415         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20416         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
20417         return tag_ptr(ret_conv, true);
20418 }
20419
20420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20421         if (!ptr_is_owned(_res)) return;
20422         void* _res_ptr = untag_ptr(_res);
20423         CHECK_ACCESS(_res_ptr);
20424         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
20425         FREE(untag_ptr(_res));
20426         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
20427 }
20428
20429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20430         void* o_ptr = untag_ptr(o);
20431         CHECK_ACCESS(o_ptr);
20432         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
20433         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
20434         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20435         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
20436         return tag_ptr(ret_conv, true);
20437 }
20438
20439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20440         void* e_ptr = untag_ptr(e);
20441         CHECK_ACCESS(e_ptr);
20442         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20443         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20444         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20445         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
20446         return tag_ptr(ret_conv, true);
20447 }
20448
20449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20450         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
20451         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
20452         return ret_conv;
20453 }
20454
20455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20456         if (!ptr_is_owned(_res)) return;
20457         void* _res_ptr = untag_ptr(_res);
20458         CHECK_ACCESS(_res_ptr);
20459         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
20460         FREE(untag_ptr(_res));
20461         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
20462 }
20463
20464 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
20465         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20466         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
20467         return tag_ptr(ret_conv, true);
20468 }
20469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20470         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
20471         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
20472         return ret_conv;
20473 }
20474
20475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20476         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
20477         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20478         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
20479         return tag_ptr(ret_conv, true);
20480 }
20481
20482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20483         LDKCVec_ThirtyTwoBytesZ _res_constr;
20484         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20485         if (_res_constr.datalen > 0)
20486                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
20487         else
20488                 _res_constr.data = NULL;
20489         for (size_t i = 0; i < _res_constr.datalen; i++) {
20490                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20491                 LDKThirtyTwoBytes _res_conv_8_ref;
20492                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20493                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20494                 _res_constr.data[i] = _res_conv_8_ref;
20495         }
20496         CVec_ThirtyTwoBytesZ_free(_res_constr);
20497 }
20498
20499 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
20500         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20501         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
20502         return tag_ptr(ret_conv, true);
20503 }
20504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20505         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
20506         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
20507         return ret_conv;
20508 }
20509
20510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20511         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
20512         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20513         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
20514         return tag_ptr(ret_conv, true);
20515 }
20516
20517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20518         LDKThirtyTwoBytes a_ref;
20519         CHECK((*env)->GetArrayLength(env, a) == 32);
20520         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20521         LDKThirtyTwoBytes b_ref;
20522         CHECK((*env)->GetArrayLength(env, b) == 32);
20523         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20524         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20525         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
20526         return tag_ptr(ret_conv, true);
20527 }
20528
20529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20530         if (!ptr_is_owned(_res)) return;
20531         void* _res_ptr = untag_ptr(_res);
20532         CHECK_ACCESS(_res_ptr);
20533         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
20534         FREE(untag_ptr(_res));
20535         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20539         void* o_ptr = untag_ptr(o);
20540         CHECK_ACCESS(o_ptr);
20541         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20542         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20543         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20544         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
20545         return tag_ptr(ret_conv, true);
20546 }
20547
20548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
20549         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20550         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
20551         return tag_ptr(ret_conv, true);
20552 }
20553
20554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20555         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
20556         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
20557         return ret_conv;
20558 }
20559
20560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20561         if (!ptr_is_owned(_res)) return;
20562         void* _res_ptr = untag_ptr(_res);
20563         CHECK_ACCESS(_res_ptr);
20564         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
20565         FREE(untag_ptr(_res));
20566         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
20567 }
20568
20569 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
20570         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20571         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
20572         return tag_ptr(ret_conv, true);
20573 }
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20575         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
20576         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
20577         return ret_conv;
20578 }
20579
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20581         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
20582         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20583         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
20584         return tag_ptr(ret_conv, true);
20585 }
20586
20587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20588         void* o_ptr = untag_ptr(o);
20589         CHECK_ACCESS(o_ptr);
20590         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20591         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20592         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20593         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
20594         return tag_ptr(ret_conv, true);
20595 }
20596
20597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20598         void* e_ptr = untag_ptr(e);
20599         CHECK_ACCESS(e_ptr);
20600         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20601         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20602         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20603         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
20604         return tag_ptr(ret_conv, true);
20605 }
20606
20607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20608         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
20609         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
20610         return ret_conv;
20611 }
20612
20613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20614         if (!ptr_is_owned(_res)) return;
20615         void* _res_ptr = untag_ptr(_res);
20616         CHECK_ACCESS(_res_ptr);
20617         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
20618         FREE(untag_ptr(_res));
20619         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
20620 }
20621
20622 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
20623         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20624         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
20625         return tag_ptr(ret_conv, true);
20626 }
20627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20628         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
20629         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
20630         return ret_conv;
20631 }
20632
20633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20634         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
20635         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20636         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
20637         return tag_ptr(ret_conv, true);
20638 }
20639
20640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20641         LDKThirtyTwoBytes o_ref;
20642         CHECK((*env)->GetArrayLength(env, o) == 32);
20643         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20644         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20645         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
20646         return tag_ptr(ret_conv, true);
20647 }
20648
20649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20650         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20651         *ret_conv = CResult_PaymentSecretNoneZ_err();
20652         return tag_ptr(ret_conv, true);
20653 }
20654
20655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20656         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
20657         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
20658         return ret_conv;
20659 }
20660
20661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20662         if (!ptr_is_owned(_res)) return;
20663         void* _res_ptr = untag_ptr(_res);
20664         CHECK_ACCESS(_res_ptr);
20665         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
20666         FREE(untag_ptr(_res));
20667         CResult_PaymentSecretNoneZ_free(_res_conv);
20668 }
20669
20670 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20671         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20672         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20673         return tag_ptr(ret_conv, true);
20674 }
20675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20676         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
20677         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20678         return ret_conv;
20679 }
20680
20681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20682         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
20683         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20684         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20685         return tag_ptr(ret_conv, true);
20686 }
20687
20688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20689         LDKThirtyTwoBytes o_ref;
20690         CHECK((*env)->GetArrayLength(env, o) == 32);
20691         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20692         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20693         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20694         return tag_ptr(ret_conv, true);
20695 }
20696
20697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20698         void* e_ptr = untag_ptr(e);
20699         CHECK_ACCESS(e_ptr);
20700         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20701         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20702         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20703         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20704         return tag_ptr(ret_conv, true);
20705 }
20706
20707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20708         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
20709         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20710         return ret_conv;
20711 }
20712
20713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20714         if (!ptr_is_owned(_res)) return;
20715         void* _res_ptr = untag_ptr(_res);
20716         CHECK_ACCESS(_res_ptr);
20717         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20718         FREE(untag_ptr(_res));
20719         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20720 }
20721
20722 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20723         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20724         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20725         return tag_ptr(ret_conv, true);
20726 }
20727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20728         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
20729         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20730         return ret_conv;
20731 }
20732
20733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20734         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
20735         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20736         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20737         return tag_ptr(ret_conv, true);
20738 }
20739
20740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20741         LDKThirtyTwoBytes o_ref;
20742         CHECK((*env)->GetArrayLength(env, o) == 32);
20743         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20744         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20745         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20746         return tag_ptr(ret_conv, true);
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20750         void* e_ptr = untag_ptr(e);
20751         CHECK_ACCESS(e_ptr);
20752         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20753         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20754         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20755         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20756         return tag_ptr(ret_conv, true);
20757 }
20758
20759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20760         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
20761         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20762         return ret_conv;
20763 }
20764
20765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20766         if (!ptr_is_owned(_res)) return;
20767         void* _res_ptr = untag_ptr(_res);
20768         CHECK_ACCESS(_res_ptr);
20769         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20770         FREE(untag_ptr(_res));
20771         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20772 }
20773
20774 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20775         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20776         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20777         return tag_ptr(ret_conv, true);
20778 }
20779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20780         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
20781         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20782         return ret_conv;
20783 }
20784
20785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20786         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
20787         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20788         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20789         return tag_ptr(ret_conv, true);
20790 }
20791
20792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20793         LDKCounterpartyForwardingInfo o_conv;
20794         o_conv.inner = untag_ptr(o);
20795         o_conv.is_owned = ptr_is_owned(o);
20796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20797         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20798         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20799         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20800         return tag_ptr(ret_conv, true);
20801 }
20802
20803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20804         void* e_ptr = untag_ptr(e);
20805         CHECK_ACCESS(e_ptr);
20806         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20807         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20808         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20809         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20810         return tag_ptr(ret_conv, true);
20811 }
20812
20813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20814         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
20815         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20816         return ret_conv;
20817 }
20818
20819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20820         if (!ptr_is_owned(_res)) return;
20821         void* _res_ptr = untag_ptr(_res);
20822         CHECK_ACCESS(_res_ptr);
20823         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20824         FREE(untag_ptr(_res));
20825         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20826 }
20827
20828 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20829         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20830         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20831         return tag_ptr(ret_conv, true);
20832 }
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20834         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
20835         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20836         return ret_conv;
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20840         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
20841         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20842         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20843         return tag_ptr(ret_conv, true);
20844 }
20845
20846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20847         LDKChannelCounterparty o_conv;
20848         o_conv.inner = untag_ptr(o);
20849         o_conv.is_owned = ptr_is_owned(o);
20850         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20851         o_conv = ChannelCounterparty_clone(&o_conv);
20852         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20853         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20854         return tag_ptr(ret_conv, true);
20855 }
20856
20857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20858         void* e_ptr = untag_ptr(e);
20859         CHECK_ACCESS(e_ptr);
20860         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20861         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20862         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20863         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20864         return tag_ptr(ret_conv, true);
20865 }
20866
20867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20868         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
20869         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20870         return ret_conv;
20871 }
20872
20873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20874         if (!ptr_is_owned(_res)) return;
20875         void* _res_ptr = untag_ptr(_res);
20876         CHECK_ACCESS(_res_ptr);
20877         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20878         FREE(untag_ptr(_res));
20879         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20880 }
20881
20882 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20883         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20884         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20885         return tag_ptr(ret_conv, true);
20886 }
20887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20888         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
20889         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20890         return ret_conv;
20891 }
20892
20893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20894         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
20895         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20896         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20897         return tag_ptr(ret_conv, true);
20898 }
20899
20900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20901         LDKChannelDetails o_conv;
20902         o_conv.inner = untag_ptr(o);
20903         o_conv.is_owned = ptr_is_owned(o);
20904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20905         o_conv = ChannelDetails_clone(&o_conv);
20906         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20907         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20908         return tag_ptr(ret_conv, true);
20909 }
20910
20911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20912         void* e_ptr = untag_ptr(e);
20913         CHECK_ACCESS(e_ptr);
20914         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20915         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20916         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20917         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20918         return tag_ptr(ret_conv, true);
20919 }
20920
20921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20922         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
20923         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20924         return ret_conv;
20925 }
20926
20927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20928         if (!ptr_is_owned(_res)) return;
20929         void* _res_ptr = untag_ptr(_res);
20930         CHECK_ACCESS(_res_ptr);
20931         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20932         FREE(untag_ptr(_res));
20933         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20934 }
20935
20936 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20937         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20938         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20939         return tag_ptr(ret_conv, true);
20940 }
20941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20942         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
20943         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20944         return ret_conv;
20945 }
20946
20947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20948         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
20949         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20950         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20951         return tag_ptr(ret_conv, true);
20952 }
20953
20954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20955         LDKPhantomRouteHints o_conv;
20956         o_conv.inner = untag_ptr(o);
20957         o_conv.is_owned = ptr_is_owned(o);
20958         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20959         o_conv = PhantomRouteHints_clone(&o_conv);
20960         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20961         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20962         return tag_ptr(ret_conv, true);
20963 }
20964
20965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20966         void* e_ptr = untag_ptr(e);
20967         CHECK_ACCESS(e_ptr);
20968         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20969         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20970         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20971         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20972         return tag_ptr(ret_conv, true);
20973 }
20974
20975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20976         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
20977         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20978         return ret_conv;
20979 }
20980
20981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20982         if (!ptr_is_owned(_res)) return;
20983         void* _res_ptr = untag_ptr(_res);
20984         CHECK_ACCESS(_res_ptr);
20985         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20986         FREE(untag_ptr(_res));
20987         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20988 }
20989
20990 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20991         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20992         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20993         return tag_ptr(ret_conv, true);
20994 }
20995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20996         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
20997         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
20998         return ret_conv;
20999 }
21000
21001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21002         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21003         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21004         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21005         return tag_ptr(ret_conv, true);
21006 }
21007
21008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21009         LDKCVec_ChannelMonitorZ _res_constr;
21010         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21011         if (_res_constr.datalen > 0)
21012                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21013         else
21014                 _res_constr.data = NULL;
21015         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21016         for (size_t q = 0; q < _res_constr.datalen; q++) {
21017                 int64_t _res_conv_16 = _res_vals[q];
21018                 LDKChannelMonitor _res_conv_16_conv;
21019                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21020                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21021                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21022                 _res_constr.data[q] = _res_conv_16_conv;
21023         }
21024         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21025         CVec_ChannelMonitorZ_free(_res_constr);
21026 }
21027
21028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21029         LDKThirtyTwoBytes a_ref;
21030         CHECK((*env)->GetArrayLength(env, a) == 32);
21031         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21032         LDKChannelManager b_conv;
21033         b_conv.inner = untag_ptr(b);
21034         b_conv.is_owned = ptr_is_owned(b);
21035         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21036         // WARNING: we need a move here but no clone is available for LDKChannelManager
21037         
21038         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
21039         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
21040         return tag_ptr(ret_conv, true);
21041 }
21042
21043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21044         if (!ptr_is_owned(_res)) return;
21045         void* _res_ptr = untag_ptr(_res);
21046         CHECK_ACCESS(_res_ptr);
21047         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
21048         FREE(untag_ptr(_res));
21049         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
21050 }
21051
21052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21053         void* o_ptr = untag_ptr(o);
21054         CHECK_ACCESS(o_ptr);
21055         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
21056         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
21057         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21058         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
21059         return tag_ptr(ret_conv, true);
21060 }
21061
21062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21063         void* e_ptr = untag_ptr(e);
21064         CHECK_ACCESS(e_ptr);
21065         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21066         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21067         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21068         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
21069         return tag_ptr(ret_conv, true);
21070 }
21071
21072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21073         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
21074         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
21075         return ret_conv;
21076 }
21077
21078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21079         if (!ptr_is_owned(_res)) return;
21080         void* _res_ptr = untag_ptr(_res);
21081         CHECK_ACCESS(_res_ptr);
21082         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
21083         FREE(untag_ptr(_res));
21084         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
21085 }
21086
21087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21088         LDKChannelConfig o_conv;
21089         o_conv.inner = untag_ptr(o);
21090         o_conv.is_owned = ptr_is_owned(o);
21091         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21092         o_conv = ChannelConfig_clone(&o_conv);
21093         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21094         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21095         return tag_ptr(ret_conv, true);
21096 }
21097
21098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21099         void* e_ptr = untag_ptr(e);
21100         CHECK_ACCESS(e_ptr);
21101         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21102         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21103         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21104         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21105         return tag_ptr(ret_conv, true);
21106 }
21107
21108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21109         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21110         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21111         return ret_conv;
21112 }
21113
21114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21115         if (!ptr_is_owned(_res)) return;
21116         void* _res_ptr = untag_ptr(_res);
21117         CHECK_ACCESS(_res_ptr);
21118         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21119         FREE(untag_ptr(_res));
21120         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21121 }
21122
21123 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21124         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21125         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21126         return tag_ptr(ret_conv, true);
21127 }
21128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21129         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21130         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21131         return ret_conv;
21132 }
21133
21134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21135         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21136         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21137         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21138         return tag_ptr(ret_conv, true);
21139 }
21140
21141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21142         LDKOutPoint o_conv;
21143         o_conv.inner = untag_ptr(o);
21144         o_conv.is_owned = ptr_is_owned(o);
21145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21146         o_conv = OutPoint_clone(&o_conv);
21147         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21148         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
21149         return tag_ptr(ret_conv, true);
21150 }
21151
21152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21153         void* e_ptr = untag_ptr(e);
21154         CHECK_ACCESS(e_ptr);
21155         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21156         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21157         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21158         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
21159         return tag_ptr(ret_conv, true);
21160 }
21161
21162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21163         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
21164         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
21165         return ret_conv;
21166 }
21167
21168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21169         if (!ptr_is_owned(_res)) return;
21170         void* _res_ptr = untag_ptr(_res);
21171         CHECK_ACCESS(_res_ptr);
21172         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
21173         FREE(untag_ptr(_res));
21174         CResult_OutPointDecodeErrorZ_free(_res_conv);
21175 }
21176
21177 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
21178         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21179         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
21180         return tag_ptr(ret_conv, true);
21181 }
21182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21183         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
21184         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
21185         return ret_conv;
21186 }
21187
21188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21189         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
21190         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21191         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
21192         return tag_ptr(ret_conv, true);
21193 }
21194
21195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21196         void* o_ptr = untag_ptr(o);
21197         CHECK_ACCESS(o_ptr);
21198         LDKType o_conv = *(LDKType*)(o_ptr);
21199         if (o_conv.free == LDKType_JCalls_free) {
21200                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21201                 LDKType_JCalls_cloned(&o_conv);
21202         }
21203         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21204         *ret_copy = COption_TypeZ_some(o_conv);
21205         int64_t ret_ref = tag_ptr(ret_copy, true);
21206         return ret_ref;
21207 }
21208
21209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
21210         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21211         *ret_copy = COption_TypeZ_none();
21212         int64_t ret_ref = tag_ptr(ret_copy, true);
21213         return ret_ref;
21214 }
21215
21216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21217         if (!ptr_is_owned(_res)) return;
21218         void* _res_ptr = untag_ptr(_res);
21219         CHECK_ACCESS(_res_ptr);
21220         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
21221         FREE(untag_ptr(_res));
21222         COption_TypeZ_free(_res_conv);
21223 }
21224
21225 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
21226         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21227         *ret_copy = COption_TypeZ_clone(arg);
21228         int64_t ret_ref = tag_ptr(ret_copy, true);
21229         return ret_ref;
21230 }
21231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21232         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
21233         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
21234         return ret_conv;
21235 }
21236
21237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21238         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
21239         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21240         *ret_copy = COption_TypeZ_clone(orig_conv);
21241         int64_t ret_ref = tag_ptr(ret_copy, true);
21242         return ret_ref;
21243 }
21244
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21246         void* o_ptr = untag_ptr(o);
21247         CHECK_ACCESS(o_ptr);
21248         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
21249         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
21250         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21251         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
21252         return tag_ptr(ret_conv, true);
21253 }
21254
21255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21256         void* e_ptr = untag_ptr(e);
21257         CHECK_ACCESS(e_ptr);
21258         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21259         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21260         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21261         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
21262         return tag_ptr(ret_conv, true);
21263 }
21264
21265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21266         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
21267         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
21268         return ret_conv;
21269 }
21270
21271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21272         if (!ptr_is_owned(_res)) return;
21273         void* _res_ptr = untag_ptr(_res);
21274         CHECK_ACCESS(_res_ptr);
21275         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
21276         FREE(untag_ptr(_res));
21277         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
21278 }
21279
21280 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
21281         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21282         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
21283         return tag_ptr(ret_conv, true);
21284 }
21285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21286         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
21287         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
21288         return ret_conv;
21289 }
21290
21291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21292         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
21293         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21294         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
21295         return tag_ptr(ret_conv, true);
21296 }
21297
21298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21299         LDKThirtyTwoBytes o_ref;
21300         CHECK((*env)->GetArrayLength(env, o) == 32);
21301         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21302         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21303         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
21304         return tag_ptr(ret_conv, true);
21305 }
21306
21307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21308         void* e_ptr = untag_ptr(e);
21309         CHECK_ACCESS(e_ptr);
21310         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
21311         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
21312         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21313         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
21314         return tag_ptr(ret_conv, true);
21315 }
21316
21317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21318         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
21319         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
21320         return ret_conv;
21321 }
21322
21323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21324         if (!ptr_is_owned(_res)) return;
21325         void* _res_ptr = untag_ptr(_res);
21326         CHECK_ACCESS(_res_ptr);
21327         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
21328         FREE(untag_ptr(_res));
21329         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
21330 }
21331
21332 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
21333         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21334         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
21335         return tag_ptr(ret_conv, true);
21336 }
21337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21338         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
21339         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
21340         return ret_conv;
21341 }
21342
21343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21344         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
21345         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21346         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
21347         return tag_ptr(ret_conv, true);
21348 }
21349
21350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21351         LDKInFlightHtlcs o_conv;
21352         o_conv.inner = untag_ptr(o);
21353         o_conv.is_owned = ptr_is_owned(o);
21354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21355         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
21356         
21357         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21358         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
21359         return tag_ptr(ret_conv, true);
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21363         void* e_ptr = untag_ptr(e);
21364         CHECK_ACCESS(e_ptr);
21365         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21366         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21367         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21368         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
21369         return tag_ptr(ret_conv, true);
21370 }
21371
21372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21373         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
21374         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
21375         return ret_conv;
21376 }
21377
21378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21379         if (!ptr_is_owned(_res)) return;
21380         void* _res_ptr = untag_ptr(_res);
21381         CHECK_ACCESS(_res_ptr);
21382         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
21383         FREE(untag_ptr(_res));
21384         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
21385 }
21386
21387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
21388         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
21389         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21390         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
21391         return tag_ptr(ret_conv, true);
21392 }
21393
21394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21395         void* e_ptr = untag_ptr(e);
21396         CHECK_ACCESS(e_ptr);
21397         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21398         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21399         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21400         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
21401         return tag_ptr(ret_conv, true);
21402 }
21403
21404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21405         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
21406         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
21407         return ret_conv;
21408 }
21409
21410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21411         if (!ptr_is_owned(_res)) return;
21412         void* _res_ptr = untag_ptr(_res);
21413         CHECK_ACCESS(_res_ptr);
21414         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
21415         FREE(untag_ptr(_res));
21416         CResult_SiPrefixParseErrorZ_free(_res_conv);
21417 }
21418
21419 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
21420         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21421         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
21422         return tag_ptr(ret_conv, true);
21423 }
21424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21425         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
21426         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
21427         return ret_conv;
21428 }
21429
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21431         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
21432         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21433         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
21434         return tag_ptr(ret_conv, true);
21435 }
21436
21437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21438         LDKInvoice o_conv;
21439         o_conv.inner = untag_ptr(o);
21440         o_conv.is_owned = ptr_is_owned(o);
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21442         o_conv = Invoice_clone(&o_conv);
21443         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21444         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
21445         return tag_ptr(ret_conv, true);
21446 }
21447
21448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21449         void* e_ptr = untag_ptr(e);
21450         CHECK_ACCESS(e_ptr);
21451         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
21452         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
21453         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21454         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
21455         return tag_ptr(ret_conv, true);
21456 }
21457
21458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21459         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
21460         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
21461         return ret_conv;
21462 }
21463
21464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21465         if (!ptr_is_owned(_res)) return;
21466         void* _res_ptr = untag_ptr(_res);
21467         CHECK_ACCESS(_res_ptr);
21468         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
21469         FREE(untag_ptr(_res));
21470         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
21471 }
21472
21473 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
21474         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21475         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
21476         return tag_ptr(ret_conv, true);
21477 }
21478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21479         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
21480         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
21481         return ret_conv;
21482 }
21483
21484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21485         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
21486         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21487         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
21488         return tag_ptr(ret_conv, true);
21489 }
21490
21491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21492         LDKSignedRawInvoice o_conv;
21493         o_conv.inner = untag_ptr(o);
21494         o_conv.is_owned = ptr_is_owned(o);
21495         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21496         o_conv = SignedRawInvoice_clone(&o_conv);
21497         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21498         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
21499         return tag_ptr(ret_conv, true);
21500 }
21501
21502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21503         void* e_ptr = untag_ptr(e);
21504         CHECK_ACCESS(e_ptr);
21505         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21506         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21507         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21508         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
21509         return tag_ptr(ret_conv, true);
21510 }
21511
21512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21513         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
21514         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
21515         return ret_conv;
21516 }
21517
21518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21519         if (!ptr_is_owned(_res)) return;
21520         void* _res_ptr = untag_ptr(_res);
21521         CHECK_ACCESS(_res_ptr);
21522         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
21523         FREE(untag_ptr(_res));
21524         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
21525 }
21526
21527 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
21528         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21529         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
21530         return tag_ptr(ret_conv, true);
21531 }
21532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21533         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
21534         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
21535         return ret_conv;
21536 }
21537
21538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21539         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
21540         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21541         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
21542         return tag_ptr(ret_conv, true);
21543 }
21544
21545 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
21546         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21547         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
21548         return tag_ptr(ret_conv, true);
21549 }
21550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21551         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
21552         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
21553         return ret_conv;
21554 }
21555
21556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21557         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
21558         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21559         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
21560         return tag_ptr(ret_conv, true);
21561 }
21562
21563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
21564         LDKRawInvoice a_conv;
21565         a_conv.inner = untag_ptr(a);
21566         a_conv.is_owned = ptr_is_owned(a);
21567         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21568         a_conv = RawInvoice_clone(&a_conv);
21569         LDKThirtyTwoBytes b_ref;
21570         CHECK((*env)->GetArrayLength(env, b) == 32);
21571         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21572         LDKInvoiceSignature c_conv;
21573         c_conv.inner = untag_ptr(c);
21574         c_conv.is_owned = ptr_is_owned(c);
21575         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
21576         c_conv = InvoiceSignature_clone(&c_conv);
21577         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21578         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
21579         return tag_ptr(ret_conv, true);
21580 }
21581
21582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21583         if (!ptr_is_owned(_res)) return;
21584         void* _res_ptr = untag_ptr(_res);
21585         CHECK_ACCESS(_res_ptr);
21586         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
21587         FREE(untag_ptr(_res));
21588         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
21589 }
21590
21591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21592         LDKPayeePubKey o_conv;
21593         o_conv.inner = untag_ptr(o);
21594         o_conv.is_owned = ptr_is_owned(o);
21595         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21596         o_conv = PayeePubKey_clone(&o_conv);
21597         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21598         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
21599         return tag_ptr(ret_conv, true);
21600 }
21601
21602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21603         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21604         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21605         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
21606         return tag_ptr(ret_conv, true);
21607 }
21608
21609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21610         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
21611         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
21612         return ret_conv;
21613 }
21614
21615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21616         if (!ptr_is_owned(_res)) return;
21617         void* _res_ptr = untag_ptr(_res);
21618         CHECK_ACCESS(_res_ptr);
21619         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
21620         FREE(untag_ptr(_res));
21621         CResult_PayeePubKeyErrorZ_free(_res_conv);
21622 }
21623
21624 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
21625         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21626         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
21627         return tag_ptr(ret_conv, true);
21628 }
21629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21630         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
21631         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
21632         return ret_conv;
21633 }
21634
21635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21636         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
21637         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21638         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
21639         return tag_ptr(ret_conv, true);
21640 }
21641
21642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21643         LDKCVec_PrivateRouteZ _res_constr;
21644         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21645         if (_res_constr.datalen > 0)
21646                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
21647         else
21648                 _res_constr.data = NULL;
21649         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21650         for (size_t o = 0; o < _res_constr.datalen; o++) {
21651                 int64_t _res_conv_14 = _res_vals[o];
21652                 LDKPrivateRoute _res_conv_14_conv;
21653                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
21654                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
21655                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
21656                 _res_constr.data[o] = _res_conv_14_conv;
21657         }
21658         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21659         CVec_PrivateRouteZ_free(_res_constr);
21660 }
21661
21662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21663         LDKPositiveTimestamp o_conv;
21664         o_conv.inner = untag_ptr(o);
21665         o_conv.is_owned = ptr_is_owned(o);
21666         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21667         o_conv = PositiveTimestamp_clone(&o_conv);
21668         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21669         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
21670         return tag_ptr(ret_conv, true);
21671 }
21672
21673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21674         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21675         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21676         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
21677         return tag_ptr(ret_conv, true);
21678 }
21679
21680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21681         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
21682         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
21683         return ret_conv;
21684 }
21685
21686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21687         if (!ptr_is_owned(_res)) return;
21688         void* _res_ptr = untag_ptr(_res);
21689         CHECK_ACCESS(_res_ptr);
21690         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
21691         FREE(untag_ptr(_res));
21692         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
21693 }
21694
21695 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
21696         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21697         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
21698         return tag_ptr(ret_conv, true);
21699 }
21700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21701         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
21702         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21703         return ret_conv;
21704 }
21705
21706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21707         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
21708         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21709         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21710         return tag_ptr(ret_conv, true);
21711 }
21712
21713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21714         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21715         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21716         return tag_ptr(ret_conv, true);
21717 }
21718
21719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21720         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21721         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21722         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21723         return tag_ptr(ret_conv, true);
21724 }
21725
21726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21727         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
21728         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21729         return ret_conv;
21730 }
21731
21732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21733         if (!ptr_is_owned(_res)) return;
21734         void* _res_ptr = untag_ptr(_res);
21735         CHECK_ACCESS(_res_ptr);
21736         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21737         FREE(untag_ptr(_res));
21738         CResult_NoneSemanticErrorZ_free(_res_conv);
21739 }
21740
21741 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21742         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21743         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21744         return tag_ptr(ret_conv, true);
21745 }
21746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21747         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
21748         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21749         return ret_conv;
21750 }
21751
21752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21753         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
21754         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21755         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21756         return tag_ptr(ret_conv, true);
21757 }
21758
21759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21760         LDKInvoice o_conv;
21761         o_conv.inner = untag_ptr(o);
21762         o_conv.is_owned = ptr_is_owned(o);
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21764         o_conv = Invoice_clone(&o_conv);
21765         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21766         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21767         return tag_ptr(ret_conv, true);
21768 }
21769
21770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21771         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21772         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21773         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21774         return tag_ptr(ret_conv, true);
21775 }
21776
21777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21778         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
21779         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21780         return ret_conv;
21781 }
21782
21783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21784         if (!ptr_is_owned(_res)) return;
21785         void* _res_ptr = untag_ptr(_res);
21786         CHECK_ACCESS(_res_ptr);
21787         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21788         FREE(untag_ptr(_res));
21789         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21790 }
21791
21792 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21793         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21794         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21795         return tag_ptr(ret_conv, true);
21796 }
21797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21798         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
21799         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21800         return ret_conv;
21801 }
21802
21803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21804         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
21805         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21806         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21807         return tag_ptr(ret_conv, true);
21808 }
21809
21810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21811         LDKDescription o_conv;
21812         o_conv.inner = untag_ptr(o);
21813         o_conv.is_owned = ptr_is_owned(o);
21814         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21815         o_conv = Description_clone(&o_conv);
21816         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21817         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21818         return tag_ptr(ret_conv, true);
21819 }
21820
21821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21822         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21823         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21824         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21825         return tag_ptr(ret_conv, true);
21826 }
21827
21828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21829         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
21830         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21831         return ret_conv;
21832 }
21833
21834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21835         if (!ptr_is_owned(_res)) return;
21836         void* _res_ptr = untag_ptr(_res);
21837         CHECK_ACCESS(_res_ptr);
21838         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21839         FREE(untag_ptr(_res));
21840         CResult_DescriptionCreationErrorZ_free(_res_conv);
21841 }
21842
21843 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21844         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21845         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21846         return tag_ptr(ret_conv, true);
21847 }
21848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21849         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
21850         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21851         return ret_conv;
21852 }
21853
21854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21855         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
21856         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21857         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21858         return tag_ptr(ret_conv, true);
21859 }
21860
21861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21862         LDKPrivateRoute o_conv;
21863         o_conv.inner = untag_ptr(o);
21864         o_conv.is_owned = ptr_is_owned(o);
21865         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21866         o_conv = PrivateRoute_clone(&o_conv);
21867         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21868         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21869         return tag_ptr(ret_conv, true);
21870 }
21871
21872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21873         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21874         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21875         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21876         return tag_ptr(ret_conv, true);
21877 }
21878
21879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21880         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
21881         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21882         return ret_conv;
21883 }
21884
21885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21886         if (!ptr_is_owned(_res)) return;
21887         void* _res_ptr = untag_ptr(_res);
21888         CHECK_ACCESS(_res_ptr);
21889         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21890         FREE(untag_ptr(_res));
21891         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21892 }
21893
21894 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21895         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21896         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21897         return tag_ptr(ret_conv, true);
21898 }
21899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21900         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
21901         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21902         return ret_conv;
21903 }
21904
21905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21906         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
21907         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21908         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21909         return tag_ptr(ret_conv, true);
21910 }
21911
21912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21913         LDKStr o_conv = java_to_owned_str(env, o);
21914         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21915         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21916         return tag_ptr(ret_conv, true);
21917 }
21918
21919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21920         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21921         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21922         *ret_conv = CResult_StringErrorZ_err(e_conv);
21923         return tag_ptr(ret_conv, true);
21924 }
21925
21926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21927         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
21928         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21929         return ret_conv;
21930 }
21931
21932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21933         if (!ptr_is_owned(_res)) return;
21934         void* _res_ptr = untag_ptr(_res);
21935         CHECK_ACCESS(_res_ptr);
21936         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21937         FREE(untag_ptr(_res));
21938         CResult_StringErrorZ_free(_res_conv);
21939 }
21940
21941 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21942         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21943         *ret_conv = CResult_StringErrorZ_clone(arg);
21944         return tag_ptr(ret_conv, true);
21945 }
21946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21947         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
21948         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21949         return ret_conv;
21950 }
21951
21952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21953         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
21954         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21955         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21956         return tag_ptr(ret_conv, true);
21957 }
21958
21959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21960         LDKChannelMonitorUpdate o_conv;
21961         o_conv.inner = untag_ptr(o);
21962         o_conv.is_owned = ptr_is_owned(o);
21963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21964         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21965         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21966         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21967         return tag_ptr(ret_conv, true);
21968 }
21969
21970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21971         void* e_ptr = untag_ptr(e);
21972         CHECK_ACCESS(e_ptr);
21973         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21974         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21975         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21976         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21977         return tag_ptr(ret_conv, true);
21978 }
21979
21980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21981         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
21982         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21983         return ret_conv;
21984 }
21985
21986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21987         if (!ptr_is_owned(_res)) return;
21988         void* _res_ptr = untag_ptr(_res);
21989         CHECK_ACCESS(_res_ptr);
21990         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21991         FREE(untag_ptr(_res));
21992         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21993 }
21994
21995 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21996         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21997         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
21998         return tag_ptr(ret_conv, true);
21999 }
22000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22001         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22002         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22003         return ret_conv;
22004 }
22005
22006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22007         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22008         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22009         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22010         return tag_ptr(ret_conv, true);
22011 }
22012
22013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22014         void* o_ptr = untag_ptr(o);
22015         CHECK_ACCESS(o_ptr);
22016         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22017         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22018         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22019         *ret_copy = COption_MonitorEventZ_some(o_conv);
22020         int64_t ret_ref = tag_ptr(ret_copy, true);
22021         return ret_ref;
22022 }
22023
22024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
22025         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22026         *ret_copy = COption_MonitorEventZ_none();
22027         int64_t ret_ref = tag_ptr(ret_copy, true);
22028         return ret_ref;
22029 }
22030
22031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22032         if (!ptr_is_owned(_res)) return;
22033         void* _res_ptr = untag_ptr(_res);
22034         CHECK_ACCESS(_res_ptr);
22035         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22036         FREE(untag_ptr(_res));
22037         COption_MonitorEventZ_free(_res_conv);
22038 }
22039
22040 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22041         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22042         *ret_copy = COption_MonitorEventZ_clone(arg);
22043         int64_t ret_ref = tag_ptr(ret_copy, true);
22044         return ret_ref;
22045 }
22046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22047         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22048         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22049         return ret_conv;
22050 }
22051
22052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22053         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22054         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22055         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22056         int64_t ret_ref = tag_ptr(ret_copy, true);
22057         return ret_ref;
22058 }
22059
22060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22061         void* o_ptr = untag_ptr(o);
22062         CHECK_ACCESS(o_ptr);
22063         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22064         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22065         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22066         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22067         return tag_ptr(ret_conv, true);
22068 }
22069
22070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22071         void* e_ptr = untag_ptr(e);
22072         CHECK_ACCESS(e_ptr);
22073         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22074         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22075         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22076         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22077         return tag_ptr(ret_conv, true);
22078 }
22079
22080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22081         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22082         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22083         return ret_conv;
22084 }
22085
22086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22087         if (!ptr_is_owned(_res)) return;
22088         void* _res_ptr = untag_ptr(_res);
22089         CHECK_ACCESS(_res_ptr);
22090         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22091         FREE(untag_ptr(_res));
22092         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22093 }
22094
22095 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22096         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22097         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22098         return tag_ptr(ret_conv, true);
22099 }
22100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22101         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22102         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22103         return ret_conv;
22104 }
22105
22106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22107         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22108         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22109         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22110         return tag_ptr(ret_conv, true);
22111 }
22112
22113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22114         LDKHTLCUpdate o_conv;
22115         o_conv.inner = untag_ptr(o);
22116         o_conv.is_owned = ptr_is_owned(o);
22117         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22118         o_conv = HTLCUpdate_clone(&o_conv);
22119         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22120         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22121         return tag_ptr(ret_conv, true);
22122 }
22123
22124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22125         void* e_ptr = untag_ptr(e);
22126         CHECK_ACCESS(e_ptr);
22127         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22128         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22129         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22130         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22131         return tag_ptr(ret_conv, true);
22132 }
22133
22134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22135         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22136         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22137         return ret_conv;
22138 }
22139
22140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22141         if (!ptr_is_owned(_res)) return;
22142         void* _res_ptr = untag_ptr(_res);
22143         CHECK_ACCESS(_res_ptr);
22144         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22145         FREE(untag_ptr(_res));
22146         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22147 }
22148
22149 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22150         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22151         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22152         return tag_ptr(ret_conv, true);
22153 }
22154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22155         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22156         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22157         return ret_conv;
22158 }
22159
22160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22161         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22162         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22163         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22164         return tag_ptr(ret_conv, true);
22165 }
22166
22167 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
22168         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22169         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
22170         return tag_ptr(ret_conv, true);
22171 }
22172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22173         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
22174         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
22175         return ret_conv;
22176 }
22177
22178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22179         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
22180         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22181         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
22182         return tag_ptr(ret_conv, true);
22183 }
22184
22185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
22186         LDKOutPoint a_conv;
22187         a_conv.inner = untag_ptr(a);
22188         a_conv.is_owned = ptr_is_owned(a);
22189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22190         a_conv = OutPoint_clone(&a_conv);
22191         LDKCVec_u8Z b_ref;
22192         b_ref.datalen = (*env)->GetArrayLength(env, b);
22193         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22194         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22195         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22196         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
22197         return tag_ptr(ret_conv, true);
22198 }
22199
22200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22201         if (!ptr_is_owned(_res)) return;
22202         void* _res_ptr = untag_ptr(_res);
22203         CHECK_ACCESS(_res_ptr);
22204         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
22205         FREE(untag_ptr(_res));
22206         C2Tuple_OutPointScriptZ_free(_res_conv);
22207 }
22208
22209 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
22210         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22211         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
22212         return tag_ptr(ret_conv, true);
22213 }
22214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22215         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
22216         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
22217         return ret_conv;
22218 }
22219
22220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22221         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
22222         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22223         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
22224         return tag_ptr(ret_conv, true);
22225 }
22226
22227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
22228         LDKCVec_u8Z b_ref;
22229         b_ref.datalen = (*env)->GetArrayLength(env, b);
22230         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22231         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22232         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22233         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
22234         return tag_ptr(ret_conv, true);
22235 }
22236
22237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22238         if (!ptr_is_owned(_res)) return;
22239         void* _res_ptr = untag_ptr(_res);
22240         CHECK_ACCESS(_res_ptr);
22241         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
22242         FREE(untag_ptr(_res));
22243         C2Tuple_u32ScriptZ_free(_res_conv);
22244 }
22245
22246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22247         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
22248         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22249         if (_res_constr.datalen > 0)
22250                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22251         else
22252                 _res_constr.data = NULL;
22253         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22254         for (size_t v = 0; v < _res_constr.datalen; v++) {
22255                 int64_t _res_conv_21 = _res_vals[v];
22256                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22257                 CHECK_ACCESS(_res_conv_21_ptr);
22258                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22259                 FREE(untag_ptr(_res_conv_21));
22260                 _res_constr.data[v] = _res_conv_21_conv;
22261         }
22262         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22263         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22264 }
22265
22266 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22267         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22268         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22269         return tag_ptr(ret_conv, true);
22270 }
22271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22272         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22273         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22274         return ret_conv;
22275 }
22276
22277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22278         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22279         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22280         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22281         return tag_ptr(ret_conv, true);
22282 }
22283
22284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22285         LDKThirtyTwoBytes a_ref;
22286         CHECK((*env)->GetArrayLength(env, a) == 32);
22287         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22288         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22289         b_constr.datalen = (*env)->GetArrayLength(env, b);
22290         if (b_constr.datalen > 0)
22291                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22292         else
22293                 b_constr.data = NULL;
22294         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22295         for (size_t v = 0; v < b_constr.datalen; v++) {
22296                 int64_t b_conv_21 = b_vals[v];
22297                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22298                 CHECK_ACCESS(b_conv_21_ptr);
22299                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22300                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22301                 b_constr.data[v] = b_conv_21_conv;
22302         }
22303         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22304         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22305         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22306         return tag_ptr(ret_conv, true);
22307 }
22308
22309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22310         if (!ptr_is_owned(_res)) return;
22311         void* _res_ptr = untag_ptr(_res);
22312         CHECK_ACCESS(_res_ptr);
22313         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22314         FREE(untag_ptr(_res));
22315         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22316 }
22317
22318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22319         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22320         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22321         if (_res_constr.datalen > 0)
22322                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22323         else
22324                 _res_constr.data = NULL;
22325         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22326         for (size_t o = 0; o < _res_constr.datalen; o++) {
22327                 int64_t _res_conv_40 = _res_vals[o];
22328                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22329                 CHECK_ACCESS(_res_conv_40_ptr);
22330                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22331                 FREE(untag_ptr(_res_conv_40));
22332                 _res_constr.data[o] = _res_conv_40_conv;
22333         }
22334         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22335         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22336 }
22337
22338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22339         LDKCVec_EventZ _res_constr;
22340         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22341         if (_res_constr.datalen > 0)
22342                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22343         else
22344                 _res_constr.data = NULL;
22345         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22346         for (size_t h = 0; h < _res_constr.datalen; h++) {
22347                 int64_t _res_conv_7 = _res_vals[h];
22348                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22349                 CHECK_ACCESS(_res_conv_7_ptr);
22350                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22351                 FREE(untag_ptr(_res_conv_7));
22352                 _res_constr.data[h] = _res_conv_7_conv;
22353         }
22354         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22355         CVec_EventZ_free(_res_constr);
22356 }
22357
22358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22359         LDKCVec_TransactionZ _res_constr;
22360         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22361         if (_res_constr.datalen > 0)
22362                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22363         else
22364                 _res_constr.data = NULL;
22365         for (size_t i = 0; i < _res_constr.datalen; i++) {
22366                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22367                 LDKTransaction _res_conv_8_ref;
22368                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22369                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22370                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22371                 _res_conv_8_ref.data_is_owned = true;
22372                 _res_constr.data[i] = _res_conv_8_ref;
22373         }
22374         CVec_TransactionZ_free(_res_constr);
22375 }
22376
22377 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22378         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22379         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22380         return tag_ptr(ret_conv, true);
22381 }
22382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22383         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22384         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22385         return ret_conv;
22386 }
22387
22388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22389         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22390         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22391         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22392         return tag_ptr(ret_conv, true);
22393 }
22394
22395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22396         void* b_ptr = untag_ptr(b);
22397         CHECK_ACCESS(b_ptr);
22398         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22399         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22400         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22401         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22402         return tag_ptr(ret_conv, true);
22403 }
22404
22405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22406         if (!ptr_is_owned(_res)) return;
22407         void* _res_ptr = untag_ptr(_res);
22408         CHECK_ACCESS(_res_ptr);
22409         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22410         FREE(untag_ptr(_res));
22411         C2Tuple_u32TxOutZ_free(_res_conv);
22412 }
22413
22414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22415         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22416         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22417         if (_res_constr.datalen > 0)
22418                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22419         else
22420                 _res_constr.data = NULL;
22421         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22422         for (size_t u = 0; u < _res_constr.datalen; u++) {
22423                 int64_t _res_conv_20 = _res_vals[u];
22424                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22425                 CHECK_ACCESS(_res_conv_20_ptr);
22426                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22427                 FREE(untag_ptr(_res_conv_20));
22428                 _res_constr.data[u] = _res_conv_20_conv;
22429         }
22430         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22431         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22432 }
22433
22434 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22435         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22436         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22437         return tag_ptr(ret_conv, true);
22438 }
22439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22440         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22441         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22442         return ret_conv;
22443 }
22444
22445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22446         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22447         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22448         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22449         return tag_ptr(ret_conv, true);
22450 }
22451
22452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22453         LDKThirtyTwoBytes a_ref;
22454         CHECK((*env)->GetArrayLength(env, a) == 32);
22455         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22456         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22457         b_constr.datalen = (*env)->GetArrayLength(env, b);
22458         if (b_constr.datalen > 0)
22459                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22460         else
22461                 b_constr.data = NULL;
22462         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22463         for (size_t u = 0; u < b_constr.datalen; u++) {
22464                 int64_t b_conv_20 = b_vals[u];
22465                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22466                 CHECK_ACCESS(b_conv_20_ptr);
22467                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22468                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22469                 b_constr.data[u] = b_conv_20_conv;
22470         }
22471         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22472         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22473         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22474         return tag_ptr(ret_conv, true);
22475 }
22476
22477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22478         if (!ptr_is_owned(_res)) return;
22479         void* _res_ptr = untag_ptr(_res);
22480         CHECK_ACCESS(_res_ptr);
22481         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22482         FREE(untag_ptr(_res));
22483         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22484 }
22485
22486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22487         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22488         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22489         if (_res_constr.datalen > 0)
22490                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22491         else
22492                 _res_constr.data = NULL;
22493         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22494         for (size_t n = 0; n < _res_constr.datalen; n++) {
22495                 int64_t _res_conv_39 = _res_vals[n];
22496                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22497                 CHECK_ACCESS(_res_conv_39_ptr);
22498                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22499                 FREE(untag_ptr(_res_conv_39));
22500                 _res_constr.data[n] = _res_conv_39_conv;
22501         }
22502         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22503         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22507         LDKCVec_BalanceZ _res_constr;
22508         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22509         if (_res_constr.datalen > 0)
22510                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22511         else
22512                 _res_constr.data = NULL;
22513         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22514         for (size_t j = 0; j < _res_constr.datalen; j++) {
22515                 int64_t _res_conv_9 = _res_vals[j];
22516                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22517                 CHECK_ACCESS(_res_conv_9_ptr);
22518                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22519                 FREE(untag_ptr(_res_conv_9));
22520                 _res_constr.data[j] = _res_conv_9_conv;
22521         }
22522         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22523         CVec_BalanceZ_free(_res_constr);
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22527         void* o_ptr = untag_ptr(o);
22528         CHECK_ACCESS(o_ptr);
22529         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22530         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22531         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22532         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22533         return tag_ptr(ret_conv, true);
22534 }
22535
22536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22537         void* e_ptr = untag_ptr(e);
22538         CHECK_ACCESS(e_ptr);
22539         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22540         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22541         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22542         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22543         return tag_ptr(ret_conv, true);
22544 }
22545
22546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22547         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22548         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22549         return ret_conv;
22550 }
22551
22552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22553         if (!ptr_is_owned(_res)) return;
22554         void* _res_ptr = untag_ptr(_res);
22555         CHECK_ACCESS(_res_ptr);
22556         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22557         FREE(untag_ptr(_res));
22558         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22559 }
22560
22561 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22562         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22563         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22564         return tag_ptr(ret_conv, true);
22565 }
22566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22567         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22568         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22569         return ret_conv;
22570 }
22571
22572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22573         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22574         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22575         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22576         return tag_ptr(ret_conv, true);
22577 }
22578
22579 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22580         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22581         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22582         return tag_ptr(ret_conv, true);
22583 }
22584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22585         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22586         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22587         return ret_conv;
22588 }
22589
22590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22591         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22592         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22593         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22594         return tag_ptr(ret_conv, true);
22595 }
22596
22597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22598         LDKPublicKey a_ref;
22599         CHECK((*env)->GetArrayLength(env, a) == 33);
22600         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22601         void* b_ptr = untag_ptr(b);
22602         CHECK_ACCESS(b_ptr);
22603         LDKType b_conv = *(LDKType*)(b_ptr);
22604         if (b_conv.free == LDKType_JCalls_free) {
22605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22606                 LDKType_JCalls_cloned(&b_conv);
22607         }
22608         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22609         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22610         return tag_ptr(ret_conv, true);
22611 }
22612
22613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22614         if (!ptr_is_owned(_res)) return;
22615         void* _res_ptr = untag_ptr(_res);
22616         CHECK_ACCESS(_res_ptr);
22617         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22618         FREE(untag_ptr(_res));
22619         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22620 }
22621
22622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22623         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22624         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22625         if (_res_constr.datalen > 0)
22626                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22627         else
22628                 _res_constr.data = NULL;
22629         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22630         for (size_t z = 0; z < _res_constr.datalen; z++) {
22631                 int64_t _res_conv_25 = _res_vals[z];
22632                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22633                 CHECK_ACCESS(_res_conv_25_ptr);
22634                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22635                 FREE(untag_ptr(_res_conv_25));
22636                 _res_constr.data[z] = _res_conv_25_conv;
22637         }
22638         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22639         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22640 }
22641
22642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22643         void* o_ptr = untag_ptr(o);
22644         CHECK_ACCESS(o_ptr);
22645         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
22646         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
22647                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22648                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
22649         }
22650         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22651         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
22652         int64_t ret_ref = tag_ptr(ret_copy, true);
22653         return ret_ref;
22654 }
22655
22656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
22657         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22658         *ret_copy = COption_CustomOnionMessageContentsZ_none();
22659         int64_t ret_ref = tag_ptr(ret_copy, true);
22660         return ret_ref;
22661 }
22662
22663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22664         if (!ptr_is_owned(_res)) return;
22665         void* _res_ptr = untag_ptr(_res);
22666         CHECK_ACCESS(_res_ptr);
22667         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
22668         FREE(untag_ptr(_res));
22669         COption_CustomOnionMessageContentsZ_free(_res_conv);
22670 }
22671
22672 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
22673         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22674         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
22675         int64_t ret_ref = tag_ptr(ret_copy, true);
22676         return ret_ref;
22677 }
22678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22679         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
22680         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
22681         return ret_conv;
22682 }
22683
22684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22685         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
22686         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22687         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
22688         int64_t ret_ref = tag_ptr(ret_copy, true);
22689         return ret_ref;
22690 }
22691
22692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22693         void* o_ptr = untag_ptr(o);
22694         CHECK_ACCESS(o_ptr);
22695         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
22696         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
22697         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22698         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
22699         return tag_ptr(ret_conv, true);
22700 }
22701
22702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22703         void* e_ptr = untag_ptr(e);
22704         CHECK_ACCESS(e_ptr);
22705         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22706         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22707         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22708         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
22709         return tag_ptr(ret_conv, true);
22710 }
22711
22712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22713         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22714         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22715         return ret_conv;
22716 }
22717
22718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22719         if (!ptr_is_owned(_res)) return;
22720         void* _res_ptr = untag_ptr(_res);
22721         CHECK_ACCESS(_res_ptr);
22722         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22723         FREE(untag_ptr(_res));
22724         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
22725 }
22726
22727 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22728         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22729         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
22730         return tag_ptr(ret_conv, true);
22731 }
22732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22733         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22734         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22735         return ret_conv;
22736 }
22737
22738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22739         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22740         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22741         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22742         return tag_ptr(ret_conv, true);
22743 }
22744
22745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22746         void* o_ptr = untag_ptr(o);
22747         CHECK_ACCESS(o_ptr);
22748         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22749         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22750         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22751         *ret_copy = COption_NetAddressZ_some(o_conv);
22752         int64_t ret_ref = tag_ptr(ret_copy, true);
22753         return ret_ref;
22754 }
22755
22756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
22757         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22758         *ret_copy = COption_NetAddressZ_none();
22759         int64_t ret_ref = tag_ptr(ret_copy, true);
22760         return ret_ref;
22761 }
22762
22763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22764         if (!ptr_is_owned(_res)) return;
22765         void* _res_ptr = untag_ptr(_res);
22766         CHECK_ACCESS(_res_ptr);
22767         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
22768         FREE(untag_ptr(_res));
22769         COption_NetAddressZ_free(_res_conv);
22770 }
22771
22772 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
22773         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22774         *ret_copy = COption_NetAddressZ_clone(arg);
22775         int64_t ret_ref = tag_ptr(ret_copy, true);
22776         return ret_ref;
22777 }
22778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22779         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
22780         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
22781         return ret_conv;
22782 }
22783
22784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22785         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
22786         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22787         *ret_copy = COption_NetAddressZ_clone(orig_conv);
22788         int64_t ret_ref = tag_ptr(ret_copy, true);
22789         return ret_ref;
22790 }
22791
22792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22793         LDKCVec_u8Z o_ref;
22794         o_ref.datalen = (*env)->GetArrayLength(env, o);
22795         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
22796         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
22797         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22798         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22799         return tag_ptr(ret_conv, true);
22800 }
22801
22802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22803         LDKPeerHandleError e_conv;
22804         e_conv.inner = untag_ptr(e);
22805         e_conv.is_owned = ptr_is_owned(e);
22806         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22807         e_conv = PeerHandleError_clone(&e_conv);
22808         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22809         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22810         return tag_ptr(ret_conv, true);
22811 }
22812
22813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22814         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
22815         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22816         return ret_conv;
22817 }
22818
22819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22820         if (!ptr_is_owned(_res)) return;
22821         void* _res_ptr = untag_ptr(_res);
22822         CHECK_ACCESS(_res_ptr);
22823         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22824         FREE(untag_ptr(_res));
22825         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22826 }
22827
22828 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22829         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22830         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22831         return tag_ptr(ret_conv, true);
22832 }
22833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22834         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
22835         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22836         return ret_conv;
22837 }
22838
22839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22840         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
22841         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22842         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22843         return tag_ptr(ret_conv, true);
22844 }
22845
22846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22847         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22848         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22849         return tag_ptr(ret_conv, true);
22850 }
22851
22852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22853         LDKPeerHandleError e_conv;
22854         e_conv.inner = untag_ptr(e);
22855         e_conv.is_owned = ptr_is_owned(e);
22856         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22857         e_conv = PeerHandleError_clone(&e_conv);
22858         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22859         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22860         return tag_ptr(ret_conv, true);
22861 }
22862
22863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22864         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
22865         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22866         return ret_conv;
22867 }
22868
22869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22870         if (!ptr_is_owned(_res)) return;
22871         void* _res_ptr = untag_ptr(_res);
22872         CHECK_ACCESS(_res_ptr);
22873         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22874         FREE(untag_ptr(_res));
22875         CResult_NonePeerHandleErrorZ_free(_res_conv);
22876 }
22877
22878 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22879         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22880         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22881         return tag_ptr(ret_conv, true);
22882 }
22883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22884         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
22885         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22886         return ret_conv;
22887 }
22888
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22890         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
22891         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22892         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22893         return tag_ptr(ret_conv, true);
22894 }
22895
22896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22897         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22898         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22899         return tag_ptr(ret_conv, true);
22900 }
22901
22902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22903         LDKPeerHandleError e_conv;
22904         e_conv.inner = untag_ptr(e);
22905         e_conv.is_owned = ptr_is_owned(e);
22906         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22907         e_conv = PeerHandleError_clone(&e_conv);
22908         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22909         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22910         return tag_ptr(ret_conv, true);
22911 }
22912
22913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22914         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
22915         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22916         return ret_conv;
22917 }
22918
22919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22920         if (!ptr_is_owned(_res)) return;
22921         void* _res_ptr = untag_ptr(_res);
22922         CHECK_ACCESS(_res_ptr);
22923         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22924         FREE(untag_ptr(_res));
22925         CResult_boolPeerHandleErrorZ_free(_res_conv);
22926 }
22927
22928 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22929         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22930         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22931         return tag_ptr(ret_conv, true);
22932 }
22933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22934         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
22935         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22936         return ret_conv;
22937 }
22938
22939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22940         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
22941         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22942         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22943         return tag_ptr(ret_conv, true);
22944 }
22945
22946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
22947         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22948         *ret_conv = CResult_NoneSendErrorZ_ok();
22949         return tag_ptr(ret_conv, true);
22950 }
22951
22952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22953         void* e_ptr = untag_ptr(e);
22954         CHECK_ACCESS(e_ptr);
22955         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
22956         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
22957         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22958         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
22959         return tag_ptr(ret_conv, true);
22960 }
22961
22962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22963         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
22964         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
22965         return ret_conv;
22966 }
22967
22968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22969         if (!ptr_is_owned(_res)) return;
22970         void* _res_ptr = untag_ptr(_res);
22971         CHECK_ACCESS(_res_ptr);
22972         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
22973         FREE(untag_ptr(_res));
22974         CResult_NoneSendErrorZ_free(_res_conv);
22975 }
22976
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22978         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22979         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22980         return tag_ptr(ret_conv, true);
22981 }
22982
22983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22984         void* e_ptr = untag_ptr(e);
22985         CHECK_ACCESS(e_ptr);
22986         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22987         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
22988         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22989         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22990         return tag_ptr(ret_conv, true);
22991 }
22992
22993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22994         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
22995         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22996         return ret_conv;
22997 }
22998
22999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23000         if (!ptr_is_owned(_res)) return;
23001         void* _res_ptr = untag_ptr(_res);
23002         CHECK_ACCESS(_res_ptr);
23003         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23004         FREE(untag_ptr(_res));
23005         CResult_u32GraphSyncErrorZ_free(_res_conv);
23006 }
23007
23008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23009         void* o_ptr = untag_ptr(o);
23010         CHECK_ACCESS(o_ptr);
23011         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23012         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23013         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23014         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
23015         return tag_ptr(ret_conv, true);
23016 }
23017
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23019         void* e_ptr = untag_ptr(e);
23020         CHECK_ACCESS(e_ptr);
23021         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23022         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23023         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23024         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
23025         return tag_ptr(ret_conv, true);
23026 }
23027
23028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23029         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
23030         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
23031         return ret_conv;
23032 }
23033
23034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23035         if (!ptr_is_owned(_res)) return;
23036         void* _res_ptr = untag_ptr(_res);
23037         CHECK_ACCESS(_res_ptr);
23038         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
23039         FREE(untag_ptr(_res));
23040         CResult_NetAddressDecodeErrorZ_free(_res_conv);
23041 }
23042
23043 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
23044         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23045         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
23046         return tag_ptr(ret_conv, true);
23047 }
23048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23049         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
23050         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
23051         return ret_conv;
23052 }
23053
23054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23055         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
23056         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23057         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
23058         return tag_ptr(ret_conv, true);
23059 }
23060
23061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23062         LDKCVec_UpdateAddHTLCZ _res_constr;
23063         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23064         if (_res_constr.datalen > 0)
23065                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23066         else
23067                 _res_constr.data = NULL;
23068         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23069         for (size_t p = 0; p < _res_constr.datalen; p++) {
23070                 int64_t _res_conv_15 = _res_vals[p];
23071                 LDKUpdateAddHTLC _res_conv_15_conv;
23072                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23073                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23074                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23075                 _res_constr.data[p] = _res_conv_15_conv;
23076         }
23077         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23078         CVec_UpdateAddHTLCZ_free(_res_constr);
23079 }
23080
23081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23082         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23083         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23084         if (_res_constr.datalen > 0)
23085                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23086         else
23087                 _res_constr.data = NULL;
23088         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23089         for (size_t t = 0; t < _res_constr.datalen; t++) {
23090                 int64_t _res_conv_19 = _res_vals[t];
23091                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23092                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23093                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23094                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23095                 _res_constr.data[t] = _res_conv_19_conv;
23096         }
23097         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23098         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23099 }
23100
23101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23102         LDKCVec_UpdateFailHTLCZ _res_constr;
23103         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23104         if (_res_constr.datalen > 0)
23105                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23106         else
23107                 _res_constr.data = NULL;
23108         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23109         for (size_t q = 0; q < _res_constr.datalen; q++) {
23110                 int64_t _res_conv_16 = _res_vals[q];
23111                 LDKUpdateFailHTLC _res_conv_16_conv;
23112                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23113                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23114                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23115                 _res_constr.data[q] = _res_conv_16_conv;
23116         }
23117         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23118         CVec_UpdateFailHTLCZ_free(_res_constr);
23119 }
23120
23121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23122         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23123         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23124         if (_res_constr.datalen > 0)
23125                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23126         else
23127                 _res_constr.data = NULL;
23128         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23129         for (size_t z = 0; z < _res_constr.datalen; z++) {
23130                 int64_t _res_conv_25 = _res_vals[z];
23131                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23132                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23133                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23134                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23135                 _res_constr.data[z] = _res_conv_25_conv;
23136         }
23137         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23138         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23139 }
23140
23141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23142         LDKAcceptChannel o_conv;
23143         o_conv.inner = untag_ptr(o);
23144         o_conv.is_owned = ptr_is_owned(o);
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23146         o_conv = AcceptChannel_clone(&o_conv);
23147         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23148         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23149         return tag_ptr(ret_conv, true);
23150 }
23151
23152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23153         void* e_ptr = untag_ptr(e);
23154         CHECK_ACCESS(e_ptr);
23155         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23156         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23157         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23158         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23159         return tag_ptr(ret_conv, true);
23160 }
23161
23162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23163         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23164         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23165         return ret_conv;
23166 }
23167
23168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23169         if (!ptr_is_owned(_res)) return;
23170         void* _res_ptr = untag_ptr(_res);
23171         CHECK_ACCESS(_res_ptr);
23172         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23173         FREE(untag_ptr(_res));
23174         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23175 }
23176
23177 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23178         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23179         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23180         return tag_ptr(ret_conv, true);
23181 }
23182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23183         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23184         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23185         return ret_conv;
23186 }
23187
23188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23189         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23190         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23191         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23192         return tag_ptr(ret_conv, true);
23193 }
23194
23195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23196         LDKAnnouncementSignatures o_conv;
23197         o_conv.inner = untag_ptr(o);
23198         o_conv.is_owned = ptr_is_owned(o);
23199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23200         o_conv = AnnouncementSignatures_clone(&o_conv);
23201         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23202         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
23203         return tag_ptr(ret_conv, true);
23204 }
23205
23206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23207         void* e_ptr = untag_ptr(e);
23208         CHECK_ACCESS(e_ptr);
23209         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23210         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23211         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23212         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
23213         return tag_ptr(ret_conv, true);
23214 }
23215
23216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23217         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
23218         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
23219         return ret_conv;
23220 }
23221
23222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23223         if (!ptr_is_owned(_res)) return;
23224         void* _res_ptr = untag_ptr(_res);
23225         CHECK_ACCESS(_res_ptr);
23226         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
23227         FREE(untag_ptr(_res));
23228         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
23229 }
23230
23231 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
23232         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23233         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
23234         return tag_ptr(ret_conv, true);
23235 }
23236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23237         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
23238         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
23239         return ret_conv;
23240 }
23241
23242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23243         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
23244         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23245         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
23246         return tag_ptr(ret_conv, true);
23247 }
23248
23249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23250         LDKChannelReestablish o_conv;
23251         o_conv.inner = untag_ptr(o);
23252         o_conv.is_owned = ptr_is_owned(o);
23253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23254         o_conv = ChannelReestablish_clone(&o_conv);
23255         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23256         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
23257         return tag_ptr(ret_conv, true);
23258 }
23259
23260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23261         void* e_ptr = untag_ptr(e);
23262         CHECK_ACCESS(e_ptr);
23263         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23264         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23265         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23266         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
23267         return tag_ptr(ret_conv, true);
23268 }
23269
23270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23271         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
23272         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
23273         return ret_conv;
23274 }
23275
23276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23277         if (!ptr_is_owned(_res)) return;
23278         void* _res_ptr = untag_ptr(_res);
23279         CHECK_ACCESS(_res_ptr);
23280         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
23281         FREE(untag_ptr(_res));
23282         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
23283 }
23284
23285 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
23286         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23287         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
23288         return tag_ptr(ret_conv, true);
23289 }
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23291         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
23292         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
23293         return ret_conv;
23294 }
23295
23296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23297         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
23298         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23299         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
23300         return tag_ptr(ret_conv, true);
23301 }
23302
23303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23304         LDKClosingSigned o_conv;
23305         o_conv.inner = untag_ptr(o);
23306         o_conv.is_owned = ptr_is_owned(o);
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23308         o_conv = ClosingSigned_clone(&o_conv);
23309         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23310         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
23311         return tag_ptr(ret_conv, true);
23312 }
23313
23314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23315         void* e_ptr = untag_ptr(e);
23316         CHECK_ACCESS(e_ptr);
23317         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23318         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23319         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23320         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
23321         return tag_ptr(ret_conv, true);
23322 }
23323
23324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23325         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
23326         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
23327         return ret_conv;
23328 }
23329
23330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23331         if (!ptr_is_owned(_res)) return;
23332         void* _res_ptr = untag_ptr(_res);
23333         CHECK_ACCESS(_res_ptr);
23334         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
23335         FREE(untag_ptr(_res));
23336         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
23337 }
23338
23339 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
23340         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23341         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
23342         return tag_ptr(ret_conv, true);
23343 }
23344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23345         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
23346         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
23347         return ret_conv;
23348 }
23349
23350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23351         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
23352         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23353         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
23354         return tag_ptr(ret_conv, true);
23355 }
23356
23357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23358         LDKClosingSignedFeeRange o_conv;
23359         o_conv.inner = untag_ptr(o);
23360         o_conv.is_owned = ptr_is_owned(o);
23361         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23362         o_conv = ClosingSignedFeeRange_clone(&o_conv);
23363         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23364         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
23365         return tag_ptr(ret_conv, true);
23366 }
23367
23368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23369         void* e_ptr = untag_ptr(e);
23370         CHECK_ACCESS(e_ptr);
23371         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23372         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23373         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23374         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
23375         return tag_ptr(ret_conv, true);
23376 }
23377
23378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23379         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
23380         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
23381         return ret_conv;
23382 }
23383
23384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23385         if (!ptr_is_owned(_res)) return;
23386         void* _res_ptr = untag_ptr(_res);
23387         CHECK_ACCESS(_res_ptr);
23388         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
23389         FREE(untag_ptr(_res));
23390         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
23391 }
23392
23393 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
23394         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23395         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
23396         return tag_ptr(ret_conv, true);
23397 }
23398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23399         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
23400         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
23401         return ret_conv;
23402 }
23403
23404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23405         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
23406         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23407         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
23408         return tag_ptr(ret_conv, true);
23409 }
23410
23411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23412         LDKCommitmentSigned o_conv;
23413         o_conv.inner = untag_ptr(o);
23414         o_conv.is_owned = ptr_is_owned(o);
23415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23416         o_conv = CommitmentSigned_clone(&o_conv);
23417         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23418         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
23419         return tag_ptr(ret_conv, true);
23420 }
23421
23422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23423         void* e_ptr = untag_ptr(e);
23424         CHECK_ACCESS(e_ptr);
23425         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23426         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23427         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23428         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
23429         return tag_ptr(ret_conv, true);
23430 }
23431
23432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23433         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
23434         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
23435         return ret_conv;
23436 }
23437
23438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23439         if (!ptr_is_owned(_res)) return;
23440         void* _res_ptr = untag_ptr(_res);
23441         CHECK_ACCESS(_res_ptr);
23442         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
23443         FREE(untag_ptr(_res));
23444         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
23445 }
23446
23447 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
23448         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23449         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
23450         return tag_ptr(ret_conv, true);
23451 }
23452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23453         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
23454         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
23455         return ret_conv;
23456 }
23457
23458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23459         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
23460         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23461         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
23462         return tag_ptr(ret_conv, true);
23463 }
23464
23465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23466         LDKFundingCreated o_conv;
23467         o_conv.inner = untag_ptr(o);
23468         o_conv.is_owned = ptr_is_owned(o);
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23470         o_conv = FundingCreated_clone(&o_conv);
23471         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23472         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
23473         return tag_ptr(ret_conv, true);
23474 }
23475
23476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23477         void* e_ptr = untag_ptr(e);
23478         CHECK_ACCESS(e_ptr);
23479         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23480         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23481         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23482         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
23483         return tag_ptr(ret_conv, true);
23484 }
23485
23486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23487         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
23488         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
23489         return ret_conv;
23490 }
23491
23492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23493         if (!ptr_is_owned(_res)) return;
23494         void* _res_ptr = untag_ptr(_res);
23495         CHECK_ACCESS(_res_ptr);
23496         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
23497         FREE(untag_ptr(_res));
23498         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
23499 }
23500
23501 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
23502         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23503         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
23504         return tag_ptr(ret_conv, true);
23505 }
23506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23507         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
23508         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
23509         return ret_conv;
23510 }
23511
23512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23513         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
23514         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23515         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
23516         return tag_ptr(ret_conv, true);
23517 }
23518
23519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23520         LDKFundingSigned o_conv;
23521         o_conv.inner = untag_ptr(o);
23522         o_conv.is_owned = ptr_is_owned(o);
23523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23524         o_conv = FundingSigned_clone(&o_conv);
23525         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23526         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
23527         return tag_ptr(ret_conv, true);
23528 }
23529
23530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23531         void* e_ptr = untag_ptr(e);
23532         CHECK_ACCESS(e_ptr);
23533         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23534         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23535         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23536         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
23537         return tag_ptr(ret_conv, true);
23538 }
23539
23540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23541         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
23542         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
23543         return ret_conv;
23544 }
23545
23546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23547         if (!ptr_is_owned(_res)) return;
23548         void* _res_ptr = untag_ptr(_res);
23549         CHECK_ACCESS(_res_ptr);
23550         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
23551         FREE(untag_ptr(_res));
23552         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
23553 }
23554
23555 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
23556         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23557         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
23558         return tag_ptr(ret_conv, true);
23559 }
23560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23561         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
23562         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
23563         return ret_conv;
23564 }
23565
23566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23567         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
23568         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23569         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
23570         return tag_ptr(ret_conv, true);
23571 }
23572
23573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23574         LDKChannelReady o_conv;
23575         o_conv.inner = untag_ptr(o);
23576         o_conv.is_owned = ptr_is_owned(o);
23577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23578         o_conv = ChannelReady_clone(&o_conv);
23579         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23580         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
23581         return tag_ptr(ret_conv, true);
23582 }
23583
23584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23585         void* e_ptr = untag_ptr(e);
23586         CHECK_ACCESS(e_ptr);
23587         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23588         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23589         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23590         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
23591         return tag_ptr(ret_conv, true);
23592 }
23593
23594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23595         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
23596         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
23597         return ret_conv;
23598 }
23599
23600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23601         if (!ptr_is_owned(_res)) return;
23602         void* _res_ptr = untag_ptr(_res);
23603         CHECK_ACCESS(_res_ptr);
23604         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
23605         FREE(untag_ptr(_res));
23606         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
23607 }
23608
23609 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
23610         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23611         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
23612         return tag_ptr(ret_conv, true);
23613 }
23614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23615         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
23616         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
23617         return ret_conv;
23618 }
23619
23620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23621         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
23622         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23623         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
23624         return tag_ptr(ret_conv, true);
23625 }
23626
23627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23628         LDKInit o_conv;
23629         o_conv.inner = untag_ptr(o);
23630         o_conv.is_owned = ptr_is_owned(o);
23631         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23632         o_conv = Init_clone(&o_conv);
23633         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23634         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
23635         return tag_ptr(ret_conv, true);
23636 }
23637
23638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23639         void* e_ptr = untag_ptr(e);
23640         CHECK_ACCESS(e_ptr);
23641         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23642         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23643         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23644         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
23645         return tag_ptr(ret_conv, true);
23646 }
23647
23648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23649         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
23650         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
23651         return ret_conv;
23652 }
23653
23654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23655         if (!ptr_is_owned(_res)) return;
23656         void* _res_ptr = untag_ptr(_res);
23657         CHECK_ACCESS(_res_ptr);
23658         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
23659         FREE(untag_ptr(_res));
23660         CResult_InitDecodeErrorZ_free(_res_conv);
23661 }
23662
23663 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
23664         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23665         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
23666         return tag_ptr(ret_conv, true);
23667 }
23668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23669         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
23670         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
23671         return ret_conv;
23672 }
23673
23674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23675         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
23676         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23677         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
23678         return tag_ptr(ret_conv, true);
23679 }
23680
23681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23682         LDKOpenChannel o_conv;
23683         o_conv.inner = untag_ptr(o);
23684         o_conv.is_owned = ptr_is_owned(o);
23685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23686         o_conv = OpenChannel_clone(&o_conv);
23687         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23688         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
23689         return tag_ptr(ret_conv, true);
23690 }
23691
23692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23693         void* e_ptr = untag_ptr(e);
23694         CHECK_ACCESS(e_ptr);
23695         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23696         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23697         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23698         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
23699         return tag_ptr(ret_conv, true);
23700 }
23701
23702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23703         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
23704         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
23705         return ret_conv;
23706 }
23707
23708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23709         if (!ptr_is_owned(_res)) return;
23710         void* _res_ptr = untag_ptr(_res);
23711         CHECK_ACCESS(_res_ptr);
23712         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
23713         FREE(untag_ptr(_res));
23714         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
23715 }
23716
23717 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
23718         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23719         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
23720         return tag_ptr(ret_conv, true);
23721 }
23722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23723         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
23724         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
23725         return ret_conv;
23726 }
23727
23728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23729         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
23730         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23731         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
23732         return tag_ptr(ret_conv, true);
23733 }
23734
23735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23736         LDKRevokeAndACK o_conv;
23737         o_conv.inner = untag_ptr(o);
23738         o_conv.is_owned = ptr_is_owned(o);
23739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23740         o_conv = RevokeAndACK_clone(&o_conv);
23741         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23742         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
23743         return tag_ptr(ret_conv, true);
23744 }
23745
23746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23747         void* e_ptr = untag_ptr(e);
23748         CHECK_ACCESS(e_ptr);
23749         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23750         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23751         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23752         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
23753         return tag_ptr(ret_conv, true);
23754 }
23755
23756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23757         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
23758         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
23759         return ret_conv;
23760 }
23761
23762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23763         if (!ptr_is_owned(_res)) return;
23764         void* _res_ptr = untag_ptr(_res);
23765         CHECK_ACCESS(_res_ptr);
23766         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
23767         FREE(untag_ptr(_res));
23768         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
23769 }
23770
23771 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
23772         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23773         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
23774         return tag_ptr(ret_conv, true);
23775 }
23776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23777         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
23778         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
23779         return ret_conv;
23780 }
23781
23782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23783         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
23784         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23785         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
23786         return tag_ptr(ret_conv, true);
23787 }
23788
23789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23790         LDKShutdown o_conv;
23791         o_conv.inner = untag_ptr(o);
23792         o_conv.is_owned = ptr_is_owned(o);
23793         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23794         o_conv = Shutdown_clone(&o_conv);
23795         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23796         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
23797         return tag_ptr(ret_conv, true);
23798 }
23799
23800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23801         void* e_ptr = untag_ptr(e);
23802         CHECK_ACCESS(e_ptr);
23803         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23804         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23805         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23806         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
23807         return tag_ptr(ret_conv, true);
23808 }
23809
23810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23811         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
23812         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
23813         return ret_conv;
23814 }
23815
23816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23817         if (!ptr_is_owned(_res)) return;
23818         void* _res_ptr = untag_ptr(_res);
23819         CHECK_ACCESS(_res_ptr);
23820         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23821         FREE(untag_ptr(_res));
23822         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23823 }
23824
23825 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23826         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23827         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23828         return tag_ptr(ret_conv, true);
23829 }
23830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23831         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
23832         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23833         return ret_conv;
23834 }
23835
23836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23837         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
23838         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23839         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23840         return tag_ptr(ret_conv, true);
23841 }
23842
23843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23844         LDKUpdateFailHTLC o_conv;
23845         o_conv.inner = untag_ptr(o);
23846         o_conv.is_owned = ptr_is_owned(o);
23847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23848         o_conv = UpdateFailHTLC_clone(&o_conv);
23849         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23850         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23851         return tag_ptr(ret_conv, true);
23852 }
23853
23854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23855         void* e_ptr = untag_ptr(e);
23856         CHECK_ACCESS(e_ptr);
23857         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23858         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23859         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23860         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23861         return tag_ptr(ret_conv, true);
23862 }
23863
23864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23865         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
23866         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23867         return ret_conv;
23868 }
23869
23870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23871         if (!ptr_is_owned(_res)) return;
23872         void* _res_ptr = untag_ptr(_res);
23873         CHECK_ACCESS(_res_ptr);
23874         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23875         FREE(untag_ptr(_res));
23876         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23877 }
23878
23879 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23880         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23881         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23882         return tag_ptr(ret_conv, true);
23883 }
23884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23885         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
23886         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23887         return ret_conv;
23888 }
23889
23890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23891         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
23892         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23893         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23894         return tag_ptr(ret_conv, true);
23895 }
23896
23897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23898         LDKUpdateFailMalformedHTLC o_conv;
23899         o_conv.inner = untag_ptr(o);
23900         o_conv.is_owned = ptr_is_owned(o);
23901         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23902         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23903         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23904         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23905         return tag_ptr(ret_conv, true);
23906 }
23907
23908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23909         void* e_ptr = untag_ptr(e);
23910         CHECK_ACCESS(e_ptr);
23911         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23912         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23913         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23914         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23915         return tag_ptr(ret_conv, true);
23916 }
23917
23918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23919         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
23920         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23921         return ret_conv;
23922 }
23923
23924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23925         if (!ptr_is_owned(_res)) return;
23926         void* _res_ptr = untag_ptr(_res);
23927         CHECK_ACCESS(_res_ptr);
23928         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23929         FREE(untag_ptr(_res));
23930         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23931 }
23932
23933 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23934         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23935         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23936         return tag_ptr(ret_conv, true);
23937 }
23938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23939         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
23940         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23941         return ret_conv;
23942 }
23943
23944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23945         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
23946         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23947         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23948         return tag_ptr(ret_conv, true);
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23952         LDKUpdateFee o_conv;
23953         o_conv.inner = untag_ptr(o);
23954         o_conv.is_owned = ptr_is_owned(o);
23955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23956         o_conv = UpdateFee_clone(&o_conv);
23957         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23958         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23959         return tag_ptr(ret_conv, true);
23960 }
23961
23962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23963         void* e_ptr = untag_ptr(e);
23964         CHECK_ACCESS(e_ptr);
23965         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23966         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23967         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23968         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23969         return tag_ptr(ret_conv, true);
23970 }
23971
23972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23973         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
23974         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23975         return ret_conv;
23976 }
23977
23978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23979         if (!ptr_is_owned(_res)) return;
23980         void* _res_ptr = untag_ptr(_res);
23981         CHECK_ACCESS(_res_ptr);
23982         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23983         FREE(untag_ptr(_res));
23984         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23985 }
23986
23987 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23988         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23989         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23990         return tag_ptr(ret_conv, true);
23991 }
23992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23993         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
23994         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23995         return ret_conv;
23996 }
23997
23998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23999         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
24000         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24001         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
24002         return tag_ptr(ret_conv, true);
24003 }
24004
24005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24006         LDKUpdateFulfillHTLC o_conv;
24007         o_conv.inner = untag_ptr(o);
24008         o_conv.is_owned = ptr_is_owned(o);
24009         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24010         o_conv = UpdateFulfillHTLC_clone(&o_conv);
24011         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24012         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
24013         return tag_ptr(ret_conv, true);
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24017         void* e_ptr = untag_ptr(e);
24018         CHECK_ACCESS(e_ptr);
24019         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24020         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24021         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24022         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
24023         return tag_ptr(ret_conv, true);
24024 }
24025
24026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24027         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
24028         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
24029         return ret_conv;
24030 }
24031
24032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24033         if (!ptr_is_owned(_res)) return;
24034         void* _res_ptr = untag_ptr(_res);
24035         CHECK_ACCESS(_res_ptr);
24036         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
24037         FREE(untag_ptr(_res));
24038         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
24039 }
24040
24041 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
24042         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24043         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
24044         return tag_ptr(ret_conv, true);
24045 }
24046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24047         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
24048         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
24049         return ret_conv;
24050 }
24051
24052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24053         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
24054         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24055         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
24056         return tag_ptr(ret_conv, true);
24057 }
24058
24059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24060         LDKUpdateAddHTLC o_conv;
24061         o_conv.inner = untag_ptr(o);
24062         o_conv.is_owned = ptr_is_owned(o);
24063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24064         o_conv = UpdateAddHTLC_clone(&o_conv);
24065         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24066         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
24067         return tag_ptr(ret_conv, true);
24068 }
24069
24070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24071         void* e_ptr = untag_ptr(e);
24072         CHECK_ACCESS(e_ptr);
24073         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24074         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24075         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24076         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
24077         return tag_ptr(ret_conv, true);
24078 }
24079
24080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24081         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
24082         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
24083         return ret_conv;
24084 }
24085
24086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24087         if (!ptr_is_owned(_res)) return;
24088         void* _res_ptr = untag_ptr(_res);
24089         CHECK_ACCESS(_res_ptr);
24090         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
24091         FREE(untag_ptr(_res));
24092         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
24093 }
24094
24095 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
24096         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24097         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
24098         return tag_ptr(ret_conv, true);
24099 }
24100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24101         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
24102         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
24103         return ret_conv;
24104 }
24105
24106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24107         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
24108         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24109         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
24110         return tag_ptr(ret_conv, true);
24111 }
24112
24113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24114         LDKOnionMessage o_conv;
24115         o_conv.inner = untag_ptr(o);
24116         o_conv.is_owned = ptr_is_owned(o);
24117         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24118         o_conv = OnionMessage_clone(&o_conv);
24119         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24120         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
24121         return tag_ptr(ret_conv, true);
24122 }
24123
24124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24125         void* e_ptr = untag_ptr(e);
24126         CHECK_ACCESS(e_ptr);
24127         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24128         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24129         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24130         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
24131         return tag_ptr(ret_conv, true);
24132 }
24133
24134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24135         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
24136         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
24137         return ret_conv;
24138 }
24139
24140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24141         if (!ptr_is_owned(_res)) return;
24142         void* _res_ptr = untag_ptr(_res);
24143         CHECK_ACCESS(_res_ptr);
24144         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
24145         FREE(untag_ptr(_res));
24146         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
24147 }
24148
24149 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
24150         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24151         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
24152         return tag_ptr(ret_conv, true);
24153 }
24154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24155         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
24156         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
24157         return ret_conv;
24158 }
24159
24160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24161         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
24162         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24163         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
24164         return tag_ptr(ret_conv, true);
24165 }
24166
24167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24168         LDKPing o_conv;
24169         o_conv.inner = untag_ptr(o);
24170         o_conv.is_owned = ptr_is_owned(o);
24171         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24172         o_conv = Ping_clone(&o_conv);
24173         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24174         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
24175         return tag_ptr(ret_conv, true);
24176 }
24177
24178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24179         void* e_ptr = untag_ptr(e);
24180         CHECK_ACCESS(e_ptr);
24181         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24182         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24183         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24184         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
24185         return tag_ptr(ret_conv, true);
24186 }
24187
24188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24189         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
24190         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
24191         return ret_conv;
24192 }
24193
24194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24195         if (!ptr_is_owned(_res)) return;
24196         void* _res_ptr = untag_ptr(_res);
24197         CHECK_ACCESS(_res_ptr);
24198         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
24199         FREE(untag_ptr(_res));
24200         CResult_PingDecodeErrorZ_free(_res_conv);
24201 }
24202
24203 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
24204         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24205         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
24206         return tag_ptr(ret_conv, true);
24207 }
24208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24209         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
24210         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
24211         return ret_conv;
24212 }
24213
24214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24215         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
24216         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24217         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
24218         return tag_ptr(ret_conv, true);
24219 }
24220
24221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24222         LDKPong o_conv;
24223         o_conv.inner = untag_ptr(o);
24224         o_conv.is_owned = ptr_is_owned(o);
24225         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24226         o_conv = Pong_clone(&o_conv);
24227         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24228         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
24229         return tag_ptr(ret_conv, true);
24230 }
24231
24232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24233         void* e_ptr = untag_ptr(e);
24234         CHECK_ACCESS(e_ptr);
24235         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24236         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24237         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24238         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
24239         return tag_ptr(ret_conv, true);
24240 }
24241
24242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24243         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
24244         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
24245         return ret_conv;
24246 }
24247
24248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24249         if (!ptr_is_owned(_res)) return;
24250         void* _res_ptr = untag_ptr(_res);
24251         CHECK_ACCESS(_res_ptr);
24252         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
24253         FREE(untag_ptr(_res));
24254         CResult_PongDecodeErrorZ_free(_res_conv);
24255 }
24256
24257 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
24258         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24259         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
24260         return tag_ptr(ret_conv, true);
24261 }
24262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24263         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
24264         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
24265         return ret_conv;
24266 }
24267
24268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24269         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
24270         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24271         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
24272         return tag_ptr(ret_conv, true);
24273 }
24274
24275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24276         LDKUnsignedChannelAnnouncement o_conv;
24277         o_conv.inner = untag_ptr(o);
24278         o_conv.is_owned = ptr_is_owned(o);
24279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24280         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
24281         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24282         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
24283         return tag_ptr(ret_conv, true);
24284 }
24285
24286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24287         void* e_ptr = untag_ptr(e);
24288         CHECK_ACCESS(e_ptr);
24289         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24290         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24292         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
24293         return tag_ptr(ret_conv, true);
24294 }
24295
24296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24297         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
24298         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
24299         return ret_conv;
24300 }
24301
24302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24303         if (!ptr_is_owned(_res)) return;
24304         void* _res_ptr = untag_ptr(_res);
24305         CHECK_ACCESS(_res_ptr);
24306         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
24307         FREE(untag_ptr(_res));
24308         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
24309 }
24310
24311 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24312         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24313         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
24314         return tag_ptr(ret_conv, true);
24315 }
24316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24317         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
24318         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24319         return ret_conv;
24320 }
24321
24322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24323         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
24324         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24325         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
24326         return tag_ptr(ret_conv, true);
24327 }
24328
24329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24330         LDKChannelAnnouncement o_conv;
24331         o_conv.inner = untag_ptr(o);
24332         o_conv.is_owned = ptr_is_owned(o);
24333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24334         o_conv = ChannelAnnouncement_clone(&o_conv);
24335         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24336         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
24337         return tag_ptr(ret_conv, true);
24338 }
24339
24340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24341         void* e_ptr = untag_ptr(e);
24342         CHECK_ACCESS(e_ptr);
24343         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24344         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24345         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24346         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
24347         return tag_ptr(ret_conv, true);
24348 }
24349
24350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24351         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
24352         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
24353         return ret_conv;
24354 }
24355
24356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24357         if (!ptr_is_owned(_res)) return;
24358         void* _res_ptr = untag_ptr(_res);
24359         CHECK_ACCESS(_res_ptr);
24360         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
24361         FREE(untag_ptr(_res));
24362         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
24363 }
24364
24365 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24366         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24367         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
24368         return tag_ptr(ret_conv, true);
24369 }
24370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24371         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
24372         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24373         return ret_conv;
24374 }
24375
24376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24377         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
24378         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24379         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
24380         return tag_ptr(ret_conv, true);
24381 }
24382
24383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24384         LDKUnsignedChannelUpdate o_conv;
24385         o_conv.inner = untag_ptr(o);
24386         o_conv.is_owned = ptr_is_owned(o);
24387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24388         o_conv = UnsignedChannelUpdate_clone(&o_conv);
24389         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24390         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
24391         return tag_ptr(ret_conv, true);
24392 }
24393
24394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24395         void* e_ptr = untag_ptr(e);
24396         CHECK_ACCESS(e_ptr);
24397         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24398         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24399         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24400         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
24401         return tag_ptr(ret_conv, true);
24402 }
24403
24404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24405         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
24406         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
24407         return ret_conv;
24408 }
24409
24410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24411         if (!ptr_is_owned(_res)) return;
24412         void* _res_ptr = untag_ptr(_res);
24413         CHECK_ACCESS(_res_ptr);
24414         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
24415         FREE(untag_ptr(_res));
24416         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
24417 }
24418
24419 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24420         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24421         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
24422         return tag_ptr(ret_conv, true);
24423 }
24424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24425         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24426         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24427         return ret_conv;
24428 }
24429
24430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24431         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24432         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24433         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
24434         return tag_ptr(ret_conv, true);
24435 }
24436
24437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24438         LDKChannelUpdate o_conv;
24439         o_conv.inner = untag_ptr(o);
24440         o_conv.is_owned = ptr_is_owned(o);
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24442         o_conv = ChannelUpdate_clone(&o_conv);
24443         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24444         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
24445         return tag_ptr(ret_conv, true);
24446 }
24447
24448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24449         void* e_ptr = untag_ptr(e);
24450         CHECK_ACCESS(e_ptr);
24451         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24452         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24453         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24454         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
24455         return tag_ptr(ret_conv, true);
24456 }
24457
24458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24459         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
24460         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
24461         return ret_conv;
24462 }
24463
24464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24465         if (!ptr_is_owned(_res)) return;
24466         void* _res_ptr = untag_ptr(_res);
24467         CHECK_ACCESS(_res_ptr);
24468         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
24469         FREE(untag_ptr(_res));
24470         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
24471 }
24472
24473 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24474         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24475         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
24476         return tag_ptr(ret_conv, true);
24477 }
24478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24479         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24480         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24481         return ret_conv;
24482 }
24483
24484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24485         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24486         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24487         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
24488         return tag_ptr(ret_conv, true);
24489 }
24490
24491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24492         LDKErrorMessage o_conv;
24493         o_conv.inner = untag_ptr(o);
24494         o_conv.is_owned = ptr_is_owned(o);
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24496         o_conv = ErrorMessage_clone(&o_conv);
24497         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24498         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
24499         return tag_ptr(ret_conv, true);
24500 }
24501
24502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24503         void* e_ptr = untag_ptr(e);
24504         CHECK_ACCESS(e_ptr);
24505         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24506         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24507         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24508         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
24509         return tag_ptr(ret_conv, true);
24510 }
24511
24512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24513         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
24514         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
24515         return ret_conv;
24516 }
24517
24518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24519         if (!ptr_is_owned(_res)) return;
24520         void* _res_ptr = untag_ptr(_res);
24521         CHECK_ACCESS(_res_ptr);
24522         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
24523         FREE(untag_ptr(_res));
24524         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
24525 }
24526
24527 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
24528         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24529         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
24530         return tag_ptr(ret_conv, true);
24531 }
24532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24533         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
24534         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
24535         return ret_conv;
24536 }
24537
24538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24539         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
24540         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24541         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
24542         return tag_ptr(ret_conv, true);
24543 }
24544
24545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24546         LDKWarningMessage o_conv;
24547         o_conv.inner = untag_ptr(o);
24548         o_conv.is_owned = ptr_is_owned(o);
24549         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24550         o_conv = WarningMessage_clone(&o_conv);
24551         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24552         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
24553         return tag_ptr(ret_conv, true);
24554 }
24555
24556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24557         void* e_ptr = untag_ptr(e);
24558         CHECK_ACCESS(e_ptr);
24559         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24560         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24561         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24562         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
24563         return tag_ptr(ret_conv, true);
24564 }
24565
24566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24567         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
24568         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
24569         return ret_conv;
24570 }
24571
24572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24573         if (!ptr_is_owned(_res)) return;
24574         void* _res_ptr = untag_ptr(_res);
24575         CHECK_ACCESS(_res_ptr);
24576         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
24577         FREE(untag_ptr(_res));
24578         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
24579 }
24580
24581 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
24582         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24583         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
24584         return tag_ptr(ret_conv, true);
24585 }
24586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24587         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
24588         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
24589         return ret_conv;
24590 }
24591
24592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24593         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
24594         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24595         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
24596         return tag_ptr(ret_conv, true);
24597 }
24598
24599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24600         LDKUnsignedNodeAnnouncement o_conv;
24601         o_conv.inner = untag_ptr(o);
24602         o_conv.is_owned = ptr_is_owned(o);
24603         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24604         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
24605         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24606         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
24607         return tag_ptr(ret_conv, true);
24608 }
24609
24610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24611         void* e_ptr = untag_ptr(e);
24612         CHECK_ACCESS(e_ptr);
24613         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24614         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24615         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24616         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
24617         return tag_ptr(ret_conv, true);
24618 }
24619
24620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24621         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24622         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24623         return ret_conv;
24624 }
24625
24626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24627         if (!ptr_is_owned(_res)) return;
24628         void* _res_ptr = untag_ptr(_res);
24629         CHECK_ACCESS(_res_ptr);
24630         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
24631         FREE(untag_ptr(_res));
24632         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
24633 }
24634
24635 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24636         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24637         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
24638         return tag_ptr(ret_conv, true);
24639 }
24640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24641         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24642         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24643         return ret_conv;
24644 }
24645
24646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24647         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24648         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24649         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
24650         return tag_ptr(ret_conv, true);
24651 }
24652
24653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24654         LDKNodeAnnouncement o_conv;
24655         o_conv.inner = untag_ptr(o);
24656         o_conv.is_owned = ptr_is_owned(o);
24657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24658         o_conv = NodeAnnouncement_clone(&o_conv);
24659         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24660         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
24661         return tag_ptr(ret_conv, true);
24662 }
24663
24664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24665         void* e_ptr = untag_ptr(e);
24666         CHECK_ACCESS(e_ptr);
24667         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24668         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24669         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24670         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
24671         return tag_ptr(ret_conv, true);
24672 }
24673
24674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24675         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24676         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24677         return ret_conv;
24678 }
24679
24680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24681         if (!ptr_is_owned(_res)) return;
24682         void* _res_ptr = untag_ptr(_res);
24683         CHECK_ACCESS(_res_ptr);
24684         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
24685         FREE(untag_ptr(_res));
24686         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
24687 }
24688
24689 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24690         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24691         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
24692         return tag_ptr(ret_conv, true);
24693 }
24694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24695         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24696         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24697         return ret_conv;
24698 }
24699
24700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24701         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24702         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24703         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
24704         return tag_ptr(ret_conv, true);
24705 }
24706
24707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24708         LDKQueryShortChannelIds o_conv;
24709         o_conv.inner = untag_ptr(o);
24710         o_conv.is_owned = ptr_is_owned(o);
24711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24712         o_conv = QueryShortChannelIds_clone(&o_conv);
24713         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24714         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
24715         return tag_ptr(ret_conv, true);
24716 }
24717
24718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24719         void* e_ptr = untag_ptr(e);
24720         CHECK_ACCESS(e_ptr);
24721         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24722         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24723         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24724         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
24725         return tag_ptr(ret_conv, true);
24726 }
24727
24728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24729         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
24730         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
24731         return ret_conv;
24732 }
24733
24734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24735         if (!ptr_is_owned(_res)) return;
24736         void* _res_ptr = untag_ptr(_res);
24737         CHECK_ACCESS(_res_ptr);
24738         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
24739         FREE(untag_ptr(_res));
24740         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
24741 }
24742
24743 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
24744         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24745         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
24746         return tag_ptr(ret_conv, true);
24747 }
24748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24749         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
24750         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
24751         return ret_conv;
24752 }
24753
24754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24755         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
24756         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24757         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
24758         return tag_ptr(ret_conv, true);
24759 }
24760
24761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24762         LDKReplyShortChannelIdsEnd o_conv;
24763         o_conv.inner = untag_ptr(o);
24764         o_conv.is_owned = ptr_is_owned(o);
24765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24766         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
24767         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24768         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
24769         return tag_ptr(ret_conv, true);
24770 }
24771
24772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24773         void* e_ptr = untag_ptr(e);
24774         CHECK_ACCESS(e_ptr);
24775         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24776         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24777         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24778         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
24779         return tag_ptr(ret_conv, true);
24780 }
24781
24782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24783         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
24784         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
24785         return ret_conv;
24786 }
24787
24788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24789         if (!ptr_is_owned(_res)) return;
24790         void* _res_ptr = untag_ptr(_res);
24791         CHECK_ACCESS(_res_ptr);
24792         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
24793         FREE(untag_ptr(_res));
24794         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
24795 }
24796
24797 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
24798         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24799         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
24800         return tag_ptr(ret_conv, true);
24801 }
24802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24803         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
24804         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
24805         return ret_conv;
24806 }
24807
24808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24809         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
24810         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24811         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
24812         return tag_ptr(ret_conv, true);
24813 }
24814
24815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24816         LDKQueryChannelRange o_conv;
24817         o_conv.inner = untag_ptr(o);
24818         o_conv.is_owned = ptr_is_owned(o);
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24820         o_conv = QueryChannelRange_clone(&o_conv);
24821         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24822         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
24823         return tag_ptr(ret_conv, true);
24824 }
24825
24826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24827         void* e_ptr = untag_ptr(e);
24828         CHECK_ACCESS(e_ptr);
24829         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24830         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24831         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24832         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
24833         return tag_ptr(ret_conv, true);
24834 }
24835
24836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24837         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
24838         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
24839         return ret_conv;
24840 }
24841
24842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24843         if (!ptr_is_owned(_res)) return;
24844         void* _res_ptr = untag_ptr(_res);
24845         CHECK_ACCESS(_res_ptr);
24846         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
24847         FREE(untag_ptr(_res));
24848         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
24849 }
24850
24851 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24852         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24853         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24854         return tag_ptr(ret_conv, true);
24855 }
24856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24857         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
24858         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24859         return ret_conv;
24860 }
24861
24862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24863         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
24864         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24865         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24866         return tag_ptr(ret_conv, true);
24867 }
24868
24869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24870         LDKReplyChannelRange o_conv;
24871         o_conv.inner = untag_ptr(o);
24872         o_conv.is_owned = ptr_is_owned(o);
24873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24874         o_conv = ReplyChannelRange_clone(&o_conv);
24875         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24876         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24877         return tag_ptr(ret_conv, true);
24878 }
24879
24880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24881         void* e_ptr = untag_ptr(e);
24882         CHECK_ACCESS(e_ptr);
24883         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24884         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24885         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24886         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24887         return tag_ptr(ret_conv, true);
24888 }
24889
24890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24891         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
24892         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24893         return ret_conv;
24894 }
24895
24896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24897         if (!ptr_is_owned(_res)) return;
24898         void* _res_ptr = untag_ptr(_res);
24899         CHECK_ACCESS(_res_ptr);
24900         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24901         FREE(untag_ptr(_res));
24902         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24903 }
24904
24905 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24906         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24907         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24908         return tag_ptr(ret_conv, true);
24909 }
24910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24911         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
24912         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24913         return ret_conv;
24914 }
24915
24916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24917         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
24918         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24919         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24920         return tag_ptr(ret_conv, true);
24921 }
24922
24923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24924         LDKGossipTimestampFilter o_conv;
24925         o_conv.inner = untag_ptr(o);
24926         o_conv.is_owned = ptr_is_owned(o);
24927         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24928         o_conv = GossipTimestampFilter_clone(&o_conv);
24929         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24930         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24931         return tag_ptr(ret_conv, true);
24932 }
24933
24934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24935         void* e_ptr = untag_ptr(e);
24936         CHECK_ACCESS(e_ptr);
24937         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24938         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24939         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24940         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24941         return tag_ptr(ret_conv, true);
24942 }
24943
24944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24945         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
24946         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24947         return ret_conv;
24948 }
24949
24950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24951         if (!ptr_is_owned(_res)) return;
24952         void* _res_ptr = untag_ptr(_res);
24953         CHECK_ACCESS(_res_ptr);
24954         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24955         FREE(untag_ptr(_res));
24956         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24957 }
24958
24959 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24960         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24961         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24962         return tag_ptr(ret_conv, true);
24963 }
24964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24965         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
24966         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24967         return ret_conv;
24968 }
24969
24970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24971         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
24972         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24973         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24974         return tag_ptr(ret_conv, true);
24975 }
24976
24977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24978         LDKCVec_PhantomRouteHintsZ _res_constr;
24979         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24980         if (_res_constr.datalen > 0)
24981                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24982         else
24983                 _res_constr.data = NULL;
24984         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24985         for (size_t t = 0; t < _res_constr.datalen; t++) {
24986                 int64_t _res_conv_19 = _res_vals[t];
24987                 LDKPhantomRouteHints _res_conv_19_conv;
24988                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24989                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24990                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24991                 _res_constr.data[t] = _res_conv_19_conv;
24992         }
24993         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24994         CVec_PhantomRouteHintsZ_free(_res_constr);
24995 }
24996
24997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24998         LDKInvoice o_conv;
24999         o_conv.inner = untag_ptr(o);
25000         o_conv.is_owned = ptr_is_owned(o);
25001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25002         o_conv = Invoice_clone(&o_conv);
25003         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25004         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
25005         return tag_ptr(ret_conv, true);
25006 }
25007
25008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25009         void* e_ptr = untag_ptr(e);
25010         CHECK_ACCESS(e_ptr);
25011         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
25012         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
25013         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25014         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
25015         return tag_ptr(ret_conv, true);
25016 }
25017
25018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25019         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
25020         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
25021         return ret_conv;
25022 }
25023
25024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25025         if (!ptr_is_owned(_res)) return;
25026         void* _res_ptr = untag_ptr(_res);
25027         CHECK_ACCESS(_res_ptr);
25028         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
25029         FREE(untag_ptr(_res));
25030         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
25031 }
25032
25033 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
25034         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25035         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
25036         return tag_ptr(ret_conv, true);
25037 }
25038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25039         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
25040         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
25041         return ret_conv;
25042 }
25043
25044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25045         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
25046         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25047         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
25048         return tag_ptr(ret_conv, true);
25049 }
25050
25051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
25052         void* o_ptr = untag_ptr(o);
25053         CHECK_ACCESS(o_ptr);
25054         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
25055         if (o_conv.free == LDKFilter_JCalls_free) {
25056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25057                 LDKFilter_JCalls_cloned(&o_conv);
25058         }
25059         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25060         *ret_copy = COption_FilterZ_some(o_conv);
25061         int64_t ret_ref = tag_ptr(ret_copy, true);
25062         return ret_ref;
25063 }
25064
25065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
25066         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25067         *ret_copy = COption_FilterZ_none();
25068         int64_t ret_ref = tag_ptr(ret_copy, true);
25069         return ret_ref;
25070 }
25071
25072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25073         if (!ptr_is_owned(_res)) return;
25074         void* _res_ptr = untag_ptr(_res);
25075         CHECK_ACCESS(_res_ptr);
25076         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
25077         FREE(untag_ptr(_res));
25078         COption_FilterZ_free(_res_conv);
25079 }
25080
25081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25082         LDKLockedChannelMonitor o_conv;
25083         o_conv.inner = untag_ptr(o);
25084         o_conv.is_owned = ptr_is_owned(o);
25085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25086         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
25087         
25088         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25089         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
25090         return tag_ptr(ret_conv, true);
25091 }
25092
25093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
25094         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25095         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
25096         return tag_ptr(ret_conv, true);
25097 }
25098
25099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25100         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
25101         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
25102         return ret_conv;
25103 }
25104
25105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25106         if (!ptr_is_owned(_res)) return;
25107         void* _res_ptr = untag_ptr(_res);
25108         CHECK_ACCESS(_res_ptr);
25109         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
25110         FREE(untag_ptr(_res));
25111         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
25112 }
25113
25114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25115         LDKCVec_OutPointZ _res_constr;
25116         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25117         if (_res_constr.datalen > 0)
25118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
25119         else
25120                 _res_constr.data = NULL;
25121         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25122         for (size_t k = 0; k < _res_constr.datalen; k++) {
25123                 int64_t _res_conv_10 = _res_vals[k];
25124                 LDKOutPoint _res_conv_10_conv;
25125                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
25126                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
25127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
25128                 _res_constr.data[k] = _res_conv_10_conv;
25129         }
25130         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25131         CVec_OutPointZ_free(_res_constr);
25132 }
25133
25134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25135         if (!ptr_is_owned(this_ptr)) return;
25136         void* this_ptr_ptr = untag_ptr(this_ptr);
25137         CHECK_ACCESS(this_ptr_ptr);
25138         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
25139         FREE(untag_ptr(this_ptr));
25140         PaymentPurpose_free(this_ptr_conv);
25141 }
25142
25143 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
25144         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25145         *ret_copy = PaymentPurpose_clone(arg);
25146         int64_t ret_ref = tag_ptr(ret_copy, true);
25147         return ret_ref;
25148 }
25149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25150         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
25151         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
25152         return ret_conv;
25153 }
25154
25155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25156         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
25157         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25158         *ret_copy = PaymentPurpose_clone(orig_conv);
25159         int64_t ret_ref = tag_ptr(ret_copy, true);
25160         return ret_ref;
25161 }
25162
25163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
25164         LDKThirtyTwoBytes payment_preimage_ref;
25165         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25166         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25167         LDKThirtyTwoBytes payment_secret_ref;
25168         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25169         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25170         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25171         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
25172         int64_t ret_ref = tag_ptr(ret_copy, true);
25173         return ret_ref;
25174 }
25175
25176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
25177         LDKThirtyTwoBytes a_ref;
25178         CHECK((*env)->GetArrayLength(env, a) == 32);
25179         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
25180         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25181         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
25182         int64_t ret_ref = tag_ptr(ret_copy, true);
25183         return ret_ref;
25184 }
25185
25186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
25187         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
25188         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
25189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25191         CVec_u8Z_free(ret_var);
25192         return ret_arr;
25193 }
25194
25195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25196         LDKu8slice ser_ref;
25197         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25198         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25199         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
25200         *ret_conv = PaymentPurpose_read(ser_ref);
25201         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25202         return tag_ptr(ret_conv, true);
25203 }
25204
25205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25206         if (!ptr_is_owned(this_ptr)) return;
25207         void* this_ptr_ptr = untag_ptr(this_ptr);
25208         CHECK_ACCESS(this_ptr_ptr);
25209         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
25210         FREE(untag_ptr(this_ptr));
25211         ClosureReason_free(this_ptr_conv);
25212 }
25213
25214 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
25215         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25216         *ret_copy = ClosureReason_clone(arg);
25217         int64_t ret_ref = tag_ptr(ret_copy, true);
25218         return ret_ref;
25219 }
25220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25221         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
25222         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
25223         return ret_conv;
25224 }
25225
25226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25227         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
25228         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25229         *ret_copy = ClosureReason_clone(orig_conv);
25230         int64_t ret_ref = tag_ptr(ret_copy, true);
25231         return ret_ref;
25232 }
25233
25234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
25235         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
25236         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25237         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
25238         int64_t ret_ref = tag_ptr(ret_copy, true);
25239         return ret_ref;
25240 }
25241
25242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
25243         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25244         *ret_copy = ClosureReason_holder_force_closed();
25245         int64_t ret_ref = tag_ptr(ret_copy, true);
25246         return ret_ref;
25247 }
25248
25249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
25250         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25251         *ret_copy = ClosureReason_cooperative_closure();
25252         int64_t ret_ref = tag_ptr(ret_copy, true);
25253         return ret_ref;
25254 }
25255
25256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
25257         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25258         *ret_copy = ClosureReason_commitment_tx_confirmed();
25259         int64_t ret_ref = tag_ptr(ret_copy, true);
25260         return ret_ref;
25261 }
25262
25263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
25264         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25265         *ret_copy = ClosureReason_funding_timed_out();
25266         int64_t ret_ref = tag_ptr(ret_copy, true);
25267         return ret_ref;
25268 }
25269
25270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
25271         LDKStr err_conv = java_to_owned_str(env, err);
25272         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25273         *ret_copy = ClosureReason_processing_error(err_conv);
25274         int64_t ret_ref = tag_ptr(ret_copy, true);
25275         return ret_ref;
25276 }
25277
25278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
25279         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25280         *ret_copy = ClosureReason_disconnected_peer();
25281         int64_t ret_ref = tag_ptr(ret_copy, true);
25282         return ret_ref;
25283 }
25284
25285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
25286         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25287         *ret_copy = ClosureReason_outdated_channel_manager();
25288         int64_t ret_ref = tag_ptr(ret_copy, true);
25289         return ret_ref;
25290 }
25291
25292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25293         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
25294         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
25295         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
25296         return ret_conv;
25297 }
25298
25299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
25300         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
25301         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
25302         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25303         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25304         CVec_u8Z_free(ret_var);
25305         return ret_arr;
25306 }
25307
25308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25309         LDKu8slice ser_ref;
25310         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25311         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25312         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
25313         *ret_conv = ClosureReason_read(ser_ref);
25314         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25315         return tag_ptr(ret_conv, true);
25316 }
25317
25318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25319         if (!ptr_is_owned(this_ptr)) return;
25320         void* this_ptr_ptr = untag_ptr(this_ptr);
25321         CHECK_ACCESS(this_ptr_ptr);
25322         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
25323         FREE(untag_ptr(this_ptr));
25324         HTLCDestination_free(this_ptr_conv);
25325 }
25326
25327 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
25328         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25329         *ret_copy = HTLCDestination_clone(arg);
25330         int64_t ret_ref = tag_ptr(ret_copy, true);
25331         return ret_ref;
25332 }
25333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25334         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
25335         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
25336         return ret_conv;
25337 }
25338
25339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25340         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
25341         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25342         *ret_copy = HTLCDestination_clone(orig_conv);
25343         int64_t ret_ref = tag_ptr(ret_copy, true);
25344         return ret_ref;
25345 }
25346
25347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1next_1hop_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int8_tArray channel_id) {
25348         LDKPublicKey node_id_ref;
25349         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25350         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25351         LDKThirtyTwoBytes channel_id_ref;
25352         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25353         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25354         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25355         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
25356         int64_t ret_ref = tag_ptr(ret_copy, true);
25357         return ret_ref;
25358 }
25359
25360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
25361         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25362         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
25363         int64_t ret_ref = tag_ptr(ret_copy, true);
25364         return ret_ref;
25365 }
25366
25367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
25368         LDKThirtyTwoBytes payment_hash_ref;
25369         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25370         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25371         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25372         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
25373         int64_t ret_ref = tag_ptr(ret_copy, true);
25374         return ret_ref;
25375 }
25376
25377 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25378         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
25379         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
25380         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
25381         return ret_conv;
25382 }
25383
25384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
25385         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
25386         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
25387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25389         CVec_u8Z_free(ret_var);
25390         return ret_arr;
25391 }
25392
25393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25394         LDKu8slice ser_ref;
25395         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25396         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25397         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
25398         *ret_conv = HTLCDestination_read(ser_ref);
25399         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25400         return tag_ptr(ret_conv, true);
25401 }
25402
25403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25404         if (!ptr_is_owned(this_ptr)) return;
25405         void* this_ptr_ptr = untag_ptr(this_ptr);
25406         CHECK_ACCESS(this_ptr_ptr);
25407         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
25408         FREE(untag_ptr(this_ptr));
25409         Event_free(this_ptr_conv);
25410 }
25411
25412 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
25413         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25414         *ret_copy = Event_clone(arg);
25415         int64_t ret_ref = tag_ptr(ret_copy, true);
25416         return ret_ref;
25417 }
25418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25419         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
25420         int64_t ret_conv = Event_clone_ptr(arg_conv);
25421         return ret_conv;
25422 }
25423
25424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25425         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
25426         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25427         *ret_copy = Event_clone(orig_conv);
25428         int64_t ret_ref = tag_ptr(ret_copy, true);
25429         return ret_ref;
25430 }
25431
25432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
25433         LDKThirtyTwoBytes temporary_channel_id_ref;
25434         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25435         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25436         LDKPublicKey counterparty_node_id_ref;
25437         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25438         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25439         LDKCVec_u8Z output_script_ref;
25440         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
25441         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
25442         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
25443         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25444         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
25445         int64_t ret_ref = tag_ptr(ret_copy, true);
25446         return ret_ref;
25447 }
25448
25449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
25450         LDKThirtyTwoBytes payment_hash_ref;
25451         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25452         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25453         void* purpose_ptr = untag_ptr(purpose);
25454         CHECK_ACCESS(purpose_ptr);
25455         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25456         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25457         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25458         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
25459         int64_t ret_ref = tag_ptr(ret_copy, true);
25460         return ret_ref;
25461 }
25462
25463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
25464         LDKThirtyTwoBytes payment_hash_ref;
25465         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25466         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25467         void* purpose_ptr = untag_ptr(purpose);
25468         CHECK_ACCESS(purpose_ptr);
25469         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25470         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25471         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25472         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
25473         int64_t ret_ref = tag_ptr(ret_copy, true);
25474         return ret_ref;
25475 }
25476
25477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
25478         LDKThirtyTwoBytes payment_id_ref;
25479         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25480         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25481         LDKThirtyTwoBytes payment_preimage_ref;
25482         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25483         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25484         LDKThirtyTwoBytes payment_hash_ref;
25485         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25486         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25487         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
25488         CHECK_ACCESS(fee_paid_msat_ptr);
25489         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
25490         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
25491         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25492         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
25493         int64_t ret_ref = tag_ptr(ret_copy, true);
25494         return ret_ref;
25495 }
25496
25497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
25498         LDKThirtyTwoBytes payment_id_ref;
25499         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25500         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25501         LDKThirtyTwoBytes payment_hash_ref;
25502         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25503         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25504         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25505         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
25506         int64_t ret_ref = tag_ptr(ret_copy, true);
25507         return ret_ref;
25508 }
25509
25510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
25511         LDKThirtyTwoBytes payment_id_ref;
25512         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25513         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25514         LDKThirtyTwoBytes payment_hash_ref;
25515         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25516         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25517         LDKCVec_RouteHopZ path_constr;
25518         path_constr.datalen = (*env)->GetArrayLength(env, path);
25519         if (path_constr.datalen > 0)
25520                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25521         else
25522                 path_constr.data = NULL;
25523         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25524         for (size_t k = 0; k < path_constr.datalen; k++) {
25525                 int64_t path_conv_10 = path_vals[k];
25526                 LDKRouteHop path_conv_10_conv;
25527                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25528                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25529                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25530                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25531                 path_constr.data[k] = path_conv_10_conv;
25532         }
25533         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25534         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25535         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
25536         int64_t ret_ref = tag_ptr(ret_copy, true);
25537         return ret_ref;
25538 }
25539
25540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean payment_failed_permanently, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
25541         LDKThirtyTwoBytes payment_id_ref;
25542         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25543         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25544         LDKThirtyTwoBytes payment_hash_ref;
25545         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25546         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25547         void* network_update_ptr = untag_ptr(network_update);
25548         CHECK_ACCESS(network_update_ptr);
25549         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
25550         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
25551         LDKCVec_RouteHopZ path_constr;
25552         path_constr.datalen = (*env)->GetArrayLength(env, path);
25553         if (path_constr.datalen > 0)
25554                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25555         else
25556                 path_constr.data = NULL;
25557         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25558         for (size_t k = 0; k < path_constr.datalen; k++) {
25559                 int64_t path_conv_10 = path_vals[k];
25560                 LDKRouteHop path_conv_10_conv;
25561                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25562                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25563                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25564                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25565                 path_constr.data[k] = path_conv_10_conv;
25566         }
25567         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25568         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25569         CHECK_ACCESS(short_channel_id_ptr);
25570         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25571         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25572         LDKRouteParameters retry_conv;
25573         retry_conv.inner = untag_ptr(retry);
25574         retry_conv.is_owned = ptr_is_owned(retry);
25575         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
25576         retry_conv = RouteParameters_clone(&retry_conv);
25577         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25578         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
25579         int64_t ret_ref = tag_ptr(ret_copy, true);
25580         return ret_ref;
25581 }
25582
25583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
25584         LDKThirtyTwoBytes payment_id_ref;
25585         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25586         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25587         LDKThirtyTwoBytes payment_hash_ref;
25588         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25589         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25590         LDKCVec_RouteHopZ path_constr;
25591         path_constr.datalen = (*env)->GetArrayLength(env, path);
25592         if (path_constr.datalen > 0)
25593                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25594         else
25595                 path_constr.data = NULL;
25596         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25597         for (size_t k = 0; k < path_constr.datalen; k++) {
25598                 int64_t path_conv_10 = path_vals[k];
25599                 LDKRouteHop path_conv_10_conv;
25600                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25601                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25602                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25603                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25604                 path_constr.data[k] = path_conv_10_conv;
25605         }
25606         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25608         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
25609         int64_t ret_ref = tag_ptr(ret_copy, true);
25610         return ret_ref;
25611 }
25612
25613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
25614         LDKThirtyTwoBytes payment_id_ref;
25615         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25616         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25617         LDKThirtyTwoBytes payment_hash_ref;
25618         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25619         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25620         LDKCVec_RouteHopZ path_constr;
25621         path_constr.datalen = (*env)->GetArrayLength(env, path);
25622         if (path_constr.datalen > 0)
25623                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25624         else
25625                 path_constr.data = NULL;
25626         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25627         for (size_t k = 0; k < path_constr.datalen; k++) {
25628                 int64_t path_conv_10 = path_vals[k];
25629                 LDKRouteHop path_conv_10_conv;
25630                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25631                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25632                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25633                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25634                 path_constr.data[k] = path_conv_10_conv;
25635         }
25636         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25637         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25638         CHECK_ACCESS(short_channel_id_ptr);
25639         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25640         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25641         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25642         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
25643         int64_t ret_ref = tag_ptr(ret_copy, true);
25644         return ret_ref;
25645 }
25646
25647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
25648         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25649         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
25650         int64_t ret_ref = tag_ptr(ret_copy, true);
25651         return ret_ref;
25652 }
25653
25654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
25655         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
25656         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
25657         if (outputs_constr.datalen > 0)
25658                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25659         else
25660                 outputs_constr.data = NULL;
25661         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
25662         for (size_t b = 0; b < outputs_constr.datalen; b++) {
25663                 int64_t outputs_conv_27 = outputs_vals[b];
25664                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
25665                 CHECK_ACCESS(outputs_conv_27_ptr);
25666                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
25667                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
25668                 outputs_constr.data[b] = outputs_conv_27_conv;
25669         }
25670         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
25671         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25672         *ret_copy = Event_spendable_outputs(outputs_constr);
25673         int64_t ret_ref = tag_ptr(ret_copy, true);
25674         return ret_ref;
25675 }
25676
25677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
25678         LDKThirtyTwoBytes prev_channel_id_ref;
25679         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25680         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25681         LDKThirtyTwoBytes next_channel_id_ref;
25682         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
25683         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
25684         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
25685         CHECK_ACCESS(fee_earned_msat_ptr);
25686         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
25687         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
25688         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25689         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
25690         int64_t ret_ref = tag_ptr(ret_copy, true);
25691         return ret_ref;
25692 }
25693
25694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t user_channel_id, int64_t reason) {
25695         LDKThirtyTwoBytes channel_id_ref;
25696         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25697         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25698         void* reason_ptr = untag_ptr(reason);
25699         CHECK_ACCESS(reason_ptr);
25700         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
25701         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
25702         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25703         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
25704         int64_t ret_ref = tag_ptr(ret_copy, true);
25705         return ret_ref;
25706 }
25707
25708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
25709         LDKThirtyTwoBytes channel_id_ref;
25710         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25711         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25712         LDKTransaction transaction_ref;
25713         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
25714         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
25715         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
25716         transaction_ref.data_is_owned = true;
25717         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25718         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
25719         int64_t ret_ref = tag_ptr(ret_copy, true);
25720         return ret_ref;
25721 }
25722
25723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1open_1channel_1request(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, int64_t channel_type) {
25724         LDKThirtyTwoBytes temporary_channel_id_ref;
25725         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25726         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25727         LDKPublicKey counterparty_node_id_ref;
25728         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25729         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25730         LDKChannelTypeFeatures channel_type_conv;
25731         channel_type_conv.inner = untag_ptr(channel_type);
25732         channel_type_conv.is_owned = ptr_is_owned(channel_type);
25733         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
25734         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
25735         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25736         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
25737         int64_t ret_ref = tag_ptr(ret_copy, true);
25738         return ret_ref;
25739 }
25740
25741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlchandling_1failed(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int64_t failed_next_destination) {
25742         LDKThirtyTwoBytes prev_channel_id_ref;
25743         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25744         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25745         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
25746         CHECK_ACCESS(failed_next_destination_ptr);
25747         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
25748         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
25749         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25750         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
25751         int64_t ret_ref = tag_ptr(ret_copy, true);
25752         return ret_ref;
25753 }
25754
25755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
25756         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
25757         LDKCVec_u8Z ret_var = Event_write(obj_conv);
25758         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25759         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25760         CVec_u8Z_free(ret_var);
25761         return ret_arr;
25762 }
25763
25764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25765         LDKu8slice ser_ref;
25766         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25767         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25768         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
25769         *ret_conv = Event_read(ser_ref);
25770         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25771         return tag_ptr(ret_conv, true);
25772 }
25773
25774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25775         if (!ptr_is_owned(this_ptr)) return;
25776         void* this_ptr_ptr = untag_ptr(this_ptr);
25777         CHECK_ACCESS(this_ptr_ptr);
25778         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
25779         FREE(untag_ptr(this_ptr));
25780         MessageSendEvent_free(this_ptr_conv);
25781 }
25782
25783 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
25784         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25785         *ret_copy = MessageSendEvent_clone(arg);
25786         int64_t ret_ref = tag_ptr(ret_copy, true);
25787         return ret_ref;
25788 }
25789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25790         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
25791         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
25792         return ret_conv;
25793 }
25794
25795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25796         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
25797         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25798         *ret_copy = MessageSendEvent_clone(orig_conv);
25799         int64_t ret_ref = tag_ptr(ret_copy, true);
25800         return ret_ref;
25801 }
25802
25803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25804         LDKPublicKey node_id_ref;
25805         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25806         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25807         LDKAcceptChannel msg_conv;
25808         msg_conv.inner = untag_ptr(msg);
25809         msg_conv.is_owned = ptr_is_owned(msg);
25810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25811         msg_conv = AcceptChannel_clone(&msg_conv);
25812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25813         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
25814         int64_t ret_ref = tag_ptr(ret_copy, true);
25815         return ret_ref;
25816 }
25817
25818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25819         LDKPublicKey node_id_ref;
25820         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25821         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25822         LDKOpenChannel msg_conv;
25823         msg_conv.inner = untag_ptr(msg);
25824         msg_conv.is_owned = ptr_is_owned(msg);
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25826         msg_conv = OpenChannel_clone(&msg_conv);
25827         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25828         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
25829         int64_t ret_ref = tag_ptr(ret_copy, true);
25830         return ret_ref;
25831 }
25832
25833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25834         LDKPublicKey node_id_ref;
25835         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25836         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25837         LDKFundingCreated msg_conv;
25838         msg_conv.inner = untag_ptr(msg);
25839         msg_conv.is_owned = ptr_is_owned(msg);
25840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25841         msg_conv = FundingCreated_clone(&msg_conv);
25842         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25843         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
25844         int64_t ret_ref = tag_ptr(ret_copy, true);
25845         return ret_ref;
25846 }
25847
25848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25849         LDKPublicKey node_id_ref;
25850         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25851         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25852         LDKFundingSigned msg_conv;
25853         msg_conv.inner = untag_ptr(msg);
25854         msg_conv.is_owned = ptr_is_owned(msg);
25855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25856         msg_conv = FundingSigned_clone(&msg_conv);
25857         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25858         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
25859         int64_t ret_ref = tag_ptr(ret_copy, true);
25860         return ret_ref;
25861 }
25862
25863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25864         LDKPublicKey node_id_ref;
25865         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25866         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25867         LDKChannelReady msg_conv;
25868         msg_conv.inner = untag_ptr(msg);
25869         msg_conv.is_owned = ptr_is_owned(msg);
25870         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25871         msg_conv = ChannelReady_clone(&msg_conv);
25872         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25873         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25874         int64_t ret_ref = tag_ptr(ret_copy, true);
25875         return ret_ref;
25876 }
25877
25878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25879         LDKPublicKey node_id_ref;
25880         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25881         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25882         LDKAnnouncementSignatures msg_conv;
25883         msg_conv.inner = untag_ptr(msg);
25884         msg_conv.is_owned = ptr_is_owned(msg);
25885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25886         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25887         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25888         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25889         int64_t ret_ref = tag_ptr(ret_copy, true);
25890         return ret_ref;
25891 }
25892
25893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25894         LDKPublicKey node_id_ref;
25895         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25896         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25897         LDKCommitmentUpdate updates_conv;
25898         updates_conv.inner = untag_ptr(updates);
25899         updates_conv.is_owned = ptr_is_owned(updates);
25900         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25901         updates_conv = CommitmentUpdate_clone(&updates_conv);
25902         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25903         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25904         int64_t ret_ref = tag_ptr(ret_copy, true);
25905         return ret_ref;
25906 }
25907
25908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1revoke_1and_1ack(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25909         LDKPublicKey node_id_ref;
25910         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25911         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25912         LDKRevokeAndACK msg_conv;
25913         msg_conv.inner = untag_ptr(msg);
25914         msg_conv.is_owned = ptr_is_owned(msg);
25915         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25916         msg_conv = RevokeAndACK_clone(&msg_conv);
25917         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25918         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25919         int64_t ret_ref = tag_ptr(ret_copy, true);
25920         return ret_ref;
25921 }
25922
25923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25924         LDKPublicKey node_id_ref;
25925         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25926         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25927         LDKClosingSigned msg_conv;
25928         msg_conv.inner = untag_ptr(msg);
25929         msg_conv.is_owned = ptr_is_owned(msg);
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25931         msg_conv = ClosingSigned_clone(&msg_conv);
25932         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25933         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25934         int64_t ret_ref = tag_ptr(ret_copy, true);
25935         return ret_ref;
25936 }
25937
25938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25939         LDKPublicKey node_id_ref;
25940         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25941         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25942         LDKShutdown msg_conv;
25943         msg_conv.inner = untag_ptr(msg);
25944         msg_conv.is_owned = ptr_is_owned(msg);
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25946         msg_conv = Shutdown_clone(&msg_conv);
25947         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25948         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25949         int64_t ret_ref = tag_ptr(ret_copy, true);
25950         return ret_ref;
25951 }
25952
25953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25954         LDKPublicKey node_id_ref;
25955         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25956         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25957         LDKChannelReestablish msg_conv;
25958         msg_conv.inner = untag_ptr(msg);
25959         msg_conv.is_owned = ptr_is_owned(msg);
25960         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25961         msg_conv = ChannelReestablish_clone(&msg_conv);
25962         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25963         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25964         int64_t ret_ref = tag_ptr(ret_copy, true);
25965         return ret_ref;
25966 }
25967
25968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1announcement(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg, int64_t update_msg) {
25969         LDKPublicKey node_id_ref;
25970         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25971         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25972         LDKChannelAnnouncement msg_conv;
25973         msg_conv.inner = untag_ptr(msg);
25974         msg_conv.is_owned = ptr_is_owned(msg);
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25976         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25977         LDKChannelUpdate update_msg_conv;
25978         update_msg_conv.inner = untag_ptr(update_msg);
25979         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25980         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25981         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25982         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25983         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
25984         int64_t ret_ref = tag_ptr(ret_copy, true);
25985         return ret_ref;
25986 }
25987
25988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25989         LDKChannelAnnouncement msg_conv;
25990         msg_conv.inner = untag_ptr(msg);
25991         msg_conv.is_owned = ptr_is_owned(msg);
25992         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25993         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25994         LDKChannelUpdate update_msg_conv;
25995         update_msg_conv.inner = untag_ptr(update_msg);
25996         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25997         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25998         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25999         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26000         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
26001         int64_t ret_ref = tag_ptr(ret_copy, true);
26002         return ret_ref;
26003 }
26004
26005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
26006         LDKChannelUpdate msg_conv;
26007         msg_conv.inner = untag_ptr(msg);
26008         msg_conv.is_owned = ptr_is_owned(msg);
26009         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26010         msg_conv = ChannelUpdate_clone(&msg_conv);
26011         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26012         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
26013         int64_t ret_ref = tag_ptr(ret_copy, true);
26014         return ret_ref;
26015 }
26016
26017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26018         LDKPublicKey node_id_ref;
26019         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26020         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26021         LDKChannelUpdate msg_conv;
26022         msg_conv.inner = untag_ptr(msg);
26023         msg_conv.is_owned = ptr_is_owned(msg);
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26025         msg_conv = ChannelUpdate_clone(&msg_conv);
26026         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26027         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
26028         int64_t ret_ref = tag_ptr(ret_copy, true);
26029         return ret_ref;
26030 }
26031
26032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
26033         LDKPublicKey node_id_ref;
26034         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26035         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26036         void* action_ptr = untag_ptr(action);
26037         CHECK_ACCESS(action_ptr);
26038         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
26039         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
26040         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26041         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
26042         int64_t ret_ref = tag_ptr(ret_copy, true);
26043         return ret_ref;
26044 }
26045
26046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26047         LDKPublicKey node_id_ref;
26048         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26049         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26050         LDKQueryChannelRange msg_conv;
26051         msg_conv.inner = untag_ptr(msg);
26052         msg_conv.is_owned = ptr_is_owned(msg);
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26054         msg_conv = QueryChannelRange_clone(&msg_conv);
26055         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26056         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
26057         int64_t ret_ref = tag_ptr(ret_copy, true);
26058         return ret_ref;
26059 }
26060
26061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1short_1ids_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26062         LDKPublicKey node_id_ref;
26063         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26064         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26065         LDKQueryShortChannelIds msg_conv;
26066         msg_conv.inner = untag_ptr(msg);
26067         msg_conv.is_owned = ptr_is_owned(msg);
26068         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26069         msg_conv = QueryShortChannelIds_clone(&msg_conv);
26070         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26071         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
26072         int64_t ret_ref = tag_ptr(ret_copy, true);
26073         return ret_ref;
26074 }
26075
26076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26077         LDKPublicKey node_id_ref;
26078         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26079         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26080         LDKReplyChannelRange msg_conv;
26081         msg_conv.inner = untag_ptr(msg);
26082         msg_conv.is_owned = ptr_is_owned(msg);
26083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26084         msg_conv = ReplyChannelRange_clone(&msg_conv);
26085         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26086         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
26087         int64_t ret_ref = tag_ptr(ret_copy, true);
26088         return ret_ref;
26089 }
26090
26091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1gossip_1timestamp_1filter(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26092         LDKPublicKey node_id_ref;
26093         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26094         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26095         LDKGossipTimestampFilter msg_conv;
26096         msg_conv.inner = untag_ptr(msg);
26097         msg_conv.is_owned = ptr_is_owned(msg);
26098         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26099         msg_conv = GossipTimestampFilter_clone(&msg_conv);
26100         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26101         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
26102         int64_t ret_ref = tag_ptr(ret_copy, true);
26103         return ret_ref;
26104 }
26105
26106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26107         if (!ptr_is_owned(this_ptr)) return;
26108         void* this_ptr_ptr = untag_ptr(this_ptr);
26109         CHECK_ACCESS(this_ptr_ptr);
26110         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
26111         FREE(untag_ptr(this_ptr));
26112         MessageSendEventsProvider_free(this_ptr_conv);
26113 }
26114
26115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26116         if (!ptr_is_owned(this_ptr)) return;
26117         void* this_ptr_ptr = untag_ptr(this_ptr);
26118         CHECK_ACCESS(this_ptr_ptr);
26119         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
26120         FREE(untag_ptr(this_ptr));
26121         OnionMessageProvider_free(this_ptr_conv);
26122 }
26123
26124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26125         if (!ptr_is_owned(this_ptr)) return;
26126         void* this_ptr_ptr = untag_ptr(this_ptr);
26127         CHECK_ACCESS(this_ptr_ptr);
26128         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
26129         FREE(untag_ptr(this_ptr));
26130         EventsProvider_free(this_ptr_conv);
26131 }
26132
26133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26134         if (!ptr_is_owned(this_ptr)) return;
26135         void* this_ptr_ptr = untag_ptr(this_ptr);
26136         CHECK_ACCESS(this_ptr_ptr);
26137         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
26138         FREE(untag_ptr(this_ptr));
26139         EventHandler_free(this_ptr_conv);
26140 }
26141
26142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26143         if (!ptr_is_owned(this_ptr)) return;
26144         void* this_ptr_ptr = untag_ptr(this_ptr);
26145         CHECK_ACCESS(this_ptr_ptr);
26146         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
26147         FREE(untag_ptr(this_ptr));
26148         APIError_free(this_ptr_conv);
26149 }
26150
26151 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
26152         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26153         *ret_copy = APIError_clone(arg);
26154         int64_t ret_ref = tag_ptr(ret_copy, true);
26155         return ret_ref;
26156 }
26157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26158         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
26159         int64_t ret_conv = APIError_clone_ptr(arg_conv);
26160         return ret_conv;
26161 }
26162
26163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26164         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
26165         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26166         *ret_copy = APIError_clone(orig_conv);
26167         int64_t ret_ref = tag_ptr(ret_copy, true);
26168         return ret_ref;
26169 }
26170
26171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
26172         LDKStr err_conv = java_to_owned_str(env, err);
26173         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26174         *ret_copy = APIError_apimisuse_error(err_conv);
26175         int64_t ret_ref = tag_ptr(ret_copy, true);
26176         return ret_ref;
26177 }
26178
26179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
26180         LDKStr err_conv = java_to_owned_str(env, err);
26181         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26182         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
26183         int64_t ret_ref = tag_ptr(ret_copy, true);
26184         return ret_ref;
26185 }
26186
26187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
26188         LDKStr err_conv = java_to_owned_str(env, err);
26189         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26190         *ret_copy = APIError_route_error(err_conv);
26191         int64_t ret_ref = tag_ptr(ret_copy, true);
26192         return ret_ref;
26193 }
26194
26195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
26196         LDKStr err_conv = java_to_owned_str(env, err);
26197         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26198         *ret_copy = APIError_channel_unavailable(err_conv);
26199         int64_t ret_ref = tag_ptr(ret_copy, true);
26200         return ret_ref;
26201 }
26202
26203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
26204         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26205         *ret_copy = APIError_monitor_update_in_progress();
26206         int64_t ret_ref = tag_ptr(ret_copy, true);
26207         return ret_ref;
26208 }
26209
26210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
26211         LDKShutdownScript script_conv;
26212         script_conv.inner = untag_ptr(script);
26213         script_conv.is_owned = ptr_is_owned(script);
26214         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
26215         script_conv = ShutdownScript_clone(&script_conv);
26216         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26217         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
26218         int64_t ret_ref = tag_ptr(ret_copy, true);
26219         return ret_ref;
26220 }
26221
26222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26223         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
26224         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
26225         jboolean ret_conv = APIError_eq(a_conv, b_conv);
26226         return ret_conv;
26227 }
26228
26229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26230         LDKBigSize this_obj_conv;
26231         this_obj_conv.inner = untag_ptr(this_obj);
26232         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26234         BigSize_free(this_obj_conv);
26235 }
26236
26237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
26238         LDKBigSize this_ptr_conv;
26239         this_ptr_conv.inner = untag_ptr(this_ptr);
26240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26242         this_ptr_conv.is_owned = false;
26243         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
26244         return ret_conv;
26245 }
26246
26247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26248         LDKBigSize this_ptr_conv;
26249         this_ptr_conv.inner = untag_ptr(this_ptr);
26250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26252         this_ptr_conv.is_owned = false;
26253         BigSize_set_a(&this_ptr_conv, val);
26254 }
26255
26256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
26257         LDKBigSize ret_var = BigSize_new(a_arg);
26258         int64_t ret_ref = 0;
26259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26261         return ret_ref;
26262 }
26263
26264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26265         LDKHostname this_obj_conv;
26266         this_obj_conv.inner = untag_ptr(this_obj);
26267         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26269         Hostname_free(this_obj_conv);
26270 }
26271
26272 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
26273         LDKHostname ret_var = Hostname_clone(arg);
26274         int64_t ret_ref = 0;
26275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26277         return ret_ref;
26278 }
26279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26280         LDKHostname arg_conv;
26281         arg_conv.inner = untag_ptr(arg);
26282         arg_conv.is_owned = ptr_is_owned(arg);
26283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26284         arg_conv.is_owned = false;
26285         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
26286         return ret_conv;
26287 }
26288
26289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26290         LDKHostname orig_conv;
26291         orig_conv.inner = untag_ptr(orig);
26292         orig_conv.is_owned = ptr_is_owned(orig);
26293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26294         orig_conv.is_owned = false;
26295         LDKHostname ret_var = Hostname_clone(&orig_conv);
26296         int64_t ret_ref = 0;
26297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26299         return ret_ref;
26300 }
26301
26302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26303         LDKHostname a_conv;
26304         a_conv.inner = untag_ptr(a);
26305         a_conv.is_owned = ptr_is_owned(a);
26306         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26307         a_conv.is_owned = false;
26308         LDKHostname b_conv;
26309         b_conv.inner = untag_ptr(b);
26310         b_conv.is_owned = ptr_is_owned(b);
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26312         b_conv.is_owned = false;
26313         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
26314         return ret_conv;
26315 }
26316
26317 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
26318         LDKHostname this_arg_conv;
26319         this_arg_conv.inner = untag_ptr(this_arg);
26320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26322         this_arg_conv.is_owned = false;
26323         int8_t ret_conv = Hostname_len(&this_arg_conv);
26324         return ret_conv;
26325 }
26326
26327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
26328         LDKu8slice msg_ref;
26329         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26330         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26331         unsigned char sk_arr[32];
26332         CHECK((*env)->GetArrayLength(env, sk) == 32);
26333         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
26334         unsigned char (*sk_ref)[32] = &sk_arr;
26335         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
26336         *ret_conv = sign(msg_ref, sk_ref);
26337         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26338         return tag_ptr(ret_conv, true);
26339 }
26340
26341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
26342         LDKu8slice msg_ref;
26343         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26344         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26345         LDKStr sig_conv = java_to_owned_str(env, sig);
26346         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
26347         *ret_conv = recover_pk(msg_ref, sig_conv);
26348         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26349         return tag_ptr(ret_conv, true);
26350 }
26351
26352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
26353         LDKu8slice msg_ref;
26354         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26355         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26356         LDKStr sig_conv = java_to_owned_str(env, sig);
26357         LDKPublicKey pk_ref;
26358         CHECK((*env)->GetArrayLength(env, pk) == 33);
26359         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
26360         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
26361         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26362         return ret_conv;
26363 }
26364
26365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
26366         LDKu8slice hrp_bytes_ref;
26367         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
26368         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
26369         LDKCVec_u5Z data_without_signature_constr;
26370         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
26371         if (data_without_signature_constr.datalen > 0)
26372                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
26373         else
26374                 data_without_signature_constr.data = NULL;
26375         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
26376         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
26377                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
26378                 
26379                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
26380         }
26381         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
26382         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
26383         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26384         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26385         CVec_u8Z_free(ret_var);
26386         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
26387         return ret_arr;
26388 }
26389
26390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26391         if (!ptr_is_owned(this_ptr)) return;
26392         void* this_ptr_ptr = untag_ptr(this_ptr);
26393         CHECK_ACCESS(this_ptr_ptr);
26394         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
26395         FREE(untag_ptr(this_ptr));
26396         Persister_free(this_ptr_conv);
26397 }
26398
26399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26400         if (!ptr_is_owned(this_ptr)) return;
26401         void* this_ptr_ptr = untag_ptr(this_ptr);
26402         CHECK_ACCESS(this_ptr_ptr);
26403         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
26404         FREE(untag_ptr(this_ptr));
26405         FutureCallback_free(this_ptr_conv);
26406 }
26407
26408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26409         LDKFuture this_obj_conv;
26410         this_obj_conv.inner = untag_ptr(this_obj);
26411         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26413         Future_free(this_obj_conv);
26414 }
26415
26416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
26417         LDKFuture this_arg_conv;
26418         this_arg_conv.inner = untag_ptr(this_arg);
26419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26421         this_arg_conv.is_owned = false;
26422         void* callback_ptr = untag_ptr(callback);
26423         CHECK_ACCESS(callback_ptr);
26424         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
26425         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
26426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26427                 LDKFutureCallback_JCalls_cloned(&callback_conv);
26428         }
26429         Future_register_callback_fn(&this_arg_conv, callback_conv);
26430 }
26431
26432 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26433         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
26434         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
26435         return ret_conv;
26436 }
26437
26438 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
26439         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
26440         return ret_conv;
26441 }
26442
26443 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
26444         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
26445         return ret_conv;
26446 }
26447
26448 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
26449         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
26450         return ret_conv;
26451 }
26452
26453 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
26454         jclass ret_conv = LDKLevel_to_java(env, Level_info());
26455         return ret_conv;
26456 }
26457
26458 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
26459         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
26460         return ret_conv;
26461 }
26462
26463 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
26464         jclass ret_conv = LDKLevel_to_java(env, Level_error());
26465         return ret_conv;
26466 }
26467
26468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26469         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
26470         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
26471         jboolean ret_conv = Level_eq(a_conv, b_conv);
26472         return ret_conv;
26473 }
26474
26475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
26476         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
26477         int64_t ret_conv = Level_hash(o_conv);
26478         return ret_conv;
26479 }
26480
26481 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
26482         jclass ret_conv = LDKLevel_to_java(env, Level_max());
26483         return ret_conv;
26484 }
26485
26486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26487         LDKRecord this_obj_conv;
26488         this_obj_conv.inner = untag_ptr(this_obj);
26489         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26491         Record_free(this_obj_conv);
26492 }
26493
26494 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
26495         LDKRecord this_ptr_conv;
26496         this_ptr_conv.inner = untag_ptr(this_ptr);
26497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26499         this_ptr_conv.is_owned = false;
26500         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
26501         return ret_conv;
26502 }
26503
26504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
26505         LDKRecord this_ptr_conv;
26506         this_ptr_conv.inner = untag_ptr(this_ptr);
26507         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26509         this_ptr_conv.is_owned = false;
26510         LDKLevel val_conv = LDKLevel_from_java(env, val);
26511         Record_set_level(&this_ptr_conv, val_conv);
26512 }
26513
26514 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
26515         LDKRecord this_ptr_conv;
26516         this_ptr_conv.inner = untag_ptr(this_ptr);
26517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26519         this_ptr_conv.is_owned = false;
26520         LDKStr ret_str = Record_get_args(&this_ptr_conv);
26521         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26522         Str_free(ret_str);
26523         return ret_conv;
26524 }
26525
26526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26527         LDKRecord this_ptr_conv;
26528         this_ptr_conv.inner = untag_ptr(this_ptr);
26529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26531         this_ptr_conv.is_owned = false;
26532         LDKStr val_conv = java_to_owned_str(env, val);
26533         Record_set_args(&this_ptr_conv, val_conv);
26534 }
26535
26536 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
26537         LDKRecord this_ptr_conv;
26538         this_ptr_conv.inner = untag_ptr(this_ptr);
26539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26541         this_ptr_conv.is_owned = false;
26542         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
26543         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26544         Str_free(ret_str);
26545         return ret_conv;
26546 }
26547
26548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26549         LDKRecord this_ptr_conv;
26550         this_ptr_conv.inner = untag_ptr(this_ptr);
26551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26553         this_ptr_conv.is_owned = false;
26554         LDKStr val_conv = java_to_owned_str(env, val);
26555         Record_set_module_path(&this_ptr_conv, val_conv);
26556 }
26557
26558 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
26559         LDKRecord this_ptr_conv;
26560         this_ptr_conv.inner = untag_ptr(this_ptr);
26561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26563         this_ptr_conv.is_owned = false;
26564         LDKStr ret_str = Record_get_file(&this_ptr_conv);
26565         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26566         Str_free(ret_str);
26567         return ret_conv;
26568 }
26569
26570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26571         LDKRecord this_ptr_conv;
26572         this_ptr_conv.inner = untag_ptr(this_ptr);
26573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26575         this_ptr_conv.is_owned = false;
26576         LDKStr val_conv = java_to_owned_str(env, val);
26577         Record_set_file(&this_ptr_conv, val_conv);
26578 }
26579
26580 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
26581         LDKRecord this_ptr_conv;
26582         this_ptr_conv.inner = untag_ptr(this_ptr);
26583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26585         this_ptr_conv.is_owned = false;
26586         int32_t ret_conv = Record_get_line(&this_ptr_conv);
26587         return ret_conv;
26588 }
26589
26590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26591         LDKRecord this_ptr_conv;
26592         this_ptr_conv.inner = untag_ptr(this_ptr);
26593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26595         this_ptr_conv.is_owned = false;
26596         Record_set_line(&this_ptr_conv, val);
26597 }
26598
26599 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
26600         LDKRecord ret_var = Record_clone(arg);
26601         int64_t ret_ref = 0;
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26604         return ret_ref;
26605 }
26606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26607         LDKRecord arg_conv;
26608         arg_conv.inner = untag_ptr(arg);
26609         arg_conv.is_owned = ptr_is_owned(arg);
26610         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26611         arg_conv.is_owned = false;
26612         int64_t ret_conv = Record_clone_ptr(&arg_conv);
26613         return ret_conv;
26614 }
26615
26616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26617         LDKRecord orig_conv;
26618         orig_conv.inner = untag_ptr(orig);
26619         orig_conv.is_owned = ptr_is_owned(orig);
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26621         orig_conv.is_owned = false;
26622         LDKRecord ret_var = Record_clone(&orig_conv);
26623         int64_t ret_ref = 0;
26624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26626         return ret_ref;
26627 }
26628
26629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26630         if (!ptr_is_owned(this_ptr)) return;
26631         void* this_ptr_ptr = untag_ptr(this_ptr);
26632         CHECK_ACCESS(this_ptr_ptr);
26633         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
26634         FREE(untag_ptr(this_ptr));
26635         Logger_free(this_ptr_conv);
26636 }
26637
26638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26639         LDKChannelHandshakeConfig this_obj_conv;
26640         this_obj_conv.inner = untag_ptr(this_obj);
26641         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26643         ChannelHandshakeConfig_free(this_obj_conv);
26644 }
26645
26646 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26647         LDKChannelHandshakeConfig this_ptr_conv;
26648         this_ptr_conv.inner = untag_ptr(this_ptr);
26649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26651         this_ptr_conv.is_owned = false;
26652         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
26653         return ret_conv;
26654 }
26655
26656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26657         LDKChannelHandshakeConfig this_ptr_conv;
26658         this_ptr_conv.inner = untag_ptr(this_ptr);
26659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26661         this_ptr_conv.is_owned = false;
26662         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
26663 }
26664
26665 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26666         LDKChannelHandshakeConfig this_ptr_conv;
26667         this_ptr_conv.inner = untag_ptr(this_ptr);
26668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26670         this_ptr_conv.is_owned = false;
26671         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
26672         return ret_conv;
26673 }
26674
26675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26676         LDKChannelHandshakeConfig this_ptr_conv;
26677         this_ptr_conv.inner = untag_ptr(this_ptr);
26678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26680         this_ptr_conv.is_owned = false;
26681         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
26682 }
26683
26684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26685         LDKChannelHandshakeConfig this_ptr_conv;
26686         this_ptr_conv.inner = untag_ptr(this_ptr);
26687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26689         this_ptr_conv.is_owned = false;
26690         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
26691         return ret_conv;
26692 }
26693
26694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26695         LDKChannelHandshakeConfig this_ptr_conv;
26696         this_ptr_conv.inner = untag_ptr(this_ptr);
26697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26699         this_ptr_conv.is_owned = false;
26700         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
26701 }
26702
26703 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
26704         LDKChannelHandshakeConfig this_ptr_conv;
26705         this_ptr_conv.inner = untag_ptr(this_ptr);
26706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26708         this_ptr_conv.is_owned = false;
26709         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
26710         return ret_conv;
26711 }
26712
26713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
26714         LDKChannelHandshakeConfig this_ptr_conv;
26715         this_ptr_conv.inner = untag_ptr(this_ptr);
26716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26718         this_ptr_conv.is_owned = false;
26719         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
26720 }
26721
26722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
26723         LDKChannelHandshakeConfig this_ptr_conv;
26724         this_ptr_conv.inner = untag_ptr(this_ptr);
26725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26727         this_ptr_conv.is_owned = false;
26728         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
26729         return ret_conv;
26730 }
26731
26732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26733         LDKChannelHandshakeConfig this_ptr_conv;
26734         this_ptr_conv.inner = untag_ptr(this_ptr);
26735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26737         this_ptr_conv.is_owned = false;
26738         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
26739 }
26740
26741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
26742         LDKChannelHandshakeConfig this_ptr_conv;
26743         this_ptr_conv.inner = untag_ptr(this_ptr);
26744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26746         this_ptr_conv.is_owned = false;
26747         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
26748         return ret_conv;
26749 }
26750
26751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26752         LDKChannelHandshakeConfig this_ptr_conv;
26753         this_ptr_conv.inner = untag_ptr(this_ptr);
26754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26756         this_ptr_conv.is_owned = false;
26757         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
26758 }
26759
26760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26761         LDKChannelHandshakeConfig this_ptr_conv;
26762         this_ptr_conv.inner = untag_ptr(this_ptr);
26763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26765         this_ptr_conv.is_owned = false;
26766         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
26767         return ret_conv;
26768 }
26769
26770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26771         LDKChannelHandshakeConfig this_ptr_conv;
26772         this_ptr_conv.inner = untag_ptr(this_ptr);
26773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26775         this_ptr_conv.is_owned = false;
26776         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
26777 }
26778
26779 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26780         LDKChannelHandshakeConfig this_ptr_conv;
26781         this_ptr_conv.inner = untag_ptr(this_ptr);
26782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26784         this_ptr_conv.is_owned = false;
26785         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
26786         return ret_conv;
26787 }
26788
26789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26790         LDKChannelHandshakeConfig this_ptr_conv;
26791         this_ptr_conv.inner = untag_ptr(this_ptr);
26792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26794         this_ptr_conv.is_owned = false;
26795         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
26796 }
26797
26798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg) {
26799         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg);
26800         int64_t ret_ref = 0;
26801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26803         return ret_ref;
26804 }
26805
26806 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
26807         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
26808         int64_t ret_ref = 0;
26809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26811         return ret_ref;
26812 }
26813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26814         LDKChannelHandshakeConfig arg_conv;
26815         arg_conv.inner = untag_ptr(arg);
26816         arg_conv.is_owned = ptr_is_owned(arg);
26817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26818         arg_conv.is_owned = false;
26819         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
26820         return ret_conv;
26821 }
26822
26823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26824         LDKChannelHandshakeConfig orig_conv;
26825         orig_conv.inner = untag_ptr(orig);
26826         orig_conv.is_owned = ptr_is_owned(orig);
26827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26828         orig_conv.is_owned = false;
26829         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
26830         int64_t ret_ref = 0;
26831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26833         return ret_ref;
26834 }
26835
26836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
26837         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
26838         int64_t ret_ref = 0;
26839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26840         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26841         return ret_ref;
26842 }
26843
26844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26845         LDKChannelHandshakeLimits this_obj_conv;
26846         this_obj_conv.inner = untag_ptr(this_obj);
26847         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26849         ChannelHandshakeLimits_free(this_obj_conv);
26850 }
26851
26852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26853         LDKChannelHandshakeLimits this_ptr_conv;
26854         this_ptr_conv.inner = untag_ptr(this_ptr);
26855         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26857         this_ptr_conv.is_owned = false;
26858         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
26859         return ret_conv;
26860 }
26861
26862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26863         LDKChannelHandshakeLimits this_ptr_conv;
26864         this_ptr_conv.inner = untag_ptr(this_ptr);
26865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26867         this_ptr_conv.is_owned = false;
26868         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
26869 }
26870
26871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26872         LDKChannelHandshakeLimits this_ptr_conv;
26873         this_ptr_conv.inner = untag_ptr(this_ptr);
26874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26876         this_ptr_conv.is_owned = false;
26877         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
26878         return ret_conv;
26879 }
26880
26881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26882         LDKChannelHandshakeLimits this_ptr_conv;
26883         this_ptr_conv.inner = untag_ptr(this_ptr);
26884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26886         this_ptr_conv.is_owned = false;
26887         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
26888 }
26889
26890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26891         LDKChannelHandshakeLimits this_ptr_conv;
26892         this_ptr_conv.inner = untag_ptr(this_ptr);
26893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26895         this_ptr_conv.is_owned = false;
26896         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
26897         return ret_conv;
26898 }
26899
26900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26901         LDKChannelHandshakeLimits this_ptr_conv;
26902         this_ptr_conv.inner = untag_ptr(this_ptr);
26903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26905         this_ptr_conv.is_owned = false;
26906         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
26907 }
26908
26909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26910         LDKChannelHandshakeLimits this_ptr_conv;
26911         this_ptr_conv.inner = untag_ptr(this_ptr);
26912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26914         this_ptr_conv.is_owned = false;
26915         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
26916         return ret_conv;
26917 }
26918
26919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26920         LDKChannelHandshakeLimits this_ptr_conv;
26921         this_ptr_conv.inner = untag_ptr(this_ptr);
26922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26924         this_ptr_conv.is_owned = false;
26925         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26926 }
26927
26928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26929         LDKChannelHandshakeLimits this_ptr_conv;
26930         this_ptr_conv.inner = untag_ptr(this_ptr);
26931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26933         this_ptr_conv.is_owned = false;
26934         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
26935         return ret_conv;
26936 }
26937
26938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26939         LDKChannelHandshakeLimits this_ptr_conv;
26940         this_ptr_conv.inner = untag_ptr(this_ptr);
26941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26943         this_ptr_conv.is_owned = false;
26944         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
26945 }
26946
26947 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26948         LDKChannelHandshakeLimits this_ptr_conv;
26949         this_ptr_conv.inner = untag_ptr(this_ptr);
26950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26952         this_ptr_conv.is_owned = false;
26953         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
26954         return ret_conv;
26955 }
26956
26957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26958         LDKChannelHandshakeLimits this_ptr_conv;
26959         this_ptr_conv.inner = untag_ptr(this_ptr);
26960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26962         this_ptr_conv.is_owned = false;
26963         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26964 }
26965
26966 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26967         LDKChannelHandshakeLimits this_ptr_conv;
26968         this_ptr_conv.inner = untag_ptr(this_ptr);
26969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26971         this_ptr_conv.is_owned = false;
26972         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26973         return ret_conv;
26974 }
26975
26976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26977         LDKChannelHandshakeLimits this_ptr_conv;
26978         this_ptr_conv.inner = untag_ptr(this_ptr);
26979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26981         this_ptr_conv.is_owned = false;
26982         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26983 }
26984
26985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26986         LDKChannelHandshakeLimits this_ptr_conv;
26987         this_ptr_conv.inner = untag_ptr(this_ptr);
26988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26990         this_ptr_conv.is_owned = false;
26991         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26992         return ret_conv;
26993 }
26994
26995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26996         LDKChannelHandshakeLimits this_ptr_conv;
26997         this_ptr_conv.inner = untag_ptr(this_ptr);
26998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27000         this_ptr_conv.is_owned = false;
27001         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
27002 }
27003
27004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
27005         LDKChannelHandshakeLimits this_ptr_conv;
27006         this_ptr_conv.inner = untag_ptr(this_ptr);
27007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27009         this_ptr_conv.is_owned = false;
27010         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
27011         return ret_conv;
27012 }
27013
27014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27015         LDKChannelHandshakeLimits this_ptr_conv;
27016         this_ptr_conv.inner = untag_ptr(this_ptr);
27017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27019         this_ptr_conv.is_owned = false;
27020         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
27021 }
27022
27023 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27024         LDKChannelHandshakeLimits this_ptr_conv;
27025         this_ptr_conv.inner = untag_ptr(this_ptr);
27026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27028         this_ptr_conv.is_owned = false;
27029         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
27030         return ret_conv;
27031 }
27032
27033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27034         LDKChannelHandshakeLimits this_ptr_conv;
27035         this_ptr_conv.inner = untag_ptr(this_ptr);
27036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27038         this_ptr_conv.is_owned = false;
27039         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
27040 }
27041
27042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
27043         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
27044         int64_t ret_ref = 0;
27045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27047         return ret_ref;
27048 }
27049
27050 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
27051         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
27052         int64_t ret_ref = 0;
27053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27055         return ret_ref;
27056 }
27057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27058         LDKChannelHandshakeLimits arg_conv;
27059         arg_conv.inner = untag_ptr(arg);
27060         arg_conv.is_owned = ptr_is_owned(arg);
27061         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27062         arg_conv.is_owned = false;
27063         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
27064         return ret_conv;
27065 }
27066
27067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27068         LDKChannelHandshakeLimits orig_conv;
27069         orig_conv.inner = untag_ptr(orig);
27070         orig_conv.is_owned = ptr_is_owned(orig);
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27072         orig_conv.is_owned = false;
27073         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
27074         int64_t ret_ref = 0;
27075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27077         return ret_ref;
27078 }
27079
27080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
27081         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
27082         int64_t ret_ref = 0;
27083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27085         return ret_ref;
27086 }
27087
27088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27089         LDKChannelConfig this_obj_conv;
27090         this_obj_conv.inner = untag_ptr(this_obj);
27091         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27093         ChannelConfig_free(this_obj_conv);
27094 }
27095
27096 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27097         LDKChannelConfig this_ptr_conv;
27098         this_ptr_conv.inner = untag_ptr(this_ptr);
27099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27101         this_ptr_conv.is_owned = false;
27102         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
27103         return ret_conv;
27104 }
27105
27106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27107         LDKChannelConfig this_ptr_conv;
27108         this_ptr_conv.inner = untag_ptr(this_ptr);
27109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27111         this_ptr_conv.is_owned = false;
27112         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
27113 }
27114
27115 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27116         LDKChannelConfig this_ptr_conv;
27117         this_ptr_conv.inner = untag_ptr(this_ptr);
27118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27120         this_ptr_conv.is_owned = false;
27121         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
27122         return ret_conv;
27123 }
27124
27125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27126         LDKChannelConfig this_ptr_conv;
27127         this_ptr_conv.inner = untag_ptr(this_ptr);
27128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27130         this_ptr_conv.is_owned = false;
27131         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
27132 }
27133
27134 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27135         LDKChannelConfig this_ptr_conv;
27136         this_ptr_conv.inner = untag_ptr(this_ptr);
27137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27139         this_ptr_conv.is_owned = false;
27140         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
27141         return ret_conv;
27142 }
27143
27144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27145         LDKChannelConfig this_ptr_conv;
27146         this_ptr_conv.inner = untag_ptr(this_ptr);
27147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27149         this_ptr_conv.is_owned = false;
27150         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
27151 }
27152
27153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27154         LDKChannelConfig this_ptr_conv;
27155         this_ptr_conv.inner = untag_ptr(this_ptr);
27156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27158         this_ptr_conv.is_owned = false;
27159         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
27160         return ret_conv;
27161 }
27162
27163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27164         LDKChannelConfig this_ptr_conv;
27165         this_ptr_conv.inner = untag_ptr(this_ptr);
27166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27168         this_ptr_conv.is_owned = false;
27169         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
27170 }
27171
27172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27173         LDKChannelConfig this_ptr_conv;
27174         this_ptr_conv.inner = untag_ptr(this_ptr);
27175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27177         this_ptr_conv.is_owned = false;
27178         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
27179         return ret_conv;
27180 }
27181
27182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27183         LDKChannelConfig this_ptr_conv;
27184         this_ptr_conv.inner = untag_ptr(this_ptr);
27185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27187         this_ptr_conv.is_owned = false;
27188         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
27189 }
27190
27191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
27192         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
27193         int64_t ret_ref = 0;
27194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27196         return ret_ref;
27197 }
27198
27199 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
27200         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
27201         int64_t ret_ref = 0;
27202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27204         return ret_ref;
27205 }
27206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27207         LDKChannelConfig arg_conv;
27208         arg_conv.inner = untag_ptr(arg);
27209         arg_conv.is_owned = ptr_is_owned(arg);
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27211         arg_conv.is_owned = false;
27212         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
27213         return ret_conv;
27214 }
27215
27216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27217         LDKChannelConfig orig_conv;
27218         orig_conv.inner = untag_ptr(orig);
27219         orig_conv.is_owned = ptr_is_owned(orig);
27220         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27221         orig_conv.is_owned = false;
27222         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
27223         int64_t ret_ref = 0;
27224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27226         return ret_ref;
27227 }
27228
27229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27230         LDKChannelConfig a_conv;
27231         a_conv.inner = untag_ptr(a);
27232         a_conv.is_owned = ptr_is_owned(a);
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27234         a_conv.is_owned = false;
27235         LDKChannelConfig b_conv;
27236         b_conv.inner = untag_ptr(b);
27237         b_conv.is_owned = ptr_is_owned(b);
27238         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27239         b_conv.is_owned = false;
27240         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
27241         return ret_conv;
27242 }
27243
27244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
27245         LDKChannelConfig ret_var = ChannelConfig_default();
27246         int64_t ret_ref = 0;
27247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27249         return ret_ref;
27250 }
27251
27252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
27253         LDKChannelConfig obj_conv;
27254         obj_conv.inner = untag_ptr(obj);
27255         obj_conv.is_owned = ptr_is_owned(obj);
27256         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27257         obj_conv.is_owned = false;
27258         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
27259         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27260         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27261         CVec_u8Z_free(ret_var);
27262         return ret_arr;
27263 }
27264
27265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27266         LDKu8slice ser_ref;
27267         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27268         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27269         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
27270         *ret_conv = ChannelConfig_read(ser_ref);
27271         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27272         return tag_ptr(ret_conv, true);
27273 }
27274
27275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27276         LDKUserConfig this_obj_conv;
27277         this_obj_conv.inner = untag_ptr(this_obj);
27278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27280         UserConfig_free(this_obj_conv);
27281 }
27282
27283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
27284         LDKUserConfig this_ptr_conv;
27285         this_ptr_conv.inner = untag_ptr(this_ptr);
27286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27288         this_ptr_conv.is_owned = false;
27289         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
27290         int64_t ret_ref = 0;
27291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27293         return ret_ref;
27294 }
27295
27296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27297         LDKUserConfig this_ptr_conv;
27298         this_ptr_conv.inner = untag_ptr(this_ptr);
27299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27301         this_ptr_conv.is_owned = false;
27302         LDKChannelHandshakeConfig val_conv;
27303         val_conv.inner = untag_ptr(val);
27304         val_conv.is_owned = ptr_is_owned(val);
27305         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27306         val_conv = ChannelHandshakeConfig_clone(&val_conv);
27307         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
27308 }
27309
27310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
27311         LDKUserConfig this_ptr_conv;
27312         this_ptr_conv.inner = untag_ptr(this_ptr);
27313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27315         this_ptr_conv.is_owned = false;
27316         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
27317         int64_t ret_ref = 0;
27318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27320         return ret_ref;
27321 }
27322
27323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27324         LDKUserConfig this_ptr_conv;
27325         this_ptr_conv.inner = untag_ptr(this_ptr);
27326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27328         this_ptr_conv.is_owned = false;
27329         LDKChannelHandshakeLimits val_conv;
27330         val_conv.inner = untag_ptr(val);
27331         val_conv.is_owned = ptr_is_owned(val);
27332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27333         val_conv = ChannelHandshakeLimits_clone(&val_conv);
27334         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
27335 }
27336
27337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
27338         LDKUserConfig this_ptr_conv;
27339         this_ptr_conv.inner = untag_ptr(this_ptr);
27340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27342         this_ptr_conv.is_owned = false;
27343         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
27344         int64_t ret_ref = 0;
27345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27347         return ret_ref;
27348 }
27349
27350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27351         LDKUserConfig this_ptr_conv;
27352         this_ptr_conv.inner = untag_ptr(this_ptr);
27353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27355         this_ptr_conv.is_owned = false;
27356         LDKChannelConfig val_conv;
27357         val_conv.inner = untag_ptr(val);
27358         val_conv.is_owned = ptr_is_owned(val);
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27360         val_conv = ChannelConfig_clone(&val_conv);
27361         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
27362 }
27363
27364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27365         LDKUserConfig this_ptr_conv;
27366         this_ptr_conv.inner = untag_ptr(this_ptr);
27367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27369         this_ptr_conv.is_owned = false;
27370         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
27371         return ret_conv;
27372 }
27373
27374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27375         LDKUserConfig this_ptr_conv;
27376         this_ptr_conv.inner = untag_ptr(this_ptr);
27377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27379         this_ptr_conv.is_owned = false;
27380         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
27381 }
27382
27383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27384         LDKUserConfig this_ptr_conv;
27385         this_ptr_conv.inner = untag_ptr(this_ptr);
27386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27388         this_ptr_conv.is_owned = false;
27389         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
27390         return ret_conv;
27391 }
27392
27393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27394         LDKUserConfig this_ptr_conv;
27395         this_ptr_conv.inner = untag_ptr(this_ptr);
27396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27398         this_ptr_conv.is_owned = false;
27399         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
27400 }
27401
27402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27403         LDKUserConfig this_ptr_conv;
27404         this_ptr_conv.inner = untag_ptr(this_ptr);
27405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27407         this_ptr_conv.is_owned = false;
27408         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
27409         return ret_conv;
27410 }
27411
27412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27413         LDKUserConfig this_ptr_conv;
27414         this_ptr_conv.inner = untag_ptr(this_ptr);
27415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27417         this_ptr_conv.is_owned = false;
27418         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
27419 }
27420
27421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
27422         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
27423         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
27424         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
27426         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
27427         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
27428         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
27429         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
27430         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
27431         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
27432         LDKChannelConfig channel_config_arg_conv;
27433         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
27434         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
27435         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
27436         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
27437         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
27438         int64_t ret_ref = 0;
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27441         return ret_ref;
27442 }
27443
27444 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
27445         LDKUserConfig ret_var = UserConfig_clone(arg);
27446         int64_t ret_ref = 0;
27447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27449         return ret_ref;
27450 }
27451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27452         LDKUserConfig arg_conv;
27453         arg_conv.inner = untag_ptr(arg);
27454         arg_conv.is_owned = ptr_is_owned(arg);
27455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27456         arg_conv.is_owned = false;
27457         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
27458         return ret_conv;
27459 }
27460
27461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27462         LDKUserConfig orig_conv;
27463         orig_conv.inner = untag_ptr(orig);
27464         orig_conv.is_owned = ptr_is_owned(orig);
27465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27466         orig_conv.is_owned = false;
27467         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
27468         int64_t ret_ref = 0;
27469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27471         return ret_ref;
27472 }
27473
27474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
27475         LDKUserConfig ret_var = UserConfig_default();
27476         int64_t ret_ref = 0;
27477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27479         return ret_ref;
27480 }
27481
27482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27483         LDKBestBlock this_obj_conv;
27484         this_obj_conv.inner = untag_ptr(this_obj);
27485         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27487         BestBlock_free(this_obj_conv);
27488 }
27489
27490 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
27491         LDKBestBlock ret_var = BestBlock_clone(arg);
27492         int64_t ret_ref = 0;
27493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27495         return ret_ref;
27496 }
27497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27498         LDKBestBlock arg_conv;
27499         arg_conv.inner = untag_ptr(arg);
27500         arg_conv.is_owned = ptr_is_owned(arg);
27501         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27502         arg_conv.is_owned = false;
27503         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
27504         return ret_conv;
27505 }
27506
27507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27508         LDKBestBlock orig_conv;
27509         orig_conv.inner = untag_ptr(orig);
27510         orig_conv.is_owned = ptr_is_owned(orig);
27511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27512         orig_conv.is_owned = false;
27513         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
27514         int64_t ret_ref = 0;
27515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27517         return ret_ref;
27518 }
27519
27520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27521         LDKBestBlock a_conv;
27522         a_conv.inner = untag_ptr(a);
27523         a_conv.is_owned = ptr_is_owned(a);
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27525         a_conv.is_owned = false;
27526         LDKBestBlock b_conv;
27527         b_conv.inner = untag_ptr(b);
27528         b_conv.is_owned = ptr_is_owned(b);
27529         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27530         b_conv.is_owned = false;
27531         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
27532         return ret_conv;
27533 }
27534
27535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
27536         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
27537         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
27538         int64_t ret_ref = 0;
27539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27541         return ret_ref;
27542 }
27543
27544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
27545         LDKThirtyTwoBytes block_hash_ref;
27546         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
27547         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
27548         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
27549         int64_t ret_ref = 0;
27550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27552         return ret_ref;
27553 }
27554
27555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27556         LDKBestBlock this_arg_conv;
27557         this_arg_conv.inner = untag_ptr(this_arg);
27558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27560         this_arg_conv.is_owned = false;
27561         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27562         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
27563         return ret_arr;
27564 }
27565
27566 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
27567         LDKBestBlock this_arg_conv;
27568         this_arg_conv.inner = untag_ptr(this_arg);
27569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27571         this_arg_conv.is_owned = false;
27572         int32_t ret_conv = BestBlock_height(&this_arg_conv);
27573         return ret_conv;
27574 }
27575
27576 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27577         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
27578         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
27579         return ret_conv;
27580 }
27581
27582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
27583         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
27584         return ret_conv;
27585 }
27586
27587 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
27588         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
27589         return ret_conv;
27590 }
27591
27592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27593         if (!ptr_is_owned(this_ptr)) return;
27594         void* this_ptr_ptr = untag_ptr(this_ptr);
27595         CHECK_ACCESS(this_ptr_ptr);
27596         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
27597         FREE(untag_ptr(this_ptr));
27598         Access_free(this_ptr_conv);
27599 }
27600
27601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27602         if (!ptr_is_owned(this_ptr)) return;
27603         void* this_ptr_ptr = untag_ptr(this_ptr);
27604         CHECK_ACCESS(this_ptr_ptr);
27605         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
27606         FREE(untag_ptr(this_ptr));
27607         Listen_free(this_ptr_conv);
27608 }
27609
27610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27611         if (!ptr_is_owned(this_ptr)) return;
27612         void* this_ptr_ptr = untag_ptr(this_ptr);
27613         CHECK_ACCESS(this_ptr_ptr);
27614         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
27615         FREE(untag_ptr(this_ptr));
27616         Confirm_free(this_ptr_conv);
27617 }
27618
27619 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27620         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
27621         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
27622         return ret_conv;
27623 }
27624
27625 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
27626         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
27627         return ret_conv;
27628 }
27629
27630 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
27631         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
27632         return ret_conv;
27633 }
27634
27635 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
27636         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
27637         return ret_conv;
27638 }
27639
27640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27641         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
27642         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
27643         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
27644         return ret_conv;
27645 }
27646
27647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27648         if (!ptr_is_owned(this_ptr)) return;
27649         void* this_ptr_ptr = untag_ptr(this_ptr);
27650         CHECK_ACCESS(this_ptr_ptr);
27651         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
27652         FREE(untag_ptr(this_ptr));
27653         Watch_free(this_ptr_conv);
27654 }
27655
27656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27657         if (!ptr_is_owned(this_ptr)) return;
27658         void* this_ptr_ptr = untag_ptr(this_ptr);
27659         CHECK_ACCESS(this_ptr_ptr);
27660         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
27661         FREE(untag_ptr(this_ptr));
27662         Filter_free(this_ptr_conv);
27663 }
27664
27665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27666         LDKWatchedOutput this_obj_conv;
27667         this_obj_conv.inner = untag_ptr(this_obj);
27668         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27670         WatchedOutput_free(this_obj_conv);
27671 }
27672
27673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27674         LDKWatchedOutput this_ptr_conv;
27675         this_ptr_conv.inner = untag_ptr(this_ptr);
27676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27678         this_ptr_conv.is_owned = false;
27679         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
27681         return ret_arr;
27682 }
27683
27684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27685         LDKWatchedOutput this_ptr_conv;
27686         this_ptr_conv.inner = untag_ptr(this_ptr);
27687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27689         this_ptr_conv.is_owned = false;
27690         LDKThirtyTwoBytes val_ref;
27691         CHECK((*env)->GetArrayLength(env, val) == 32);
27692         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27693         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
27694 }
27695
27696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27697         LDKWatchedOutput this_ptr_conv;
27698         this_ptr_conv.inner = untag_ptr(this_ptr);
27699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27701         this_ptr_conv.is_owned = false;
27702         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
27703         int64_t ret_ref = 0;
27704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27706         return ret_ref;
27707 }
27708
27709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27710         LDKWatchedOutput this_ptr_conv;
27711         this_ptr_conv.inner = untag_ptr(this_ptr);
27712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27714         this_ptr_conv.is_owned = false;
27715         LDKOutPoint val_conv;
27716         val_conv.inner = untag_ptr(val);
27717         val_conv.is_owned = ptr_is_owned(val);
27718         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27719         val_conv = OutPoint_clone(&val_conv);
27720         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
27721 }
27722
27723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27724         LDKWatchedOutput this_ptr_conv;
27725         this_ptr_conv.inner = untag_ptr(this_ptr);
27726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27728         this_ptr_conv.is_owned = false;
27729         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
27730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27732         return ret_arr;
27733 }
27734
27735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27736         LDKWatchedOutput this_ptr_conv;
27737         this_ptr_conv.inner = untag_ptr(this_ptr);
27738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27740         this_ptr_conv.is_owned = false;
27741         LDKCVec_u8Z val_ref;
27742         val_ref.datalen = (*env)->GetArrayLength(env, val);
27743         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27744         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27745         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
27746 }
27747
27748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1new(JNIEnv *env, jclass clz, int8_tArray block_hash_arg, int64_t outpoint_arg, int8_tArray script_pubkey_arg) {
27749         LDKThirtyTwoBytes block_hash_arg_ref;
27750         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
27751         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
27752         LDKOutPoint outpoint_arg_conv;
27753         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
27754         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
27755         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27756         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27757         LDKCVec_u8Z script_pubkey_arg_ref;
27758         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
27759         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27760         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
27761         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
27762         int64_t ret_ref = 0;
27763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27765         return ret_ref;
27766 }
27767
27768 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
27769         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
27770         int64_t ret_ref = 0;
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27773         return ret_ref;
27774 }
27775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27776         LDKWatchedOutput arg_conv;
27777         arg_conv.inner = untag_ptr(arg);
27778         arg_conv.is_owned = ptr_is_owned(arg);
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27780         arg_conv.is_owned = false;
27781         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
27782         return ret_conv;
27783 }
27784
27785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27786         LDKWatchedOutput orig_conv;
27787         orig_conv.inner = untag_ptr(orig);
27788         orig_conv.is_owned = ptr_is_owned(orig);
27789         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27790         orig_conv.is_owned = false;
27791         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
27792         int64_t ret_ref = 0;
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27795         return ret_ref;
27796 }
27797
27798 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27799         LDKWatchedOutput a_conv;
27800         a_conv.inner = untag_ptr(a);
27801         a_conv.is_owned = ptr_is_owned(a);
27802         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27803         a_conv.is_owned = false;
27804         LDKWatchedOutput b_conv;
27805         b_conv.inner = untag_ptr(b);
27806         b_conv.is_owned = ptr_is_owned(b);
27807         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27808         b_conv.is_owned = false;
27809         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
27810         return ret_conv;
27811 }
27812
27813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
27814         LDKWatchedOutput o_conv;
27815         o_conv.inner = untag_ptr(o);
27816         o_conv.is_owned = ptr_is_owned(o);
27817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27818         o_conv.is_owned = false;
27819         int64_t ret_conv = WatchedOutput_hash(&o_conv);
27820         return ret_conv;
27821 }
27822
27823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27824         if (!ptr_is_owned(this_ptr)) return;
27825         void* this_ptr_ptr = untag_ptr(this_ptr);
27826         CHECK_ACCESS(this_ptr_ptr);
27827         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
27828         FREE(untag_ptr(this_ptr));
27829         BroadcasterInterface_free(this_ptr_conv);
27830 }
27831
27832 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27833         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
27834         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
27835         return ret_conv;
27836 }
27837
27838 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
27839         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
27840         return ret_conv;
27841 }
27842
27843 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
27844         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
27845         return ret_conv;
27846 }
27847
27848 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
27849         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
27850         return ret_conv;
27851 }
27852
27853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27854         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
27855         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
27856         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
27857         return ret_conv;
27858 }
27859
27860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27861         if (!ptr_is_owned(this_ptr)) return;
27862         void* this_ptr_ptr = untag_ptr(this_ptr);
27863         CHECK_ACCESS(this_ptr_ptr);
27864         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
27865         FREE(untag_ptr(this_ptr));
27866         FeeEstimator_free(this_ptr_conv);
27867 }
27868
27869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27870         LDKMonitorUpdateId this_obj_conv;
27871         this_obj_conv.inner = untag_ptr(this_obj);
27872         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27874         MonitorUpdateId_free(this_obj_conv);
27875 }
27876
27877 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
27878         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
27879         int64_t ret_ref = 0;
27880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27882         return ret_ref;
27883 }
27884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27885         LDKMonitorUpdateId arg_conv;
27886         arg_conv.inner = untag_ptr(arg);
27887         arg_conv.is_owned = ptr_is_owned(arg);
27888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27889         arg_conv.is_owned = false;
27890         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
27891         return ret_conv;
27892 }
27893
27894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27895         LDKMonitorUpdateId orig_conv;
27896         orig_conv.inner = untag_ptr(orig);
27897         orig_conv.is_owned = ptr_is_owned(orig);
27898         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27899         orig_conv.is_owned = false;
27900         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
27901         int64_t ret_ref = 0;
27902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27904         return ret_ref;
27905 }
27906
27907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
27908         LDKMonitorUpdateId o_conv;
27909         o_conv.inner = untag_ptr(o);
27910         o_conv.is_owned = ptr_is_owned(o);
27911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27912         o_conv.is_owned = false;
27913         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
27914         return ret_conv;
27915 }
27916
27917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27918         LDKMonitorUpdateId a_conv;
27919         a_conv.inner = untag_ptr(a);
27920         a_conv.is_owned = ptr_is_owned(a);
27921         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27922         a_conv.is_owned = false;
27923         LDKMonitorUpdateId b_conv;
27924         b_conv.inner = untag_ptr(b);
27925         b_conv.is_owned = ptr_is_owned(b);
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27927         b_conv.is_owned = false;
27928         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
27929         return ret_conv;
27930 }
27931
27932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27933         if (!ptr_is_owned(this_ptr)) return;
27934         void* this_ptr_ptr = untag_ptr(this_ptr);
27935         CHECK_ACCESS(this_ptr_ptr);
27936         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
27937         FREE(untag_ptr(this_ptr));
27938         Persist_free(this_ptr_conv);
27939 }
27940
27941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27942         LDKLockedChannelMonitor this_obj_conv;
27943         this_obj_conv.inner = untag_ptr(this_obj);
27944         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27946         LockedChannelMonitor_free(this_obj_conv);
27947 }
27948
27949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27950         LDKChainMonitor this_obj_conv;
27951         this_obj_conv.inner = untag_ptr(this_obj);
27952         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27954         ChainMonitor_free(this_obj_conv);
27955 }
27956
27957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
27958         void* chain_source_ptr = untag_ptr(chain_source);
27959         CHECK_ACCESS(chain_source_ptr);
27960         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27961         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27962         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27963                 // Manually implement clone for Java trait instances
27964                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27965                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27966                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27967                 }
27968         }
27969         void* broadcaster_ptr = untag_ptr(broadcaster);
27970         CHECK_ACCESS(broadcaster_ptr);
27971         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27972         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27973                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27974                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27975         }
27976         void* logger_ptr = untag_ptr(logger);
27977         CHECK_ACCESS(logger_ptr);
27978         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27979         if (logger_conv.free == LDKLogger_JCalls_free) {
27980                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27981                 LDKLogger_JCalls_cloned(&logger_conv);
27982         }
27983         void* feeest_ptr = untag_ptr(feeest);
27984         CHECK_ACCESS(feeest_ptr);
27985         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27986         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27987                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27988                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27989         }
27990         void* persister_ptr = untag_ptr(persister);
27991         CHECK_ACCESS(persister_ptr);
27992         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27993         if (persister_conv.free == LDKPersist_JCalls_free) {
27994                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27995                 LDKPersist_JCalls_cloned(&persister_conv);
27996         }
27997         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
27998         int64_t ret_ref = 0;
27999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28001         return ret_ref;
28002 }
28003
28004 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) {
28005         LDKChainMonitor this_arg_conv;
28006         this_arg_conv.inner = untag_ptr(this_arg);
28007         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28009         this_arg_conv.is_owned = false;
28010         LDKCVec_ChannelDetailsZ ignored_channels_constr;
28011         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
28012         if (ignored_channels_constr.datalen > 0)
28013                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28014         else
28015                 ignored_channels_constr.data = NULL;
28016         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
28017         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
28018                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
28019                 LDKChannelDetails ignored_channels_conv_16_conv;
28020                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
28021                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
28022                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
28023                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
28024                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
28025         }
28026         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
28027         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
28028         int64_tArray ret_arr = NULL;
28029         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28030         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28031         for (size_t j = 0; j < ret_var.datalen; j++) {
28032                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28033                 *ret_conv_9_copy = ret_var.data[j];
28034                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28035                 ret_arr_ptr[j] = ret_conv_9_ref;
28036         }
28037         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28038         FREE(ret_var.data);
28039         return ret_arr;
28040 }
28041
28042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
28043         LDKChainMonitor this_arg_conv;
28044         this_arg_conv.inner = untag_ptr(this_arg);
28045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28047         this_arg_conv.is_owned = false;
28048         LDKOutPoint funding_txo_conv;
28049         funding_txo_conv.inner = untag_ptr(funding_txo);
28050         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28051         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28052         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28053         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
28054         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
28055         return tag_ptr(ret_conv, true);
28056 }
28057
28058 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
28059         LDKChainMonitor this_arg_conv;
28060         this_arg_conv.inner = untag_ptr(this_arg);
28061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28063         this_arg_conv.is_owned = false;
28064         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
28065         int64_tArray ret_arr = NULL;
28066         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28067         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28068         for (size_t k = 0; k < ret_var.datalen; k++) {
28069                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
28070                 int64_t ret_conv_10_ref = 0;
28071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
28072                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
28073                 ret_arr_ptr[k] = ret_conv_10_ref;
28074         }
28075         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28076         FREE(ret_var.data);
28077         return ret_arr;
28078 }
28079
28080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
28081         LDKChainMonitor this_arg_conv;
28082         this_arg_conv.inner = untag_ptr(this_arg);
28083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28085         this_arg_conv.is_owned = false;
28086         LDKOutPoint funding_txo_conv;
28087         funding_txo_conv.inner = untag_ptr(funding_txo);
28088         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28089         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28090         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28091         LDKMonitorUpdateId completed_update_id_conv;
28092         completed_update_id_conv.inner = untag_ptr(completed_update_id);
28093         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
28094         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
28095         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
28096         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28097         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
28098         return tag_ptr(ret_conv, true);
28099 }
28100
28101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
28102         LDKChainMonitor this_arg_conv;
28103         this_arg_conv.inner = untag_ptr(this_arg);
28104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28106         this_arg_conv.is_owned = false;
28107         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
28108         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
28109         return tag_ptr(ret_ret, true);
28110 }
28111
28112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
28113         LDKChainMonitor this_arg_conv;
28114         this_arg_conv.inner = untag_ptr(this_arg);
28115         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28117         this_arg_conv.is_owned = false;
28118         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
28119         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
28120         return tag_ptr(ret_ret, true);
28121 }
28122
28123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
28124         LDKChainMonitor this_arg_conv;
28125         this_arg_conv.inner = untag_ptr(this_arg);
28126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28128         this_arg_conv.is_owned = false;
28129         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
28130         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
28131         return tag_ptr(ret_ret, true);
28132 }
28133
28134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28135         LDKChainMonitor this_arg_conv;
28136         this_arg_conv.inner = untag_ptr(this_arg);
28137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28139         this_arg_conv.is_owned = false;
28140         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
28141         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
28142         return tag_ptr(ret_ret, true);
28143 }
28144
28145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28146         LDKChannelMonitorUpdate this_obj_conv;
28147         this_obj_conv.inner = untag_ptr(this_obj);
28148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28150         ChannelMonitorUpdate_free(this_obj_conv);
28151 }
28152
28153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28154         LDKChannelMonitorUpdate this_ptr_conv;
28155         this_ptr_conv.inner = untag_ptr(this_ptr);
28156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28158         this_ptr_conv.is_owned = false;
28159         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
28160         return ret_conv;
28161 }
28162
28163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28164         LDKChannelMonitorUpdate this_ptr_conv;
28165         this_ptr_conv.inner = untag_ptr(this_ptr);
28166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28168         this_ptr_conv.is_owned = false;
28169         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
28170 }
28171
28172 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
28173         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
28174         int64_t ret_ref = 0;
28175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28177         return ret_ref;
28178 }
28179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28180         LDKChannelMonitorUpdate arg_conv;
28181         arg_conv.inner = untag_ptr(arg);
28182         arg_conv.is_owned = ptr_is_owned(arg);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28184         arg_conv.is_owned = false;
28185         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
28186         return ret_conv;
28187 }
28188
28189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28190         LDKChannelMonitorUpdate orig_conv;
28191         orig_conv.inner = untag_ptr(orig);
28192         orig_conv.is_owned = ptr_is_owned(orig);
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28194         orig_conv.is_owned = false;
28195         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
28196         int64_t ret_ref = 0;
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28199         return ret_ref;
28200 }
28201
28202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
28203         LDKChannelMonitorUpdate obj_conv;
28204         obj_conv.inner = untag_ptr(obj);
28205         obj_conv.is_owned = ptr_is_owned(obj);
28206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28207         obj_conv.is_owned = false;
28208         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
28209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28211         CVec_u8Z_free(ret_var);
28212         return ret_arr;
28213 }
28214
28215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28216         LDKu8slice ser_ref;
28217         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28218         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28219         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
28220         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
28221         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28222         return tag_ptr(ret_conv, true);
28223 }
28224
28225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28226         if (!ptr_is_owned(this_ptr)) return;
28227         void* this_ptr_ptr = untag_ptr(this_ptr);
28228         CHECK_ACCESS(this_ptr_ptr);
28229         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
28230         FREE(untag_ptr(this_ptr));
28231         MonitorEvent_free(this_ptr_conv);
28232 }
28233
28234 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
28235         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28236         *ret_copy = MonitorEvent_clone(arg);
28237         int64_t ret_ref = tag_ptr(ret_copy, true);
28238         return ret_ref;
28239 }
28240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28241         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
28242         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
28243         return ret_conv;
28244 }
28245
28246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28247         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
28248         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28249         *ret_copy = MonitorEvent_clone(orig_conv);
28250         int64_t ret_ref = tag_ptr(ret_copy, true);
28251         return ret_ref;
28252 }
28253
28254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
28255         LDKHTLCUpdate a_conv;
28256         a_conv.inner = untag_ptr(a);
28257         a_conv.is_owned = ptr_is_owned(a);
28258         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28259         a_conv = HTLCUpdate_clone(&a_conv);
28260         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28261         *ret_copy = MonitorEvent_htlcevent(a_conv);
28262         int64_t ret_ref = tag_ptr(ret_copy, true);
28263         return ret_ref;
28264 }
28265
28266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
28267         LDKOutPoint a_conv;
28268         a_conv.inner = untag_ptr(a);
28269         a_conv.is_owned = ptr_is_owned(a);
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28271         a_conv = OutPoint_clone(&a_conv);
28272         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28273         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
28274         int64_t ret_ref = tag_ptr(ret_copy, true);
28275         return ret_ref;
28276 }
28277
28278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
28279         LDKOutPoint funding_txo_conv;
28280         funding_txo_conv.inner = untag_ptr(funding_txo);
28281         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28282         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28283         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28284         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28285         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
28286         int64_t ret_ref = tag_ptr(ret_copy, true);
28287         return ret_ref;
28288 }
28289
28290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
28291         LDKOutPoint a_conv;
28292         a_conv.inner = untag_ptr(a);
28293         a_conv.is_owned = ptr_is_owned(a);
28294         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28295         a_conv = OutPoint_clone(&a_conv);
28296         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28297         *ret_copy = MonitorEvent_update_failed(a_conv);
28298         int64_t ret_ref = tag_ptr(ret_copy, true);
28299         return ret_ref;
28300 }
28301
28302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28303         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
28304         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
28305         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
28306         return ret_conv;
28307 }
28308
28309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
28310         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
28311         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
28312         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28313         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28314         CVec_u8Z_free(ret_var);
28315         return ret_arr;
28316 }
28317
28318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28319         LDKu8slice ser_ref;
28320         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28321         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28322         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
28323         *ret_conv = MonitorEvent_read(ser_ref);
28324         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28325         return tag_ptr(ret_conv, true);
28326 }
28327
28328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28329         LDKHTLCUpdate this_obj_conv;
28330         this_obj_conv.inner = untag_ptr(this_obj);
28331         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28333         HTLCUpdate_free(this_obj_conv);
28334 }
28335
28336 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
28337         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
28338         int64_t ret_ref = 0;
28339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28340         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28341         return ret_ref;
28342 }
28343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28344         LDKHTLCUpdate arg_conv;
28345         arg_conv.inner = untag_ptr(arg);
28346         arg_conv.is_owned = ptr_is_owned(arg);
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28348         arg_conv.is_owned = false;
28349         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
28350         return ret_conv;
28351 }
28352
28353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28354         LDKHTLCUpdate orig_conv;
28355         orig_conv.inner = untag_ptr(orig);
28356         orig_conv.is_owned = ptr_is_owned(orig);
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28358         orig_conv.is_owned = false;
28359         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
28360         int64_t ret_ref = 0;
28361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28363         return ret_ref;
28364 }
28365
28366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28367         LDKHTLCUpdate a_conv;
28368         a_conv.inner = untag_ptr(a);
28369         a_conv.is_owned = ptr_is_owned(a);
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28371         a_conv.is_owned = false;
28372         LDKHTLCUpdate b_conv;
28373         b_conv.inner = untag_ptr(b);
28374         b_conv.is_owned = ptr_is_owned(b);
28375         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28376         b_conv.is_owned = false;
28377         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
28378         return ret_conv;
28379 }
28380
28381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
28382         LDKHTLCUpdate obj_conv;
28383         obj_conv.inner = untag_ptr(obj);
28384         obj_conv.is_owned = ptr_is_owned(obj);
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28386         obj_conv.is_owned = false;
28387         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
28388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28390         CVec_u8Z_free(ret_var);
28391         return ret_arr;
28392 }
28393
28394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28395         LDKu8slice ser_ref;
28396         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28397         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28398         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
28399         *ret_conv = HTLCUpdate_read(ser_ref);
28400         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28401         return tag_ptr(ret_conv, true);
28402 }
28403
28404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28405         if (!ptr_is_owned(this_ptr)) return;
28406         void* this_ptr_ptr = untag_ptr(this_ptr);
28407         CHECK_ACCESS(this_ptr_ptr);
28408         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
28409         FREE(untag_ptr(this_ptr));
28410         Balance_free(this_ptr_conv);
28411 }
28412
28413 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
28414         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28415         *ret_copy = Balance_clone(arg);
28416         int64_t ret_ref = tag_ptr(ret_copy, true);
28417         return ret_ref;
28418 }
28419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28420         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
28421         int64_t ret_conv = Balance_clone_ptr(arg_conv);
28422         return ret_conv;
28423 }
28424
28425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28426         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
28427         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28428         *ret_copy = Balance_clone(orig_conv);
28429         int64_t ret_ref = tag_ptr(ret_copy, true);
28430         return ret_ref;
28431 }
28432
28433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
28434         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28435         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
28436         int64_t ret_ref = tag_ptr(ret_copy, true);
28437         return ret_ref;
28438 }
28439
28440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) {
28441         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28442         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
28443         int64_t ret_ref = tag_ptr(ret_copy, true);
28444         return ret_ref;
28445 }
28446
28447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) {
28448         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28449         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
28450         int64_t ret_ref = tag_ptr(ret_copy, true);
28451         return ret_ref;
28452 }
28453
28454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1timeout_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
28455         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28456         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
28457         int64_t ret_ref = tag_ptr(ret_copy, true);
28458         return ret_ref;
28459 }
28460
28461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1preimage_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t expiry_height) {
28462         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28463         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
28464         int64_t ret_ref = tag_ptr(ret_copy, true);
28465         return ret_ref;
28466 }
28467
28468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
28469         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28470         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
28471         int64_t ret_ref = tag_ptr(ret_copy, true);
28472         return ret_ref;
28473 }
28474
28475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28476         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
28477         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
28478         jboolean ret_conv = Balance_eq(a_conv, b_conv);
28479         return ret_conv;
28480 }
28481
28482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28483         LDKChannelMonitor this_obj_conv;
28484         this_obj_conv.inner = untag_ptr(this_obj);
28485         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28487         ChannelMonitor_free(this_obj_conv);
28488 }
28489
28490 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
28491         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
28492         int64_t ret_ref = 0;
28493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28495         return ret_ref;
28496 }
28497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28498         LDKChannelMonitor arg_conv;
28499         arg_conv.inner = untag_ptr(arg);
28500         arg_conv.is_owned = ptr_is_owned(arg);
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28502         arg_conv.is_owned = false;
28503         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
28504         return ret_conv;
28505 }
28506
28507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28508         LDKChannelMonitor orig_conv;
28509         orig_conv.inner = untag_ptr(orig);
28510         orig_conv.is_owned = ptr_is_owned(orig);
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28512         orig_conv.is_owned = false;
28513         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
28514         int64_t ret_ref = 0;
28515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28517         return ret_ref;
28518 }
28519
28520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28521         LDKChannelMonitor obj_conv;
28522         obj_conv.inner = untag_ptr(obj);
28523         obj_conv.is_owned = ptr_is_owned(obj);
28524         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28525         obj_conv.is_owned = false;
28526         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
28527         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28528         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28529         CVec_u8Z_free(ret_var);
28530         return ret_arr;
28531 }
28532
28533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t updates, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28534         LDKChannelMonitor this_arg_conv;
28535         this_arg_conv.inner = untag_ptr(this_arg);
28536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28538         this_arg_conv.is_owned = false;
28539         LDKChannelMonitorUpdate updates_conv;
28540         updates_conv.inner = untag_ptr(updates);
28541         updates_conv.is_owned = ptr_is_owned(updates);
28542         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
28543         updates_conv.is_owned = false;
28544         void* broadcaster_ptr = untag_ptr(broadcaster);
28545         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
28546         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
28547         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28548         CHECK_ACCESS(fee_estimator_ptr);
28549         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28550         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28551                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28552                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28553         }
28554         void* logger_ptr = untag_ptr(logger);
28555         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28556         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28557         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
28558         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
28559         return tag_ptr(ret_conv, true);
28560 }
28561
28562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28563         LDKChannelMonitor this_arg_conv;
28564         this_arg_conv.inner = untag_ptr(this_arg);
28565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28567         this_arg_conv.is_owned = false;
28568         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
28569         return ret_conv;
28570 }
28571
28572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
28573         LDKChannelMonitor this_arg_conv;
28574         this_arg_conv.inner = untag_ptr(this_arg);
28575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28577         this_arg_conv.is_owned = false;
28578         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
28579         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
28580         return tag_ptr(ret_conv, true);
28581 }
28582
28583 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
28584         LDKChannelMonitor this_arg_conv;
28585         this_arg_conv.inner = untag_ptr(this_arg);
28586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28588         this_arg_conv.is_owned = false;
28589         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
28590         int64_tArray ret_arr = NULL;
28591         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28592         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28593         for (size_t o = 0; o < ret_var.datalen; o++) {
28594                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
28595                 *ret_conv_40_conv = ret_var.data[o];
28596                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
28597         }
28598         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28599         FREE(ret_var.data);
28600         return ret_arr;
28601 }
28602
28603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
28604         LDKChannelMonitor this_arg_conv;
28605         this_arg_conv.inner = untag_ptr(this_arg);
28606         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28608         this_arg_conv.is_owned = false;
28609         void* filter_ptr = untag_ptr(filter);
28610         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
28611         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
28612         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
28613 }
28614
28615 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28616         LDKChannelMonitor this_arg_conv;
28617         this_arg_conv.inner = untag_ptr(this_arg);
28618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28620         this_arg_conv.is_owned = false;
28621         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
28622         int64_tArray ret_arr = NULL;
28623         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28624         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28625         for (size_t o = 0; o < ret_var.datalen; o++) {
28626                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28627                 *ret_conv_14_copy = ret_var.data[o];
28628                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
28629                 ret_arr_ptr[o] = ret_conv_14_ref;
28630         }
28631         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28632         FREE(ret_var.data);
28633         return ret_arr;
28634 }
28635
28636 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28637         LDKChannelMonitor this_arg_conv;
28638         this_arg_conv.inner = untag_ptr(this_arg);
28639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28641         this_arg_conv.is_owned = false;
28642         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
28643         int64_tArray ret_arr = NULL;
28644         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28645         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28646         for (size_t h = 0; h < ret_var.datalen; h++) {
28647                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
28648                 *ret_conv_7_copy = ret_var.data[h];
28649                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
28650                 ret_arr_ptr[h] = ret_conv_7_ref;
28651         }
28652         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28653         FREE(ret_var.data);
28654         return ret_arr;
28655 }
28656
28657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28658         LDKChannelMonitor this_arg_conv;
28659         this_arg_conv.inner = untag_ptr(this_arg);
28660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28662         this_arg_conv.is_owned = false;
28663         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
28665         return ret_arr;
28666 }
28667
28668 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t logger) {
28669         LDKChannelMonitor this_arg_conv;
28670         this_arg_conv.inner = untag_ptr(this_arg);
28671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28673         this_arg_conv.is_owned = false;
28674         void* logger_ptr = untag_ptr(logger);
28675         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28676         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28677         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
28678         jobjectArray ret_arr = NULL;
28679         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28680         ;
28681         for (size_t i = 0; i < ret_var.datalen; i++) {
28682                 LDKTransaction ret_conv_8_var = ret_var.data[i];
28683                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
28684                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
28685                 Transaction_free(ret_conv_8_var);
28686                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28687         }
28688         
28689         FREE(ret_var.data);
28690         return ret_arr;
28691 }
28692
28693 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28694         LDKChannelMonitor this_arg_conv;
28695         this_arg_conv.inner = untag_ptr(this_arg);
28696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28698         this_arg_conv.is_owned = false;
28699         unsigned char header_arr[80];
28700         CHECK((*env)->GetArrayLength(env, header) == 80);
28701         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28702         unsigned char (*header_ref)[80] = &header_arr;
28703         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28704         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28705         if (txdata_constr.datalen > 0)
28706                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28707         else
28708                 txdata_constr.data = NULL;
28709         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28710         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28711                 int64_t txdata_conv_28 = txdata_vals[c];
28712                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28713                 CHECK_ACCESS(txdata_conv_28_ptr);
28714                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28715                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28716                 txdata_constr.data[c] = txdata_conv_28_conv;
28717         }
28718         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28719         void* broadcaster_ptr = untag_ptr(broadcaster);
28720         CHECK_ACCESS(broadcaster_ptr);
28721         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28722         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28723                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28724                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28725         }
28726         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28727         CHECK_ACCESS(fee_estimator_ptr);
28728         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28729         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28730                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28731                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28732         }
28733         void* logger_ptr = untag_ptr(logger);
28734         CHECK_ACCESS(logger_ptr);
28735         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28736         if (logger_conv.free == LDKLogger_JCalls_free) {
28737                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28738                 LDKLogger_JCalls_cloned(&logger_conv);
28739         }
28740         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28741         int64_tArray ret_arr = NULL;
28742         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28743         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28744         for (size_t n = 0; n < ret_var.datalen; n++) {
28745                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28746                 *ret_conv_39_conv = ret_var.data[n];
28747                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28748         }
28749         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28750         FREE(ret_var.data);
28751         return ret_arr;
28752 }
28753
28754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28755         LDKChannelMonitor this_arg_conv;
28756         this_arg_conv.inner = untag_ptr(this_arg);
28757         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28759         this_arg_conv.is_owned = false;
28760         unsigned char header_arr[80];
28761         CHECK((*env)->GetArrayLength(env, header) == 80);
28762         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28763         unsigned char (*header_ref)[80] = &header_arr;
28764         void* broadcaster_ptr = untag_ptr(broadcaster);
28765         CHECK_ACCESS(broadcaster_ptr);
28766         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28767         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28768                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28769                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28770         }
28771         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28772         CHECK_ACCESS(fee_estimator_ptr);
28773         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28774         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28775                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28776                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28777         }
28778         void* logger_ptr = untag_ptr(logger);
28779         CHECK_ACCESS(logger_ptr);
28780         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28781         if (logger_conv.free == LDKLogger_JCalls_free) {
28782                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28783                 LDKLogger_JCalls_cloned(&logger_conv);
28784         }
28785         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28786 }
28787
28788 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28789         LDKChannelMonitor this_arg_conv;
28790         this_arg_conv.inner = untag_ptr(this_arg);
28791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28793         this_arg_conv.is_owned = false;
28794         unsigned char header_arr[80];
28795         CHECK((*env)->GetArrayLength(env, header) == 80);
28796         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28797         unsigned char (*header_ref)[80] = &header_arr;
28798         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28799         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28800         if (txdata_constr.datalen > 0)
28801                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28802         else
28803                 txdata_constr.data = NULL;
28804         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28805         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28806                 int64_t txdata_conv_28 = txdata_vals[c];
28807                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28808                 CHECK_ACCESS(txdata_conv_28_ptr);
28809                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28810                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28811                 txdata_constr.data[c] = txdata_conv_28_conv;
28812         }
28813         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28814         void* broadcaster_ptr = untag_ptr(broadcaster);
28815         CHECK_ACCESS(broadcaster_ptr);
28816         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28817         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28818                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28819                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28820         }
28821         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28822         CHECK_ACCESS(fee_estimator_ptr);
28823         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28824         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28826                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28827         }
28828         void* logger_ptr = untag_ptr(logger);
28829         CHECK_ACCESS(logger_ptr);
28830         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28831         if (logger_conv.free == LDKLogger_JCalls_free) {
28832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28833                 LDKLogger_JCalls_cloned(&logger_conv);
28834         }
28835         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28836         int64_tArray ret_arr = NULL;
28837         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28838         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28839         for (size_t n = 0; n < ret_var.datalen; n++) {
28840                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28841                 *ret_conv_39_conv = ret_var.data[n];
28842                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28843         }
28844         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28845         FREE(ret_var.data);
28846         return ret_arr;
28847 }
28848
28849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28850         LDKChannelMonitor this_arg_conv;
28851         this_arg_conv.inner = untag_ptr(this_arg);
28852         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28854         this_arg_conv.is_owned = false;
28855         unsigned char txid_arr[32];
28856         CHECK((*env)->GetArrayLength(env, txid) == 32);
28857         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
28858         unsigned char (*txid_ref)[32] = &txid_arr;
28859         void* broadcaster_ptr = untag_ptr(broadcaster);
28860         CHECK_ACCESS(broadcaster_ptr);
28861         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28862         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28863                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28864                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28865         }
28866         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28867         CHECK_ACCESS(fee_estimator_ptr);
28868         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28869         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28870                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28871                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28872         }
28873         void* logger_ptr = untag_ptr(logger);
28874         CHECK_ACCESS(logger_ptr);
28875         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28876         if (logger_conv.free == LDKLogger_JCalls_free) {
28877                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28878                 LDKLogger_JCalls_cloned(&logger_conv);
28879         }
28880         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
28881 }
28882
28883 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
28884         LDKChannelMonitor this_arg_conv;
28885         this_arg_conv.inner = untag_ptr(this_arg);
28886         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28888         this_arg_conv.is_owned = false;
28889         unsigned char header_arr[80];
28890         CHECK((*env)->GetArrayLength(env, header) == 80);
28891         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28892         unsigned char (*header_ref)[80] = &header_arr;
28893         void* broadcaster_ptr = untag_ptr(broadcaster);
28894         CHECK_ACCESS(broadcaster_ptr);
28895         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28896         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28897                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28898                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28899         }
28900         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28901         CHECK_ACCESS(fee_estimator_ptr);
28902         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28903         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28904                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28905                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28906         }
28907         void* logger_ptr = untag_ptr(logger);
28908         CHECK_ACCESS(logger_ptr);
28909         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28910         if (logger_conv.free == LDKLogger_JCalls_free) {
28911                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28912                 LDKLogger_JCalls_cloned(&logger_conv);
28913         }
28914         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28915         int64_tArray ret_arr = NULL;
28916         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28917         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28918         for (size_t n = 0; n < ret_var.datalen; n++) {
28919                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28920                 *ret_conv_39_conv = ret_var.data[n];
28921                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28922         }
28923         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28924         FREE(ret_var.data);
28925         return ret_arr;
28926 }
28927
28928 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
28929         LDKChannelMonitor this_arg_conv;
28930         this_arg_conv.inner = untag_ptr(this_arg);
28931         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28933         this_arg_conv.is_owned = false;
28934         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
28935         jobjectArray ret_arr = NULL;
28936         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28937         ;
28938         for (size_t i = 0; i < ret_var.datalen; i++) {
28939                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
28940                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
28941                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28942         }
28943         
28944         FREE(ret_var.data);
28945         return ret_arr;
28946 }
28947
28948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
28949         LDKChannelMonitor this_arg_conv;
28950         this_arg_conv.inner = untag_ptr(this_arg);
28951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28953         this_arg_conv.is_owned = false;
28954         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
28955         int64_t ret_ref = 0;
28956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28958         return ret_ref;
28959 }
28960
28961 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
28962         LDKChannelMonitor this_arg_conv;
28963         this_arg_conv.inner = untag_ptr(this_arg);
28964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28966         this_arg_conv.is_owned = false;
28967         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
28968         int64_tArray ret_arr = NULL;
28969         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28970         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28971         for (size_t j = 0; j < ret_var.datalen; j++) {
28972                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28973                 *ret_conv_9_copy = ret_var.data[j];
28974                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28975                 ret_arr_ptr[j] = ret_conv_9_ref;
28976         }
28977         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28978         FREE(ret_var.data);
28979         return ret_arr;
28980 }
28981
28982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28983         LDKu8slice ser_ref;
28984         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28985         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28986         void* arg_ptr = untag_ptr(arg);
28987         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
28988         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28989         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28990         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28992         return tag_ptr(ret_conv, true);
28993 }
28994
28995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28996         LDKOutPoint this_obj_conv;
28997         this_obj_conv.inner = untag_ptr(this_obj);
28998         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29000         OutPoint_free(this_obj_conv);
29001 }
29002
29003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29004         LDKOutPoint this_ptr_conv;
29005         this_ptr_conv.inner = untag_ptr(this_ptr);
29006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29008         this_ptr_conv.is_owned = false;
29009         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
29011         return ret_arr;
29012 }
29013
29014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29015         LDKOutPoint this_ptr_conv;
29016         this_ptr_conv.inner = untag_ptr(this_ptr);
29017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29019         this_ptr_conv.is_owned = false;
29020         LDKThirtyTwoBytes val_ref;
29021         CHECK((*env)->GetArrayLength(env, val) == 32);
29022         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29023         OutPoint_set_txid(&this_ptr_conv, val_ref);
29024 }
29025
29026 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
29027         LDKOutPoint this_ptr_conv;
29028         this_ptr_conv.inner = untag_ptr(this_ptr);
29029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29031         this_ptr_conv.is_owned = false;
29032         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
29033         return ret_conv;
29034 }
29035
29036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29037         LDKOutPoint this_ptr_conv;
29038         this_ptr_conv.inner = untag_ptr(this_ptr);
29039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29041         this_ptr_conv.is_owned = false;
29042         OutPoint_set_index(&this_ptr_conv, val);
29043 }
29044
29045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
29046         LDKThirtyTwoBytes txid_arg_ref;
29047         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
29048         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
29049         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
29050         int64_t ret_ref = 0;
29051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29053         return ret_ref;
29054 }
29055
29056 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
29057         LDKOutPoint ret_var = OutPoint_clone(arg);
29058         int64_t ret_ref = 0;
29059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29061         return ret_ref;
29062 }
29063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29064         LDKOutPoint arg_conv;
29065         arg_conv.inner = untag_ptr(arg);
29066         arg_conv.is_owned = ptr_is_owned(arg);
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29068         arg_conv.is_owned = false;
29069         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
29070         return ret_conv;
29071 }
29072
29073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29074         LDKOutPoint orig_conv;
29075         orig_conv.inner = untag_ptr(orig);
29076         orig_conv.is_owned = ptr_is_owned(orig);
29077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29078         orig_conv.is_owned = false;
29079         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
29080         int64_t ret_ref = 0;
29081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29083         return ret_ref;
29084 }
29085
29086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29087         LDKOutPoint a_conv;
29088         a_conv.inner = untag_ptr(a);
29089         a_conv.is_owned = ptr_is_owned(a);
29090         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29091         a_conv.is_owned = false;
29092         LDKOutPoint b_conv;
29093         b_conv.inner = untag_ptr(b);
29094         b_conv.is_owned = ptr_is_owned(b);
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29096         b_conv.is_owned = false;
29097         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
29098         return ret_conv;
29099 }
29100
29101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
29102         LDKOutPoint o_conv;
29103         o_conv.inner = untag_ptr(o);
29104         o_conv.is_owned = ptr_is_owned(o);
29105         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29106         o_conv.is_owned = false;
29107         int64_t ret_conv = OutPoint_hash(&o_conv);
29108         return ret_conv;
29109 }
29110
29111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29112         LDKOutPoint this_arg_conv;
29113         this_arg_conv.inner = untag_ptr(this_arg);
29114         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29116         this_arg_conv.is_owned = false;
29117         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29118         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
29119         return ret_arr;
29120 }
29121
29122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
29123         LDKOutPoint obj_conv;
29124         obj_conv.inner = untag_ptr(obj);
29125         obj_conv.is_owned = ptr_is_owned(obj);
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29127         obj_conv.is_owned = false;
29128         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
29129         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29130         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29131         CVec_u8Z_free(ret_var);
29132         return ret_arr;
29133 }
29134
29135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29136         LDKu8slice ser_ref;
29137         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29138         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29139         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
29140         *ret_conv = OutPoint_read(ser_ref);
29141         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29142         return tag_ptr(ret_conv, true);
29143 }
29144
29145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29146         LDKDelayedPaymentOutputDescriptor this_obj_conv;
29147         this_obj_conv.inner = untag_ptr(this_obj);
29148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29150         DelayedPaymentOutputDescriptor_free(this_obj_conv);
29151 }
29152
29153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
29154         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29155         this_ptr_conv.inner = untag_ptr(this_ptr);
29156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29158         this_ptr_conv.is_owned = false;
29159         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
29160         int64_t ret_ref = 0;
29161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29163         return ret_ref;
29164 }
29165
29166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29167         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29168         this_ptr_conv.inner = untag_ptr(this_ptr);
29169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29171         this_ptr_conv.is_owned = false;
29172         LDKOutPoint val_conv;
29173         val_conv.inner = untag_ptr(val);
29174         val_conv.is_owned = ptr_is_owned(val);
29175         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29176         val_conv = OutPoint_clone(&val_conv);
29177         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
29178 }
29179
29180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
29181         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29182         this_ptr_conv.inner = untag_ptr(this_ptr);
29183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29185         this_ptr_conv.is_owned = false;
29186         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
29188         return ret_arr;
29189 }
29190
29191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29192         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29193         this_ptr_conv.inner = untag_ptr(this_ptr);
29194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29196         this_ptr_conv.is_owned = false;
29197         LDKPublicKey val_ref;
29198         CHECK((*env)->GetArrayLength(env, val) == 33);
29199         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29200         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
29201 }
29202
29203 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29204         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29205         this_ptr_conv.inner = untag_ptr(this_ptr);
29206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29208         this_ptr_conv.is_owned = false;
29209         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
29210         return ret_conv;
29211 }
29212
29213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29214         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29215         this_ptr_conv.inner = untag_ptr(this_ptr);
29216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29218         this_ptr_conv.is_owned = false;
29219         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
29220 }
29221
29222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
29223         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29224         this_ptr_conv.inner = untag_ptr(this_ptr);
29225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29227         this_ptr_conv.is_owned = false;
29228         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
29229         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
29230         return tag_ptr(ret_ref, true);
29231 }
29232
29233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29234         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29235         this_ptr_conv.inner = untag_ptr(this_ptr);
29236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29238         this_ptr_conv.is_owned = false;
29239         void* val_ptr = untag_ptr(val);
29240         CHECK_ACCESS(val_ptr);
29241         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
29242         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
29243         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
29244 }
29245
29246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29247         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29248         this_ptr_conv.inner = untag_ptr(this_ptr);
29249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29251         this_ptr_conv.is_owned = false;
29252         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
29254         return ret_arr;
29255 }
29256
29257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29258         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29259         this_ptr_conv.inner = untag_ptr(this_ptr);
29260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29262         this_ptr_conv.is_owned = false;
29263         LDKPublicKey val_ref;
29264         CHECK((*env)->GetArrayLength(env, val) == 33);
29265         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29266         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
29267 }
29268
29269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29270         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29271         this_ptr_conv.inner = untag_ptr(this_ptr);
29272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29274         this_ptr_conv.is_owned = false;
29275         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29276         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
29277         return ret_arr;
29278 }
29279
29280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29281         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29282         this_ptr_conv.inner = untag_ptr(this_ptr);
29283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29285         this_ptr_conv.is_owned = false;
29286         LDKThirtyTwoBytes val_ref;
29287         CHECK((*env)->GetArrayLength(env, val) == 32);
29288         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29289         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
29290 }
29291
29292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29293         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29294         this_ptr_conv.inner = untag_ptr(this_ptr);
29295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29297         this_ptr_conv.is_owned = false;
29298         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
29299         return ret_conv;
29300 }
29301
29302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29303         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29304         this_ptr_conv.inner = untag_ptr(this_ptr);
29305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29307         this_ptr_conv.is_owned = false;
29308         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
29309 }
29310
29311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, int64_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
29312         LDKOutPoint outpoint_arg_conv;
29313         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29314         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29315         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29316         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29317         LDKPublicKey per_commitment_point_arg_ref;
29318         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
29319         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
29320         void* output_arg_ptr = untag_ptr(output_arg);
29321         CHECK_ACCESS(output_arg_ptr);
29322         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
29323         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
29324         LDKPublicKey revocation_pubkey_arg_ref;
29325         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
29326         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
29327         LDKThirtyTwoBytes channel_keys_id_arg_ref;
29328         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
29329         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
29330         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
29331         int64_t ret_ref = 0;
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29334         return ret_ref;
29335 }
29336
29337 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
29338         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
29339         int64_t ret_ref = 0;
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29342         return ret_ref;
29343 }
29344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29345         LDKDelayedPaymentOutputDescriptor arg_conv;
29346         arg_conv.inner = untag_ptr(arg);
29347         arg_conv.is_owned = ptr_is_owned(arg);
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29349         arg_conv.is_owned = false;
29350         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
29351         return ret_conv;
29352 }
29353
29354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29355         LDKDelayedPaymentOutputDescriptor orig_conv;
29356         orig_conv.inner = untag_ptr(orig);
29357         orig_conv.is_owned = ptr_is_owned(orig);
29358         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29359         orig_conv.is_owned = false;
29360         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
29361         int64_t ret_ref = 0;
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29364         return ret_ref;
29365 }
29366
29367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29368         LDKDelayedPaymentOutputDescriptor a_conv;
29369         a_conv.inner = untag_ptr(a);
29370         a_conv.is_owned = ptr_is_owned(a);
29371         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29372         a_conv.is_owned = false;
29373         LDKDelayedPaymentOutputDescriptor b_conv;
29374         b_conv.inner = untag_ptr(b);
29375         b_conv.is_owned = ptr_is_owned(b);
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29377         b_conv.is_owned = false;
29378         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
29379         return ret_conv;
29380 }
29381
29382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29383         LDKDelayedPaymentOutputDescriptor obj_conv;
29384         obj_conv.inner = untag_ptr(obj);
29385         obj_conv.is_owned = ptr_is_owned(obj);
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29387         obj_conv.is_owned = false;
29388         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
29389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29391         CVec_u8Z_free(ret_var);
29392         return ret_arr;
29393 }
29394
29395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29396         LDKu8slice ser_ref;
29397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29399         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
29400         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
29401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29402         return tag_ptr(ret_conv, true);
29403 }
29404
29405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29406         LDKStaticPaymentOutputDescriptor this_obj_conv;
29407         this_obj_conv.inner = untag_ptr(this_obj);
29408         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29410         StaticPaymentOutputDescriptor_free(this_obj_conv);
29411 }
29412
29413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
29414         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29415         this_ptr_conv.inner = untag_ptr(this_ptr);
29416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29418         this_ptr_conv.is_owned = false;
29419         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
29420         int64_t ret_ref = 0;
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29423         return ret_ref;
29424 }
29425
29426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29427         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29428         this_ptr_conv.inner = untag_ptr(this_ptr);
29429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29431         this_ptr_conv.is_owned = false;
29432         LDKOutPoint val_conv;
29433         val_conv.inner = untag_ptr(val);
29434         val_conv.is_owned = ptr_is_owned(val);
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29436         val_conv = OutPoint_clone(&val_conv);
29437         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
29438 }
29439
29440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
29441         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29442         this_ptr_conv.inner = untag_ptr(this_ptr);
29443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29445         this_ptr_conv.is_owned = false;
29446         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
29447         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
29448         return tag_ptr(ret_ref, true);
29449 }
29450
29451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29452         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29453         this_ptr_conv.inner = untag_ptr(this_ptr);
29454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29456         this_ptr_conv.is_owned = false;
29457         void* val_ptr = untag_ptr(val);
29458         CHECK_ACCESS(val_ptr);
29459         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
29460         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
29461         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
29462 }
29463
29464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29465         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29466         this_ptr_conv.inner = untag_ptr(this_ptr);
29467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29469         this_ptr_conv.is_owned = false;
29470         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
29472         return ret_arr;
29473 }
29474
29475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29476         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29477         this_ptr_conv.inner = untag_ptr(this_ptr);
29478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29480         this_ptr_conv.is_owned = false;
29481         LDKThirtyTwoBytes val_ref;
29482         CHECK((*env)->GetArrayLength(env, val) == 32);
29483         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29484         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
29485 }
29486
29487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29488         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29489         this_ptr_conv.inner = untag_ptr(this_ptr);
29490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29492         this_ptr_conv.is_owned = false;
29493         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
29494         return ret_conv;
29495 }
29496
29497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29498         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29499         this_ptr_conv.inner = untag_ptr(this_ptr);
29500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29502         this_ptr_conv.is_owned = false;
29503         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
29504 }
29505
29506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int64_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
29507         LDKOutPoint outpoint_arg_conv;
29508         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29509         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29510         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29511         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29512         void* output_arg_ptr = untag_ptr(output_arg);
29513         CHECK_ACCESS(output_arg_ptr);
29514         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
29515         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
29516         LDKThirtyTwoBytes channel_keys_id_arg_ref;
29517         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
29518         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
29519         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
29520         int64_t ret_ref = 0;
29521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29523         return ret_ref;
29524 }
29525
29526 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
29527         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
29528         int64_t ret_ref = 0;
29529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29531         return ret_ref;
29532 }
29533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29534         LDKStaticPaymentOutputDescriptor arg_conv;
29535         arg_conv.inner = untag_ptr(arg);
29536         arg_conv.is_owned = ptr_is_owned(arg);
29537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29538         arg_conv.is_owned = false;
29539         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
29540         return ret_conv;
29541 }
29542
29543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29544         LDKStaticPaymentOutputDescriptor orig_conv;
29545         orig_conv.inner = untag_ptr(orig);
29546         orig_conv.is_owned = ptr_is_owned(orig);
29547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29548         orig_conv.is_owned = false;
29549         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
29550         int64_t ret_ref = 0;
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29553         return ret_ref;
29554 }
29555
29556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29557         LDKStaticPaymentOutputDescriptor a_conv;
29558         a_conv.inner = untag_ptr(a);
29559         a_conv.is_owned = ptr_is_owned(a);
29560         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29561         a_conv.is_owned = false;
29562         LDKStaticPaymentOutputDescriptor b_conv;
29563         b_conv.inner = untag_ptr(b);
29564         b_conv.is_owned = ptr_is_owned(b);
29565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29566         b_conv.is_owned = false;
29567         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
29568         return ret_conv;
29569 }
29570
29571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29572         LDKStaticPaymentOutputDescriptor obj_conv;
29573         obj_conv.inner = untag_ptr(obj);
29574         obj_conv.is_owned = ptr_is_owned(obj);
29575         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29576         obj_conv.is_owned = false;
29577         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
29578         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29579         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29580         CVec_u8Z_free(ret_var);
29581         return ret_arr;
29582 }
29583
29584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29585         LDKu8slice ser_ref;
29586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29588         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
29589         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
29590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29591         return tag_ptr(ret_conv, true);
29592 }
29593
29594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29595         if (!ptr_is_owned(this_ptr)) return;
29596         void* this_ptr_ptr = untag_ptr(this_ptr);
29597         CHECK_ACCESS(this_ptr_ptr);
29598         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
29599         FREE(untag_ptr(this_ptr));
29600         SpendableOutputDescriptor_free(this_ptr_conv);
29601 }
29602
29603 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
29604         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29605         *ret_copy = SpendableOutputDescriptor_clone(arg);
29606         int64_t ret_ref = tag_ptr(ret_copy, true);
29607         return ret_ref;
29608 }
29609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29610         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
29611         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
29612         return ret_conv;
29613 }
29614
29615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29616         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
29617         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29618         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
29619         int64_t ret_ref = tag_ptr(ret_copy, true);
29620         return ret_ref;
29621 }
29622
29623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
29624         LDKOutPoint outpoint_conv;
29625         outpoint_conv.inner = untag_ptr(outpoint);
29626         outpoint_conv.is_owned = ptr_is_owned(outpoint);
29627         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
29628         outpoint_conv = OutPoint_clone(&outpoint_conv);
29629         void* output_ptr = untag_ptr(output);
29630         CHECK_ACCESS(output_ptr);
29631         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
29632         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
29633         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29634         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
29635         int64_t ret_ref = tag_ptr(ret_copy, true);
29636         return ret_ref;
29637 }
29638
29639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29640         LDKDelayedPaymentOutputDescriptor a_conv;
29641         a_conv.inner = untag_ptr(a);
29642         a_conv.is_owned = ptr_is_owned(a);
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29644         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
29645         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29646         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
29647         int64_t ret_ref = tag_ptr(ret_copy, true);
29648         return ret_ref;
29649 }
29650
29651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29652         LDKStaticPaymentOutputDescriptor a_conv;
29653         a_conv.inner = untag_ptr(a);
29654         a_conv.is_owned = ptr_is_owned(a);
29655         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29656         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
29657         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29658         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
29659         int64_t ret_ref = tag_ptr(ret_copy, true);
29660         return ret_ref;
29661 }
29662
29663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29664         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
29665         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
29666         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
29667         return ret_conv;
29668 }
29669
29670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29671         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
29672         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
29673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29675         CVec_u8Z_free(ret_var);
29676         return ret_arr;
29677 }
29678
29679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29680         LDKu8slice ser_ref;
29681         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29682         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29683         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
29684         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
29685         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29686         return tag_ptr(ret_conv, true);
29687 }
29688
29689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29690         if (!ptr_is_owned(this_ptr)) return;
29691         void* this_ptr_ptr = untag_ptr(this_ptr);
29692         CHECK_ACCESS(this_ptr_ptr);
29693         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
29694         FREE(untag_ptr(this_ptr));
29695         BaseSign_free(this_ptr_conv);
29696 }
29697
29698 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
29699         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29700         *ret_ret = Sign_clone(arg);
29701         return tag_ptr(ret_ret, true);
29702 }
29703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29704         void* arg_ptr = untag_ptr(arg);
29705         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
29706         LDKSign* arg_conv = (LDKSign*)arg_ptr;
29707         int64_t ret_conv = Sign_clone_ptr(arg_conv);
29708         return ret_conv;
29709 }
29710
29711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29712         void* orig_ptr = untag_ptr(orig);
29713         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
29714         LDKSign* orig_conv = (LDKSign*)orig_ptr;
29715         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29716         *ret_ret = Sign_clone(orig_conv);
29717         return tag_ptr(ret_ret, true);
29718 }
29719
29720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29721         if (!ptr_is_owned(this_ptr)) return;
29722         void* this_ptr_ptr = untag_ptr(this_ptr);
29723         CHECK_ACCESS(this_ptr_ptr);
29724         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
29725         FREE(untag_ptr(this_ptr));
29726         Sign_free(this_ptr_conv);
29727 }
29728
29729 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29730         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
29731         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
29732         return ret_conv;
29733 }
29734
29735 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
29736         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
29737         return ret_conv;
29738 }
29739
29740 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
29741         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
29742         return ret_conv;
29743 }
29744
29745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29746         if (!ptr_is_owned(this_ptr)) return;
29747         void* this_ptr_ptr = untag_ptr(this_ptr);
29748         CHECK_ACCESS(this_ptr_ptr);
29749         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
29750         FREE(untag_ptr(this_ptr));
29751         KeysInterface_free(this_ptr_conv);
29752 }
29753
29754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29755         LDKInMemorySigner this_obj_conv;
29756         this_obj_conv.inner = untag_ptr(this_obj);
29757         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29759         InMemorySigner_free(this_obj_conv);
29760 }
29761
29762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29763         LDKInMemorySigner this_ptr_conv;
29764         this_ptr_conv.inner = untag_ptr(this_ptr);
29765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29767         this_ptr_conv.is_owned = false;
29768         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
29770         return ret_arr;
29771 }
29772
29773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29774         LDKInMemorySigner this_ptr_conv;
29775         this_ptr_conv.inner = untag_ptr(this_ptr);
29776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29778         this_ptr_conv.is_owned = false;
29779         LDKSecretKey val_ref;
29780         CHECK((*env)->GetArrayLength(env, val) == 32);
29781         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29782         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
29783 }
29784
29785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29786         LDKInMemorySigner this_ptr_conv;
29787         this_ptr_conv.inner = untag_ptr(this_ptr);
29788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29790         this_ptr_conv.is_owned = false;
29791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
29793         return ret_arr;
29794 }
29795
29796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29797         LDKInMemorySigner this_ptr_conv;
29798         this_ptr_conv.inner = untag_ptr(this_ptr);
29799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29801         this_ptr_conv.is_owned = false;
29802         LDKSecretKey val_ref;
29803         CHECK((*env)->GetArrayLength(env, val) == 32);
29804         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29805         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
29806 }
29807
29808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29809         LDKInMemorySigner this_ptr_conv;
29810         this_ptr_conv.inner = untag_ptr(this_ptr);
29811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29813         this_ptr_conv.is_owned = false;
29814         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29815         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
29816         return ret_arr;
29817 }
29818
29819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29820         LDKInMemorySigner this_ptr_conv;
29821         this_ptr_conv.inner = untag_ptr(this_ptr);
29822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29824         this_ptr_conv.is_owned = false;
29825         LDKSecretKey val_ref;
29826         CHECK((*env)->GetArrayLength(env, val) == 32);
29827         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29828         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
29829 }
29830
29831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29832         LDKInMemorySigner this_ptr_conv;
29833         this_ptr_conv.inner = untag_ptr(this_ptr);
29834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29836         this_ptr_conv.is_owned = false;
29837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
29839         return ret_arr;
29840 }
29841
29842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29843         LDKInMemorySigner this_ptr_conv;
29844         this_ptr_conv.inner = untag_ptr(this_ptr);
29845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29847         this_ptr_conv.is_owned = false;
29848         LDKSecretKey val_ref;
29849         CHECK((*env)->GetArrayLength(env, val) == 32);
29850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29851         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
29852 }
29853
29854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29855         LDKInMemorySigner this_ptr_conv;
29856         this_ptr_conv.inner = untag_ptr(this_ptr);
29857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29859         this_ptr_conv.is_owned = false;
29860         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
29862         return ret_arr;
29863 }
29864
29865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29866         LDKInMemorySigner this_ptr_conv;
29867         this_ptr_conv.inner = untag_ptr(this_ptr);
29868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29870         this_ptr_conv.is_owned = false;
29871         LDKSecretKey val_ref;
29872         CHECK((*env)->GetArrayLength(env, val) == 32);
29873         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29874         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
29875 }
29876
29877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
29878         LDKInMemorySigner this_ptr_conv;
29879         this_ptr_conv.inner = untag_ptr(this_ptr);
29880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29882         this_ptr_conv.is_owned = false;
29883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
29885         return ret_arr;
29886 }
29887
29888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29889         LDKInMemorySigner this_ptr_conv;
29890         this_ptr_conv.inner = untag_ptr(this_ptr);
29891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29893         this_ptr_conv.is_owned = false;
29894         LDKThirtyTwoBytes val_ref;
29895         CHECK((*env)->GetArrayLength(env, val) == 32);
29896         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29897         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
29898 }
29899
29900 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
29901         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
29902         int64_t ret_ref = 0;
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29905         return ret_ref;
29906 }
29907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29908         LDKInMemorySigner arg_conv;
29909         arg_conv.inner = untag_ptr(arg);
29910         arg_conv.is_owned = ptr_is_owned(arg);
29911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29912         arg_conv.is_owned = false;
29913         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
29914         return ret_conv;
29915 }
29916
29917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29918         LDKInMemorySigner orig_conv;
29919         orig_conv.inner = untag_ptr(orig);
29920         orig_conv.is_owned = ptr_is_owned(orig);
29921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29922         orig_conv.is_owned = false;
29923         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
29924         int64_t ret_ref = 0;
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29927         return ret_ref;
29928 }
29929
29930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray node_secret, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
29931         LDKSecretKey node_secret_ref;
29932         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
29933         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
29934         LDKSecretKey funding_key_ref;
29935         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
29936         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
29937         LDKSecretKey revocation_base_key_ref;
29938         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
29939         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
29940         LDKSecretKey payment_key_ref;
29941         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
29942         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
29943         LDKSecretKey delayed_payment_base_key_ref;
29944         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
29945         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
29946         LDKSecretKey htlc_base_key_ref;
29947         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
29948         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
29949         LDKThirtyTwoBytes commitment_seed_ref;
29950         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
29951         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
29952         LDKThirtyTwoBytes channel_keys_id_ref;
29953         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
29954         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
29955         LDKInMemorySigner ret_var = InMemorySigner_new(node_secret_ref, funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
29956         int64_t ret_ref = 0;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29959         return ret_ref;
29960 }
29961
29962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
29963         LDKInMemorySigner this_arg_conv;
29964         this_arg_conv.inner = untag_ptr(this_arg);
29965         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29967         this_arg_conv.is_owned = false;
29968         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
29969         int64_t ret_ref = 0;
29970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29971         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29972         return ret_ref;
29973 }
29974
29975 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29976         LDKInMemorySigner this_arg_conv;
29977         this_arg_conv.inner = untag_ptr(this_arg);
29978         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29980         this_arg_conv.is_owned = false;
29981         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
29982         return ret_conv;
29983 }
29984
29985 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29986         LDKInMemorySigner this_arg_conv;
29987         this_arg_conv.inner = untag_ptr(this_arg);
29988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29990         this_arg_conv.is_owned = false;
29991         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
29992         return ret_conv;
29993 }
29994
29995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
29996         LDKInMemorySigner this_arg_conv;
29997         this_arg_conv.inner = untag_ptr(this_arg);
29998         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30000         this_arg_conv.is_owned = false;
30001         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
30002         return ret_conv;
30003 }
30004
30005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
30006         LDKInMemorySigner this_arg_conv;
30007         this_arg_conv.inner = untag_ptr(this_arg);
30008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30010         this_arg_conv.is_owned = false;
30011         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
30012         int64_t ret_ref = 0;
30013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30015         return ret_ref;
30016 }
30017
30018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
30019         LDKInMemorySigner this_arg_conv;
30020         this_arg_conv.inner = untag_ptr(this_arg);
30021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30023         this_arg_conv.is_owned = false;
30024         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
30025         int64_t ret_ref = 0;
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30028         return ret_ref;
30029 }
30030
30031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
30032         LDKInMemorySigner this_arg_conv;
30033         this_arg_conv.inner = untag_ptr(this_arg);
30034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30036         this_arg_conv.is_owned = false;
30037         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
30038         return ret_conv;
30039 }
30040
30041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1counterparty_1payment_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
30042         LDKInMemorySigner this_arg_conv;
30043         this_arg_conv.inner = untag_ptr(this_arg);
30044         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30046         this_arg_conv.is_owned = false;
30047         LDKTransaction spend_tx_ref;
30048         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
30049         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
30050         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
30051         spend_tx_ref.data_is_owned = true;
30052         LDKStaticPaymentOutputDescriptor descriptor_conv;
30053         descriptor_conv.inner = untag_ptr(descriptor);
30054         descriptor_conv.is_owned = ptr_is_owned(descriptor);
30055         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
30056         descriptor_conv.is_owned = false;
30057         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
30058         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
30059         return tag_ptr(ret_conv, true);
30060 }
30061
30062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1dynamic_1p2wsh_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
30063         LDKInMemorySigner this_arg_conv;
30064         this_arg_conv.inner = untag_ptr(this_arg);
30065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30067         this_arg_conv.is_owned = false;
30068         LDKTransaction spend_tx_ref;
30069         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
30070         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
30071         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
30072         spend_tx_ref.data_is_owned = true;
30073         LDKDelayedPaymentOutputDescriptor descriptor_conv;
30074         descriptor_conv.inner = untag_ptr(descriptor);
30075         descriptor_conv.is_owned = ptr_is_owned(descriptor);
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
30077         descriptor_conv.is_owned = false;
30078         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
30079         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
30080         return tag_ptr(ret_conv, true);
30081 }
30082
30083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
30084         LDKInMemorySigner this_arg_conv;
30085         this_arg_conv.inner = untag_ptr(this_arg);
30086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30088         this_arg_conv.is_owned = false;
30089         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
30090         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
30091         return tag_ptr(ret_ret, true);
30092 }
30093
30094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
30095         LDKInMemorySigner this_arg_conv;
30096         this_arg_conv.inner = untag_ptr(this_arg);
30097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30099         this_arg_conv.is_owned = false;
30100         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30101         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
30102         return tag_ptr(ret_ret, true);
30103 }
30104
30105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
30106         LDKInMemorySigner obj_conv;
30107         obj_conv.inner = untag_ptr(obj);
30108         obj_conv.is_owned = ptr_is_owned(obj);
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30110         obj_conv.is_owned = false;
30111         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
30112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30114         CVec_u8Z_free(ret_var);
30115         return ret_arr;
30116 }
30117
30118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
30119         LDKu8slice ser_ref;
30120         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30121         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30122         LDKSecretKey arg_ref;
30123         CHECK((*env)->GetArrayLength(env, arg) == 32);
30124         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
30125         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
30126         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
30127         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30128         return tag_ptr(ret_conv, true);
30129 }
30130
30131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30132         LDKKeysManager this_obj_conv;
30133         this_obj_conv.inner = untag_ptr(this_obj);
30134         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30136         KeysManager_free(this_obj_conv);
30137 }
30138
30139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
30140         unsigned char seed_arr[32];
30141         CHECK((*env)->GetArrayLength(env, seed) == 32);
30142         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
30143         unsigned char (*seed_ref)[32] = &seed_arr;
30144         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
30145         int64_t ret_ref = 0;
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30148         return ret_ref;
30149 }
30150
30151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
30152         LDKKeysManager this_arg_conv;
30153         this_arg_conv.inner = untag_ptr(this_arg);
30154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30156         this_arg_conv.is_owned = false;
30157         unsigned char params_arr[32];
30158         CHECK((*env)->GetArrayLength(env, params) == 32);
30159         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
30160         unsigned char (*params_ref)[32] = &params_arr;
30161         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
30162         int64_t ret_ref = 0;
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30165         return ret_ref;
30166 }
30167
30168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendable_1outputs(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
30169         LDKKeysManager this_arg_conv;
30170         this_arg_conv.inner = untag_ptr(this_arg);
30171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30173         this_arg_conv.is_owned = false;
30174         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
30175         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
30176         if (descriptors_constr.datalen > 0)
30177                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
30178         else
30179                 descriptors_constr.data = NULL;
30180         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
30181         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
30182                 int64_t descriptors_conv_27 = descriptors_vals[b];
30183                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
30184                 CHECK_ACCESS(descriptors_conv_27_ptr);
30185                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
30186                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
30187                 descriptors_constr.data[b] = descriptors_conv_27_conv;
30188         }
30189         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
30190         LDKCVec_TxOutZ outputs_constr;
30191         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
30192         if (outputs_constr.datalen > 0)
30193                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
30194         else
30195                 outputs_constr.data = NULL;
30196         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
30197         for (size_t h = 0; h < outputs_constr.datalen; h++) {
30198                 int64_t outputs_conv_7 = outputs_vals[h];
30199                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
30200                 CHECK_ACCESS(outputs_conv_7_ptr);
30201                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
30202                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
30203                 outputs_constr.data[h] = outputs_conv_7_conv;
30204         }
30205         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
30206         LDKCVec_u8Z change_destination_script_ref;
30207         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
30208         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
30209         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
30210         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
30211         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
30212         return tag_ptr(ret_conv, true);
30213 }
30214
30215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
30216         LDKKeysManager this_arg_conv;
30217         this_arg_conv.inner = untag_ptr(this_arg);
30218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30220         this_arg_conv.is_owned = false;
30221         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
30222         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
30223         return tag_ptr(ret_ret, true);
30224 }
30225
30226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30227         LDKPhantomKeysManager this_obj_conv;
30228         this_obj_conv.inner = untag_ptr(this_obj);
30229         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30231         PhantomKeysManager_free(this_obj_conv);
30232 }
30233
30234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
30235         LDKPhantomKeysManager this_arg_conv;
30236         this_arg_conv.inner = untag_ptr(this_arg);
30237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30239         this_arg_conv.is_owned = false;
30240         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
30241         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
30242         return tag_ptr(ret_ret, true);
30243 }
30244
30245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
30246         unsigned char seed_arr[32];
30247         CHECK((*env)->GetArrayLength(env, seed) == 32);
30248         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
30249         unsigned char (*seed_ref)[32] = &seed_arr;
30250         unsigned char cross_node_seed_arr[32];
30251         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
30252         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
30253         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
30254         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
30255         int64_t ret_ref = 0;
30256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30258         return ret_ref;
30259 }
30260
30261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1spend_1spendable_1outputs(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
30262         LDKPhantomKeysManager this_arg_conv;
30263         this_arg_conv.inner = untag_ptr(this_arg);
30264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30266         this_arg_conv.is_owned = false;
30267         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
30268         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
30269         if (descriptors_constr.datalen > 0)
30270                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
30271         else
30272                 descriptors_constr.data = NULL;
30273         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
30274         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
30275                 int64_t descriptors_conv_27 = descriptors_vals[b];
30276                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
30277                 CHECK_ACCESS(descriptors_conv_27_ptr);
30278                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
30279                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
30280                 descriptors_constr.data[b] = descriptors_conv_27_conv;
30281         }
30282         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
30283         LDKCVec_TxOutZ outputs_constr;
30284         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
30285         if (outputs_constr.datalen > 0)
30286                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
30287         else
30288                 outputs_constr.data = NULL;
30289         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
30290         for (size_t h = 0; h < outputs_constr.datalen; h++) {
30291                 int64_t outputs_conv_7 = outputs_vals[h];
30292                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
30293                 CHECK_ACCESS(outputs_conv_7_ptr);
30294                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
30295                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
30296                 outputs_constr.data[h] = outputs_conv_7_conv;
30297         }
30298         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
30299         LDKCVec_u8Z change_destination_script_ref;
30300         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
30301         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
30302         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
30303         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
30304         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
30305         return tag_ptr(ret_conv, true);
30306 }
30307
30308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
30309         LDKPhantomKeysManager this_arg_conv;
30310         this_arg_conv.inner = untag_ptr(this_arg);
30311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30313         this_arg_conv.is_owned = false;
30314         unsigned char params_arr[32];
30315         CHECK((*env)->GetArrayLength(env, params) == 32);
30316         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
30317         unsigned char (*params_ref)[32] = &params_arr;
30318         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
30319         int64_t ret_ref = 0;
30320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30322         return ret_ref;
30323 }
30324
30325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30326         LDKChannelManager this_obj_conv;
30327         this_obj_conv.inner = untag_ptr(this_obj);
30328         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30330         ChannelManager_free(this_obj_conv);
30331 }
30332
30333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30334         LDKChainParameters this_obj_conv;
30335         this_obj_conv.inner = untag_ptr(this_obj);
30336         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30338         ChainParameters_free(this_obj_conv);
30339 }
30340
30341 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
30342         LDKChainParameters this_ptr_conv;
30343         this_ptr_conv.inner = untag_ptr(this_ptr);
30344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30346         this_ptr_conv.is_owned = false;
30347         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
30348         return ret_conv;
30349 }
30350
30351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
30352         LDKChainParameters this_ptr_conv;
30353         this_ptr_conv.inner = untag_ptr(this_ptr);
30354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30356         this_ptr_conv.is_owned = false;
30357         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
30358         ChainParameters_set_network(&this_ptr_conv, val_conv);
30359 }
30360
30361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
30362         LDKChainParameters this_ptr_conv;
30363         this_ptr_conv.inner = untag_ptr(this_ptr);
30364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30366         this_ptr_conv.is_owned = false;
30367         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
30368         int64_t ret_ref = 0;
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30371         return ret_ref;
30372 }
30373
30374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30375         LDKChainParameters this_ptr_conv;
30376         this_ptr_conv.inner = untag_ptr(this_ptr);
30377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30379         this_ptr_conv.is_owned = false;
30380         LDKBestBlock val_conv;
30381         val_conv.inner = untag_ptr(val);
30382         val_conv.is_owned = ptr_is_owned(val);
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30384         val_conv = BestBlock_clone(&val_conv);
30385         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
30386 }
30387
30388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
30389         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
30390         LDKBestBlock best_block_arg_conv;
30391         best_block_arg_conv.inner = untag_ptr(best_block_arg);
30392         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
30394         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
30395         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
30396         int64_t ret_ref = 0;
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30399         return ret_ref;
30400 }
30401
30402 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
30403         LDKChainParameters ret_var = ChainParameters_clone(arg);
30404         int64_t ret_ref = 0;
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30407         return ret_ref;
30408 }
30409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30410         LDKChainParameters arg_conv;
30411         arg_conv.inner = untag_ptr(arg);
30412         arg_conv.is_owned = ptr_is_owned(arg);
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30414         arg_conv.is_owned = false;
30415         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
30416         return ret_conv;
30417 }
30418
30419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30420         LDKChainParameters orig_conv;
30421         orig_conv.inner = untag_ptr(orig);
30422         orig_conv.is_owned = ptr_is_owned(orig);
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30424         orig_conv.is_owned = false;
30425         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
30426         int64_t ret_ref = 0;
30427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30429         return ret_ref;
30430 }
30431
30432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30433         LDKCounterpartyForwardingInfo this_obj_conv;
30434         this_obj_conv.inner = untag_ptr(this_obj);
30435         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30437         CounterpartyForwardingInfo_free(this_obj_conv);
30438 }
30439
30440 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30441         LDKCounterpartyForwardingInfo this_ptr_conv;
30442         this_ptr_conv.inner = untag_ptr(this_ptr);
30443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30445         this_ptr_conv.is_owned = false;
30446         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
30447         return ret_conv;
30448 }
30449
30450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30451         LDKCounterpartyForwardingInfo this_ptr_conv;
30452         this_ptr_conv.inner = untag_ptr(this_ptr);
30453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30455         this_ptr_conv.is_owned = false;
30456         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
30457 }
30458
30459 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
30460         LDKCounterpartyForwardingInfo this_ptr_conv;
30461         this_ptr_conv.inner = untag_ptr(this_ptr);
30462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30464         this_ptr_conv.is_owned = false;
30465         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
30466         return ret_conv;
30467 }
30468
30469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30470         LDKCounterpartyForwardingInfo this_ptr_conv;
30471         this_ptr_conv.inner = untag_ptr(this_ptr);
30472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30474         this_ptr_conv.is_owned = false;
30475         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
30476 }
30477
30478 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
30479         LDKCounterpartyForwardingInfo this_ptr_conv;
30480         this_ptr_conv.inner = untag_ptr(this_ptr);
30481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30483         this_ptr_conv.is_owned = false;
30484         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
30485         return ret_conv;
30486 }
30487
30488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30489         LDKCounterpartyForwardingInfo this_ptr_conv;
30490         this_ptr_conv.inner = untag_ptr(this_ptr);
30491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30493         this_ptr_conv.is_owned = false;
30494         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
30495 }
30496
30497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
30498         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
30499         int64_t ret_ref = 0;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30502         return ret_ref;
30503 }
30504
30505 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
30506         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
30507         int64_t ret_ref = 0;
30508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30510         return ret_ref;
30511 }
30512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30513         LDKCounterpartyForwardingInfo arg_conv;
30514         arg_conv.inner = untag_ptr(arg);
30515         arg_conv.is_owned = ptr_is_owned(arg);
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30517         arg_conv.is_owned = false;
30518         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
30519         return ret_conv;
30520 }
30521
30522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30523         LDKCounterpartyForwardingInfo orig_conv;
30524         orig_conv.inner = untag_ptr(orig);
30525         orig_conv.is_owned = ptr_is_owned(orig);
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30527         orig_conv.is_owned = false;
30528         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
30529         int64_t ret_ref = 0;
30530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30532         return ret_ref;
30533 }
30534
30535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30536         LDKChannelCounterparty this_obj_conv;
30537         this_obj_conv.inner = untag_ptr(this_obj);
30538         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30540         ChannelCounterparty_free(this_obj_conv);
30541 }
30542
30543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30544         LDKChannelCounterparty this_ptr_conv;
30545         this_ptr_conv.inner = untag_ptr(this_ptr);
30546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30548         this_ptr_conv.is_owned = false;
30549         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30550         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
30551         return ret_arr;
30552 }
30553
30554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30555         LDKChannelCounterparty this_ptr_conv;
30556         this_ptr_conv.inner = untag_ptr(this_ptr);
30557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30559         this_ptr_conv.is_owned = false;
30560         LDKPublicKey val_ref;
30561         CHECK((*env)->GetArrayLength(env, val) == 33);
30562         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30563         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
30564 }
30565
30566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30567         LDKChannelCounterparty this_ptr_conv;
30568         this_ptr_conv.inner = untag_ptr(this_ptr);
30569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30571         this_ptr_conv.is_owned = false;
30572         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
30573         int64_t ret_ref = 0;
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30576         return ret_ref;
30577 }
30578
30579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30580         LDKChannelCounterparty this_ptr_conv;
30581         this_ptr_conv.inner = untag_ptr(this_ptr);
30582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30584         this_ptr_conv.is_owned = false;
30585         LDKInitFeatures val_conv;
30586         val_conv.inner = untag_ptr(val);
30587         val_conv.is_owned = ptr_is_owned(val);
30588         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30589         val_conv = InitFeatures_clone(&val_conv);
30590         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
30591 }
30592
30593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30594         LDKChannelCounterparty this_ptr_conv;
30595         this_ptr_conv.inner = untag_ptr(this_ptr);
30596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30598         this_ptr_conv.is_owned = false;
30599         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
30600         return ret_conv;
30601 }
30602
30603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30604         LDKChannelCounterparty this_ptr_conv;
30605         this_ptr_conv.inner = untag_ptr(this_ptr);
30606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30608         this_ptr_conv.is_owned = false;
30609         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
30610 }
30611
30612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
30613         LDKChannelCounterparty this_ptr_conv;
30614         this_ptr_conv.inner = untag_ptr(this_ptr);
30615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30617         this_ptr_conv.is_owned = false;
30618         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
30619         int64_t ret_ref = 0;
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30622         return ret_ref;
30623 }
30624
30625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30626         LDKChannelCounterparty this_ptr_conv;
30627         this_ptr_conv.inner = untag_ptr(this_ptr);
30628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30630         this_ptr_conv.is_owned = false;
30631         LDKCounterpartyForwardingInfo val_conv;
30632         val_conv.inner = untag_ptr(val);
30633         val_conv.is_owned = ptr_is_owned(val);
30634         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30635         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
30636         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
30637 }
30638
30639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30640         LDKChannelCounterparty this_ptr_conv;
30641         this_ptr_conv.inner = untag_ptr(this_ptr);
30642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30644         this_ptr_conv.is_owned = false;
30645         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30646         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
30647         int64_t ret_ref = tag_ptr(ret_copy, true);
30648         return ret_ref;
30649 }
30650
30651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30652         LDKChannelCounterparty this_ptr_conv;
30653         this_ptr_conv.inner = untag_ptr(this_ptr);
30654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30656         this_ptr_conv.is_owned = false;
30657         void* val_ptr = untag_ptr(val);
30658         CHECK_ACCESS(val_ptr);
30659         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30660         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30661         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30662 }
30663
30664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30665         LDKChannelCounterparty this_ptr_conv;
30666         this_ptr_conv.inner = untag_ptr(this_ptr);
30667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30669         this_ptr_conv.is_owned = false;
30670         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30671         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
30672         int64_t ret_ref = tag_ptr(ret_copy, true);
30673         return ret_ref;
30674 }
30675
30676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30677         LDKChannelCounterparty this_ptr_conv;
30678         this_ptr_conv.inner = untag_ptr(this_ptr);
30679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30681         this_ptr_conv.is_owned = false;
30682         void* val_ptr = untag_ptr(val);
30683         CHECK_ACCESS(val_ptr);
30684         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30685         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30686         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30687 }
30688
30689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
30690         LDKPublicKey node_id_arg_ref;
30691         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
30692         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
30693         LDKInitFeatures features_arg_conv;
30694         features_arg_conv.inner = untag_ptr(features_arg);
30695         features_arg_conv.is_owned = ptr_is_owned(features_arg);
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
30697         features_arg_conv = InitFeatures_clone(&features_arg_conv);
30698         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
30699         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
30700         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
30701         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
30702         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
30703         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
30704         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
30705         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
30706         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
30707         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
30708         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
30709         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
30710         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
30711         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
30712         int64_t ret_ref = 0;
30713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30715         return ret_ref;
30716 }
30717
30718 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
30719         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
30720         int64_t ret_ref = 0;
30721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30723         return ret_ref;
30724 }
30725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30726         LDKChannelCounterparty arg_conv;
30727         arg_conv.inner = untag_ptr(arg);
30728         arg_conv.is_owned = ptr_is_owned(arg);
30729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30730         arg_conv.is_owned = false;
30731         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
30732         return ret_conv;
30733 }
30734
30735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30736         LDKChannelCounterparty orig_conv;
30737         orig_conv.inner = untag_ptr(orig);
30738         orig_conv.is_owned = ptr_is_owned(orig);
30739         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30740         orig_conv.is_owned = false;
30741         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
30742         int64_t ret_ref = 0;
30743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30745         return ret_ref;
30746 }
30747
30748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30749         LDKChannelDetails this_obj_conv;
30750         this_obj_conv.inner = untag_ptr(this_obj);
30751         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30753         ChannelDetails_free(this_obj_conv);
30754 }
30755
30756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30757         LDKChannelDetails this_ptr_conv;
30758         this_ptr_conv.inner = untag_ptr(this_ptr);
30759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30761         this_ptr_conv.is_owned = false;
30762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
30764         return ret_arr;
30765 }
30766
30767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30768         LDKChannelDetails this_ptr_conv;
30769         this_ptr_conv.inner = untag_ptr(this_ptr);
30770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30772         this_ptr_conv.is_owned = false;
30773         LDKThirtyTwoBytes val_ref;
30774         CHECK((*env)->GetArrayLength(env, val) == 32);
30775         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30776         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
30777 }
30778
30779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
30780         LDKChannelDetails this_ptr_conv;
30781         this_ptr_conv.inner = untag_ptr(this_ptr);
30782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30784         this_ptr_conv.is_owned = false;
30785         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
30786         int64_t ret_ref = 0;
30787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30788         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30789         return ret_ref;
30790 }
30791
30792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30793         LDKChannelDetails this_ptr_conv;
30794         this_ptr_conv.inner = untag_ptr(this_ptr);
30795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30797         this_ptr_conv.is_owned = false;
30798         LDKChannelCounterparty val_conv;
30799         val_conv.inner = untag_ptr(val);
30800         val_conv.is_owned = ptr_is_owned(val);
30801         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30802         val_conv = ChannelCounterparty_clone(&val_conv);
30803         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
30804 }
30805
30806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
30807         LDKChannelDetails this_ptr_conv;
30808         this_ptr_conv.inner = untag_ptr(this_ptr);
30809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         this_ptr_conv.is_owned = false;
30812         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
30813         int64_t ret_ref = 0;
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30816         return ret_ref;
30817 }
30818
30819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30820         LDKChannelDetails this_ptr_conv;
30821         this_ptr_conv.inner = untag_ptr(this_ptr);
30822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30824         this_ptr_conv.is_owned = false;
30825         LDKOutPoint val_conv;
30826         val_conv.inner = untag_ptr(val);
30827         val_conv.is_owned = ptr_is_owned(val);
30828         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30829         val_conv = OutPoint_clone(&val_conv);
30830         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
30831 }
30832
30833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30834         LDKChannelDetails this_ptr_conv;
30835         this_ptr_conv.inner = untag_ptr(this_ptr);
30836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30838         this_ptr_conv.is_owned = false;
30839         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
30840         int64_t ret_ref = 0;
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30843         return ret_ref;
30844 }
30845
30846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30847         LDKChannelDetails this_ptr_conv;
30848         this_ptr_conv.inner = untag_ptr(this_ptr);
30849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30851         this_ptr_conv.is_owned = false;
30852         LDKChannelTypeFeatures val_conv;
30853         val_conv.inner = untag_ptr(val);
30854         val_conv.is_owned = ptr_is_owned(val);
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30856         val_conv = ChannelTypeFeatures_clone(&val_conv);
30857         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
30858 }
30859
30860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30861         LDKChannelDetails this_ptr_conv;
30862         this_ptr_conv.inner = untag_ptr(this_ptr);
30863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30865         this_ptr_conv.is_owned = false;
30866         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30867         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
30868         int64_t ret_ref = tag_ptr(ret_copy, true);
30869         return ret_ref;
30870 }
30871
30872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30873         LDKChannelDetails this_ptr_conv;
30874         this_ptr_conv.inner = untag_ptr(this_ptr);
30875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30877         this_ptr_conv.is_owned = false;
30878         void* val_ptr = untag_ptr(val);
30879         CHECK_ACCESS(val_ptr);
30880         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30881         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30882         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
30883 }
30884
30885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30886         LDKChannelDetails this_ptr_conv;
30887         this_ptr_conv.inner = untag_ptr(this_ptr);
30888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30890         this_ptr_conv.is_owned = false;
30891         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30892         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
30893         int64_t ret_ref = tag_ptr(ret_copy, true);
30894         return ret_ref;
30895 }
30896
30897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30898         LDKChannelDetails this_ptr_conv;
30899         this_ptr_conv.inner = untag_ptr(this_ptr);
30900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30902         this_ptr_conv.is_owned = false;
30903         void* val_ptr = untag_ptr(val);
30904         CHECK_ACCESS(val_ptr);
30905         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30906         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30907         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
30908 }
30909
30910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30911         LDKChannelDetails this_ptr_conv;
30912         this_ptr_conv.inner = untag_ptr(this_ptr);
30913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30915         this_ptr_conv.is_owned = false;
30916         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30917         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
30918         int64_t ret_ref = tag_ptr(ret_copy, true);
30919         return ret_ref;
30920 }
30921
30922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30923         LDKChannelDetails this_ptr_conv;
30924         this_ptr_conv.inner = untag_ptr(this_ptr);
30925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30927         this_ptr_conv.is_owned = false;
30928         void* val_ptr = untag_ptr(val);
30929         CHECK_ACCESS(val_ptr);
30930         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30931         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30932         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
30933 }
30934
30935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30936         LDKChannelDetails this_ptr_conv;
30937         this_ptr_conv.inner = untag_ptr(this_ptr);
30938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30940         this_ptr_conv.is_owned = false;
30941         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
30942         return ret_conv;
30943 }
30944
30945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30946         LDKChannelDetails this_ptr_conv;
30947         this_ptr_conv.inner = untag_ptr(this_ptr);
30948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30950         this_ptr_conv.is_owned = false;
30951         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
30952 }
30953
30954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30955         LDKChannelDetails this_ptr_conv;
30956         this_ptr_conv.inner = untag_ptr(this_ptr);
30957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30959         this_ptr_conv.is_owned = false;
30960         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30961         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30962         int64_t ret_ref = tag_ptr(ret_copy, true);
30963         return ret_ref;
30964 }
30965
30966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30967         LDKChannelDetails this_ptr_conv;
30968         this_ptr_conv.inner = untag_ptr(this_ptr);
30969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30971         this_ptr_conv.is_owned = false;
30972         void* val_ptr = untag_ptr(val);
30973         CHECK_ACCESS(val_ptr);
30974         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30975         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30976         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30977 }
30978
30979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30980         LDKChannelDetails this_ptr_conv;
30981         this_ptr_conv.inner = untag_ptr(this_ptr);
30982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30984         this_ptr_conv.is_owned = false;
30985         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30986         return ret_conv;
30987 }
30988
30989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30990         LDKChannelDetails this_ptr_conv;
30991         this_ptr_conv.inner = untag_ptr(this_ptr);
30992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30994         this_ptr_conv.is_owned = false;
30995         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30996 }
30997
30998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30999         LDKChannelDetails this_ptr_conv;
31000         this_ptr_conv.inner = untag_ptr(this_ptr);
31001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31003         this_ptr_conv.is_owned = false;
31004         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
31005         return ret_conv;
31006 }
31007
31008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31009         LDKChannelDetails this_ptr_conv;
31010         this_ptr_conv.inner = untag_ptr(this_ptr);
31011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31013         this_ptr_conv.is_owned = false;
31014         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
31015 }
31016
31017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31018         LDKChannelDetails this_ptr_conv;
31019         this_ptr_conv.inner = untag_ptr(this_ptr);
31020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31022         this_ptr_conv.is_owned = false;
31023         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
31024         return ret_conv;
31025 }
31026
31027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31028         LDKChannelDetails this_ptr_conv;
31029         this_ptr_conv.inner = untag_ptr(this_ptr);
31030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31032         this_ptr_conv.is_owned = false;
31033         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
31034 }
31035
31036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31037         LDKChannelDetails this_ptr_conv;
31038         this_ptr_conv.inner = untag_ptr(this_ptr);
31039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31041         this_ptr_conv.is_owned = false;
31042         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
31043         return ret_conv;
31044 }
31045
31046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31047         LDKChannelDetails this_ptr_conv;
31048         this_ptr_conv.inner = untag_ptr(this_ptr);
31049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31051         this_ptr_conv.is_owned = false;
31052         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
31053 }
31054
31055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31056         LDKChannelDetails this_ptr_conv;
31057         this_ptr_conv.inner = untag_ptr(this_ptr);
31058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31060         this_ptr_conv.is_owned = false;
31061         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
31062         return ret_conv;
31063 }
31064
31065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31066         LDKChannelDetails this_ptr_conv;
31067         this_ptr_conv.inner = untag_ptr(this_ptr);
31068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31070         this_ptr_conv.is_owned = false;
31071         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
31072 }
31073
31074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
31075         LDKChannelDetails this_ptr_conv;
31076         this_ptr_conv.inner = untag_ptr(this_ptr);
31077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31079         this_ptr_conv.is_owned = false;
31080         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31081         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
31082         int64_t ret_ref = tag_ptr(ret_copy, true);
31083         return ret_ref;
31084 }
31085
31086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31087         LDKChannelDetails this_ptr_conv;
31088         this_ptr_conv.inner = untag_ptr(this_ptr);
31089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31091         this_ptr_conv.is_owned = false;
31092         void* val_ptr = untag_ptr(val);
31093         CHECK_ACCESS(val_ptr);
31094         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31095         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31096         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
31097 }
31098
31099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31100         LDKChannelDetails this_ptr_conv;
31101         this_ptr_conv.inner = untag_ptr(this_ptr);
31102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31104         this_ptr_conv.is_owned = false;
31105         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
31106         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
31107         int64_t ret_ref = tag_ptr(ret_copy, true);
31108         return ret_ref;
31109 }
31110
31111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31112         LDKChannelDetails this_ptr_conv;
31113         this_ptr_conv.inner = untag_ptr(this_ptr);
31114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31116         this_ptr_conv.is_owned = false;
31117         void* val_ptr = untag_ptr(val);
31118         CHECK_ACCESS(val_ptr);
31119         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
31120         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
31121         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
31122 }
31123
31124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
31125         LDKChannelDetails this_ptr_conv;
31126         this_ptr_conv.inner = untag_ptr(this_ptr);
31127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31129         this_ptr_conv.is_owned = false;
31130         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
31131         return ret_conv;
31132 }
31133
31134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31135         LDKChannelDetails this_ptr_conv;
31136         this_ptr_conv.inner = untag_ptr(this_ptr);
31137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31139         this_ptr_conv.is_owned = false;
31140         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
31141 }
31142
31143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
31144         LDKChannelDetails this_ptr_conv;
31145         this_ptr_conv.inner = untag_ptr(this_ptr);
31146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         this_ptr_conv.is_owned = false;
31149         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
31150         return ret_conv;
31151 }
31152
31153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31154         LDKChannelDetails this_ptr_conv;
31155         this_ptr_conv.inner = untag_ptr(this_ptr);
31156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31158         this_ptr_conv.is_owned = false;
31159         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
31160 }
31161
31162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
31163         LDKChannelDetails this_ptr_conv;
31164         this_ptr_conv.inner = untag_ptr(this_ptr);
31165         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31167         this_ptr_conv.is_owned = false;
31168         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
31169         return ret_conv;
31170 }
31171
31172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31173         LDKChannelDetails this_ptr_conv;
31174         this_ptr_conv.inner = untag_ptr(this_ptr);
31175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31177         this_ptr_conv.is_owned = false;
31178         ChannelDetails_set_is_usable(&this_ptr_conv, val);
31179 }
31180
31181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
31182         LDKChannelDetails this_ptr_conv;
31183         this_ptr_conv.inner = untag_ptr(this_ptr);
31184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31186         this_ptr_conv.is_owned = false;
31187         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
31188         return ret_conv;
31189 }
31190
31191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31192         LDKChannelDetails this_ptr_conv;
31193         this_ptr_conv.inner = untag_ptr(this_ptr);
31194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31196         this_ptr_conv.is_owned = false;
31197         ChannelDetails_set_is_public(&this_ptr_conv, val);
31198 }
31199
31200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31201         LDKChannelDetails this_ptr_conv;
31202         this_ptr_conv.inner = untag_ptr(this_ptr);
31203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31205         this_ptr_conv.is_owned = false;
31206         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31207         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
31208         int64_t ret_ref = tag_ptr(ret_copy, true);
31209         return ret_ref;
31210 }
31211
31212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31213         LDKChannelDetails this_ptr_conv;
31214         this_ptr_conv.inner = untag_ptr(this_ptr);
31215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31217         this_ptr_conv.is_owned = false;
31218         void* val_ptr = untag_ptr(val);
31219         CHECK_ACCESS(val_ptr);
31220         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31221         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31222         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
31223 }
31224
31225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31226         LDKChannelDetails this_ptr_conv;
31227         this_ptr_conv.inner = untag_ptr(this_ptr);
31228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31230         this_ptr_conv.is_owned = false;
31231         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31232         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
31233         int64_t ret_ref = tag_ptr(ret_copy, true);
31234         return ret_ref;
31235 }
31236
31237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31238         LDKChannelDetails this_ptr_conv;
31239         this_ptr_conv.inner = untag_ptr(this_ptr);
31240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31242         this_ptr_conv.is_owned = false;
31243         void* val_ptr = untag_ptr(val);
31244         CHECK_ACCESS(val_ptr);
31245         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31246         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31247         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
31248 }
31249
31250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31251         LDKChannelDetails this_ptr_conv;
31252         this_ptr_conv.inner = untag_ptr(this_ptr);
31253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31255         this_ptr_conv.is_owned = false;
31256         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
31257         int64_t ret_ref = 0;
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31260         return ret_ref;
31261 }
31262
31263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31264         LDKChannelDetails this_ptr_conv;
31265         this_ptr_conv.inner = untag_ptr(this_ptr);
31266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31268         this_ptr_conv.is_owned = false;
31269         LDKChannelConfig val_conv;
31270         val_conv.inner = untag_ptr(val);
31271         val_conv.is_owned = ptr_is_owned(val);
31272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31273         val_conv = ChannelConfig_clone(&val_conv);
31274         ChannelDetails_set_config(&this_ptr_conv, val_conv);
31275 }
31276
31277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
31278         LDKThirtyTwoBytes channel_id_arg_ref;
31279         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31280         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31281         LDKChannelCounterparty counterparty_arg_conv;
31282         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
31283         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
31284         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
31285         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
31286         LDKOutPoint funding_txo_arg_conv;
31287         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
31288         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
31289         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
31290         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
31291         LDKChannelTypeFeatures channel_type_arg_conv;
31292         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
31293         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
31294         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
31295         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
31296         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
31297         CHECK_ACCESS(short_channel_id_arg_ptr);
31298         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
31299         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
31300         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
31301         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
31302         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
31303         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
31304         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
31305         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
31306         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
31307         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
31308         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
31309         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
31310         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
31311         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
31312         CHECK_ACCESS(confirmations_required_arg_ptr);
31313         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
31314         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
31315         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
31316         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
31317         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
31318         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
31319         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
31320         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
31321         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
31322         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
31323         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
31324         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
31325         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
31326         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
31327         LDKChannelConfig config_arg_conv;
31328         config_arg_conv.inner = untag_ptr(config_arg);
31329         config_arg_conv.is_owned = ptr_is_owned(config_arg);
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
31331         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
31332         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
31333         int64_t ret_ref = 0;
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31336         return ret_ref;
31337 }
31338
31339 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
31340         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
31341         int64_t ret_ref = 0;
31342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31344         return ret_ref;
31345 }
31346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31347         LDKChannelDetails arg_conv;
31348         arg_conv.inner = untag_ptr(arg);
31349         arg_conv.is_owned = ptr_is_owned(arg);
31350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31351         arg_conv.is_owned = false;
31352         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
31353         return ret_conv;
31354 }
31355
31356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31357         LDKChannelDetails orig_conv;
31358         orig_conv.inner = untag_ptr(orig);
31359         orig_conv.is_owned = ptr_is_owned(orig);
31360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31361         orig_conv.is_owned = false;
31362         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
31363         int64_t ret_ref = 0;
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31366         return ret_ref;
31367 }
31368
31369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31370         LDKChannelDetails this_arg_conv;
31371         this_arg_conv.inner = untag_ptr(this_arg);
31372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31374         this_arg_conv.is_owned = false;
31375         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31376         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
31377         int64_t ret_ref = tag_ptr(ret_copy, true);
31378         return ret_ref;
31379 }
31380
31381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31382         LDKChannelDetails this_arg_conv;
31383         this_arg_conv.inner = untag_ptr(this_arg);
31384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31386         this_arg_conv.is_owned = false;
31387         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31388         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
31389         int64_t ret_ref = tag_ptr(ret_copy, true);
31390         return ret_ref;
31391 }
31392
31393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31394         if (!ptr_is_owned(this_ptr)) return;
31395         void* this_ptr_ptr = untag_ptr(this_ptr);
31396         CHECK_ACCESS(this_ptr_ptr);
31397         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
31398         FREE(untag_ptr(this_ptr));
31399         PaymentSendFailure_free(this_ptr_conv);
31400 }
31401
31402 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
31403         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31404         *ret_copy = PaymentSendFailure_clone(arg);
31405         int64_t ret_ref = tag_ptr(ret_copy, true);
31406         return ret_ref;
31407 }
31408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31409         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
31410         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
31411         return ret_conv;
31412 }
31413
31414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31415         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
31416         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31417         *ret_copy = PaymentSendFailure_clone(orig_conv);
31418         int64_t ret_ref = tag_ptr(ret_copy, true);
31419         return ret_ref;
31420 }
31421
31422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
31423         void* a_ptr = untag_ptr(a);
31424         CHECK_ACCESS(a_ptr);
31425         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
31426         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
31427         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31428         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
31429         int64_t ret_ref = tag_ptr(ret_copy, true);
31430         return ret_ref;
31431 }
31432
31433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
31434         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
31435         a_constr.datalen = (*env)->GetArrayLength(env, a);
31436         if (a_constr.datalen > 0)
31437                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
31438         else
31439                 a_constr.data = NULL;
31440         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
31441         for (size_t w = 0; w < a_constr.datalen; w++) {
31442                 int64_t a_conv_22 = a_vals[w];
31443                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
31444                 CHECK_ACCESS(a_conv_22_ptr);
31445                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
31446                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
31447                 a_constr.data[w] = a_conv_22_conv;
31448         }
31449         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
31450         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31451         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
31452         int64_t ret_ref = tag_ptr(ret_copy, true);
31453         return ret_ref;
31454 }
31455
31456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
31457         LDKCVec_APIErrorZ a_constr;
31458         a_constr.datalen = (*env)->GetArrayLength(env, a);
31459         if (a_constr.datalen > 0)
31460                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
31461         else
31462                 a_constr.data = NULL;
31463         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
31464         for (size_t k = 0; k < a_constr.datalen; k++) {
31465                 int64_t a_conv_10 = a_vals[k];
31466                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
31467                 CHECK_ACCESS(a_conv_10_ptr);
31468                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
31469                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
31470                 a_constr.data[k] = a_conv_10_conv;
31471         }
31472         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
31473         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31474         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
31475         int64_t ret_ref = tag_ptr(ret_copy, true);
31476         return ret_ref;
31477 }
31478
31479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
31480         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
31481         results_constr.datalen = (*env)->GetArrayLength(env, results);
31482         if (results_constr.datalen > 0)
31483                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
31484         else
31485                 results_constr.data = NULL;
31486         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
31487         for (size_t w = 0; w < results_constr.datalen; w++) {
31488                 int64_t results_conv_22 = results_vals[w];
31489                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
31490                 CHECK_ACCESS(results_conv_22_ptr);
31491                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
31492                 results_constr.data[w] = results_conv_22_conv;
31493         }
31494         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
31495         LDKRouteParameters failed_paths_retry_conv;
31496         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
31497         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
31498         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
31499         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
31500         LDKThirtyTwoBytes payment_id_ref;
31501         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31502         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31503         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31504         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
31505         int64_t ret_ref = tag_ptr(ret_copy, true);
31506         return ret_ref;
31507 }
31508
31509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31510         LDKPhantomRouteHints this_obj_conv;
31511         this_obj_conv.inner = untag_ptr(this_obj);
31512         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31514         PhantomRouteHints_free(this_obj_conv);
31515 }
31516
31517 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
31518         LDKPhantomRouteHints this_ptr_conv;
31519         this_ptr_conv.inner = untag_ptr(this_ptr);
31520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31522         this_ptr_conv.is_owned = false;
31523         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
31524         int64_tArray ret_arr = NULL;
31525         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31526         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31527         for (size_t q = 0; q < ret_var.datalen; q++) {
31528                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31529                 int64_t ret_conv_16_ref = 0;
31530                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31531                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31532                 ret_arr_ptr[q] = ret_conv_16_ref;
31533         }
31534         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31535         FREE(ret_var.data);
31536         return ret_arr;
31537 }
31538
31539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31540         LDKPhantomRouteHints this_ptr_conv;
31541         this_ptr_conv.inner = untag_ptr(this_ptr);
31542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31544         this_ptr_conv.is_owned = false;
31545         LDKCVec_ChannelDetailsZ val_constr;
31546         val_constr.datalen = (*env)->GetArrayLength(env, val);
31547         if (val_constr.datalen > 0)
31548                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31549         else
31550                 val_constr.data = NULL;
31551         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31552         for (size_t q = 0; q < val_constr.datalen; q++) {
31553                 int64_t val_conv_16 = val_vals[q];
31554                 LDKChannelDetails val_conv_16_conv;
31555                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
31556                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
31557                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31558                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
31559                 val_constr.data[q] = val_conv_16_conv;
31560         }
31561         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31562         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
31563 }
31564
31565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31566         LDKPhantomRouteHints this_ptr_conv;
31567         this_ptr_conv.inner = untag_ptr(this_ptr);
31568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31570         this_ptr_conv.is_owned = false;
31571         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
31572         return ret_conv;
31573 }
31574
31575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31576         LDKPhantomRouteHints this_ptr_conv;
31577         this_ptr_conv.inner = untag_ptr(this_ptr);
31578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31580         this_ptr_conv.is_owned = false;
31581         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
31582 }
31583
31584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31585         LDKPhantomRouteHints this_ptr_conv;
31586         this_ptr_conv.inner = untag_ptr(this_ptr);
31587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31589         this_ptr_conv.is_owned = false;
31590         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
31592         return ret_arr;
31593 }
31594
31595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31596         LDKPhantomRouteHints this_ptr_conv;
31597         this_ptr_conv.inner = untag_ptr(this_ptr);
31598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31600         this_ptr_conv.is_owned = false;
31601         LDKPublicKey val_ref;
31602         CHECK((*env)->GetArrayLength(env, val) == 33);
31603         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31604         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
31605 }
31606
31607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
31608         LDKCVec_ChannelDetailsZ channels_arg_constr;
31609         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
31610         if (channels_arg_constr.datalen > 0)
31611                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31612         else
31613                 channels_arg_constr.data = NULL;
31614         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
31615         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
31616                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
31617                 LDKChannelDetails channels_arg_conv_16_conv;
31618                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
31619                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
31620                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
31621                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
31622                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
31623         }
31624         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
31625         LDKPublicKey real_node_pubkey_arg_ref;
31626         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
31627         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
31628         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
31629         int64_t ret_ref = 0;
31630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31632         return ret_ref;
31633 }
31634
31635 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
31636         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
31637         int64_t ret_ref = 0;
31638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31640         return ret_ref;
31641 }
31642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31643         LDKPhantomRouteHints arg_conv;
31644         arg_conv.inner = untag_ptr(arg);
31645         arg_conv.is_owned = ptr_is_owned(arg);
31646         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31647         arg_conv.is_owned = false;
31648         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
31649         return ret_conv;
31650 }
31651
31652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31653         LDKPhantomRouteHints orig_conv;
31654         orig_conv.inner = untag_ptr(orig);
31655         orig_conv.is_owned = ptr_is_owned(orig);
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31657         orig_conv.is_owned = false;
31658         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
31659         int64_t ret_ref = 0;
31660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31662         return ret_ref;
31663 }
31664
31665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t params) {
31666         void* fee_est_ptr = untag_ptr(fee_est);
31667         CHECK_ACCESS(fee_est_ptr);
31668         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
31669         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
31670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31671                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
31672         }
31673         void* chain_monitor_ptr = untag_ptr(chain_monitor);
31674         CHECK_ACCESS(chain_monitor_ptr);
31675         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31676         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31677                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31678                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31679         }
31680         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
31681         CHECK_ACCESS(tx_broadcaster_ptr);
31682         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31683         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31684                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31685                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31686         }
31687         void* logger_ptr = untag_ptr(logger);
31688         CHECK_ACCESS(logger_ptr);
31689         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31690         if (logger_conv.free == LDKLogger_JCalls_free) {
31691                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31692                 LDKLogger_JCalls_cloned(&logger_conv);
31693         }
31694         void* keys_manager_ptr = untag_ptr(keys_manager);
31695         CHECK_ACCESS(keys_manager_ptr);
31696         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31697         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31698                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31699                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31700         }
31701         LDKUserConfig config_conv;
31702         config_conv.inner = untag_ptr(config);
31703         config_conv.is_owned = ptr_is_owned(config);
31704         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31705         config_conv = UserConfig_clone(&config_conv);
31706         LDKChainParameters params_conv;
31707         params_conv.inner = untag_ptr(params);
31708         params_conv.is_owned = ptr_is_owned(params);
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
31710         params_conv = ChainParameters_clone(&params_conv);
31711         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
31712         int64_t ret_ref = 0;
31713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31715         return ret_ref;
31716 }
31717
31718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
31719         LDKChannelManager this_arg_conv;
31720         this_arg_conv.inner = untag_ptr(this_arg);
31721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31723         this_arg_conv.is_owned = false;
31724         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
31725         int64_t ret_ref = 0;
31726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31728         return ret_ref;
31729 }
31730
31731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, int64_t override_config) {
31732         LDKChannelManager this_arg_conv;
31733         this_arg_conv.inner = untag_ptr(this_arg);
31734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31736         this_arg_conv.is_owned = false;
31737         LDKPublicKey their_network_key_ref;
31738         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
31739         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
31740         LDKUserConfig override_config_conv;
31741         override_config_conv.inner = untag_ptr(override_config);
31742         override_config_conv.is_owned = ptr_is_owned(override_config);
31743         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
31744         override_config_conv = UserConfig_clone(&override_config_conv);
31745         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
31746         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
31747         return tag_ptr(ret_conv, true);
31748 }
31749
31750 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31751         LDKChannelManager this_arg_conv;
31752         this_arg_conv.inner = untag_ptr(this_arg);
31753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31755         this_arg_conv.is_owned = false;
31756         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
31757         int64_tArray ret_arr = NULL;
31758         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31759         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31760         for (size_t q = 0; q < ret_var.datalen; q++) {
31761                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31762                 int64_t ret_conv_16_ref = 0;
31763                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31764                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31765                 ret_arr_ptr[q] = ret_conv_16_ref;
31766         }
31767         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31768         FREE(ret_var.data);
31769         return ret_arr;
31770 }
31771
31772 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31773         LDKChannelManager this_arg_conv;
31774         this_arg_conv.inner = untag_ptr(this_arg);
31775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31777         this_arg_conv.is_owned = false;
31778         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
31779         int64_tArray ret_arr = NULL;
31780         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31781         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31782         for (size_t q = 0; q < ret_var.datalen; q++) {
31783                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31784                 int64_t ret_conv_16_ref = 0;
31785                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31786                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31787                 ret_arr_ptr[q] = ret_conv_16_ref;
31788         }
31789         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31790         FREE(ret_var.data);
31791         return ret_arr;
31792 }
31793
31794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31795         LDKChannelManager this_arg_conv;
31796         this_arg_conv.inner = untag_ptr(this_arg);
31797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31799         this_arg_conv.is_owned = false;
31800         unsigned char channel_id_arr[32];
31801         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31802         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31803         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31804         LDKPublicKey counterparty_node_id_ref;
31805         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31806         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31807         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31808         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31809         return tag_ptr(ret_conv, true);
31810 }
31811
31812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
31813         LDKChannelManager this_arg_conv;
31814         this_arg_conv.inner = untag_ptr(this_arg);
31815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31817         this_arg_conv.is_owned = false;
31818         unsigned char channel_id_arr[32];
31819         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31820         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31821         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31822         LDKPublicKey counterparty_node_id_ref;
31823         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31824         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31825         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31826         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
31827         return tag_ptr(ret_conv, true);
31828 }
31829
31830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31831         LDKChannelManager this_arg_conv;
31832         this_arg_conv.inner = untag_ptr(this_arg);
31833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31835         this_arg_conv.is_owned = false;
31836         unsigned char channel_id_arr[32];
31837         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31838         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31839         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31840         LDKPublicKey counterparty_node_id_ref;
31841         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31842         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31843         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31844         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31845         return tag_ptr(ret_conv, true);
31846 }
31847
31848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31849         LDKChannelManager this_arg_conv;
31850         this_arg_conv.inner = untag_ptr(this_arg);
31851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31853         this_arg_conv.is_owned = false;
31854         unsigned char channel_id_arr[32];
31855         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31856         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31857         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31858         LDKPublicKey counterparty_node_id_ref;
31859         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31860         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31861         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31862         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31863         return tag_ptr(ret_conv, true);
31864 }
31865
31866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31867         LDKChannelManager this_arg_conv;
31868         this_arg_conv.inner = untag_ptr(this_arg);
31869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31871         this_arg_conv.is_owned = false;
31872         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
31873 }
31874
31875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31876         LDKChannelManager this_arg_conv;
31877         this_arg_conv.inner = untag_ptr(this_arg);
31878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31880         this_arg_conv.is_owned = false;
31881         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
31882 }
31883
31884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
31885         LDKChannelManager this_arg_conv;
31886         this_arg_conv.inner = untag_ptr(this_arg);
31887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31889         this_arg_conv.is_owned = false;
31890         LDKRoute route_conv;
31891         route_conv.inner = untag_ptr(route);
31892         route_conv.is_owned = ptr_is_owned(route);
31893         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31894         route_conv.is_owned = false;
31895         LDKThirtyTwoBytes payment_hash_ref;
31896         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31897         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31898         LDKThirtyTwoBytes payment_secret_ref;
31899         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31900         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31901         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
31902         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
31903         return tag_ptr(ret_conv, true);
31904 }
31905
31906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
31907         LDKChannelManager this_arg_conv;
31908         this_arg_conv.inner = untag_ptr(this_arg);
31909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31911         this_arg_conv.is_owned = false;
31912         LDKRoute route_conv;
31913         route_conv.inner = untag_ptr(route);
31914         route_conv.is_owned = ptr_is_owned(route);
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31916         route_conv.is_owned = false;
31917         LDKThirtyTwoBytes payment_id_ref;
31918         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31919         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31920         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
31921         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
31922         return tag_ptr(ret_conv, true);
31923 }
31924
31925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
31926         LDKChannelManager this_arg_conv;
31927         this_arg_conv.inner = untag_ptr(this_arg);
31928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31930         this_arg_conv.is_owned = false;
31931         LDKThirtyTwoBytes payment_id_ref;
31932         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31933         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31934         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
31935 }
31936
31937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
31938         LDKChannelManager this_arg_conv;
31939         this_arg_conv.inner = untag_ptr(this_arg);
31940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31942         this_arg_conv.is_owned = false;
31943         LDKRoute route_conv;
31944         route_conv.inner = untag_ptr(route);
31945         route_conv.is_owned = ptr_is_owned(route);
31946         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31947         route_conv.is_owned = false;
31948         LDKThirtyTwoBytes payment_preimage_ref;
31949         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31950         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31951         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31952         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
31953         return tag_ptr(ret_conv, true);
31954 }
31955
31956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31957         LDKChannelManager this_arg_conv;
31958         this_arg_conv.inner = untag_ptr(this_arg);
31959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31961         this_arg_conv.is_owned = false;
31962         LDKCVec_RouteHopZ hops_constr;
31963         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31964         if (hops_constr.datalen > 0)
31965                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31966         else
31967                 hops_constr.data = NULL;
31968         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31969         for (size_t k = 0; k < hops_constr.datalen; k++) {
31970                 int64_t hops_conv_10 = hops_vals[k];
31971                 LDKRouteHop hops_conv_10_conv;
31972                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
31973                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
31974                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31975                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31976                 hops_constr.data[k] = hops_conv_10_conv;
31977         }
31978         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31979         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31980         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31981         return tag_ptr(ret_conv, true);
31982 }
31983
31984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
31985         LDKChannelManager this_arg_conv;
31986         this_arg_conv.inner = untag_ptr(this_arg);
31987         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31989         this_arg_conv.is_owned = false;
31990         unsigned char temporary_channel_id_arr[32];
31991         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31992         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31993         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31994         LDKPublicKey counterparty_node_id_ref;
31995         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31996         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31997         LDKTransaction funding_transaction_ref;
31998         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31999         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
32000         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
32001         funding_transaction_ref.data_is_owned = true;
32002         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32003         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
32004         return tag_ptr(ret_conv, true);
32005 }
32006
32007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
32008         LDKChannelManager this_arg_conv;
32009         this_arg_conv.inner = untag_ptr(this_arg);
32010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32012         this_arg_conv.is_owned = false;
32013         LDKPublicKey counterparty_node_id_ref;
32014         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32015         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32016         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
32017         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
32018         if (channel_ids_constr.datalen > 0)
32019                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
32020         else
32021                 channel_ids_constr.data = NULL;
32022         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
32023                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
32024                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
32025                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
32026                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
32027                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
32028         }
32029         LDKChannelConfig config_conv;
32030         config_conv.inner = untag_ptr(config);
32031         config_conv.is_owned = ptr_is_owned(config);
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
32033         config_conv.is_owned = false;
32034         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32035         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
32036         return tag_ptr(ret_conv, true);
32037 }
32038
32039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
32040         LDKChannelManager this_arg_conv;
32041         this_arg_conv.inner = untag_ptr(this_arg);
32042         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32044         this_arg_conv.is_owned = false;
32045         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
32046 }
32047
32048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
32049         LDKChannelManager this_arg_conv;
32050         this_arg_conv.inner = untag_ptr(this_arg);
32051         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32053         this_arg_conv.is_owned = false;
32054         ChannelManager_timer_tick_occurred(&this_arg_conv);
32055 }
32056
32057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
32058         LDKChannelManager this_arg_conv;
32059         this_arg_conv.inner = untag_ptr(this_arg);
32060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32062         this_arg_conv.is_owned = false;
32063         unsigned char payment_hash_arr[32];
32064         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32065         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
32066         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
32067         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
32068 }
32069
32070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
32071         LDKChannelManager this_arg_conv;
32072         this_arg_conv.inner = untag_ptr(this_arg);
32073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32075         this_arg_conv.is_owned = false;
32076         LDKThirtyTwoBytes payment_preimage_ref;
32077         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
32078         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
32079         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
32080 }
32081
32082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
32083         LDKChannelManager this_arg_conv;
32084         this_arg_conv.inner = untag_ptr(this_arg);
32085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32087         this_arg_conv.is_owned = false;
32088         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
32090         return ret_arr;
32091 }
32092
32093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
32094         LDKChannelManager this_arg_conv;
32095         this_arg_conv.inner = untag_ptr(this_arg);
32096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32098         this_arg_conv.is_owned = false;
32099         unsigned char temporary_channel_id_arr[32];
32100         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32101         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32102         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32103         LDKPublicKey counterparty_node_id_ref;
32104         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32105         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32106         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32107         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
32108         return tag_ptr(ret_conv, true);
32109 }
32110
32111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
32112         LDKChannelManager this_arg_conv;
32113         this_arg_conv.inner = untag_ptr(this_arg);
32114         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32116         this_arg_conv.is_owned = false;
32117         unsigned char temporary_channel_id_arr[32];
32118         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32119         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32120         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32121         LDKPublicKey counterparty_node_id_ref;
32122         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32123         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32124         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32125         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
32126         return tag_ptr(ret_conv, true);
32127 }
32128
32129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
32130         LDKChannelManager this_arg_conv;
32131         this_arg_conv.inner = untag_ptr(this_arg);
32132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32134         this_arg_conv.is_owned = false;
32135         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32136         CHECK_ACCESS(min_value_msat_ptr);
32137         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32138         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32139         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
32140         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
32141         return tag_ptr(ret_conv, true);
32142 }
32143
32144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1legacy(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
32145         LDKChannelManager this_arg_conv;
32146         this_arg_conv.inner = untag_ptr(this_arg);
32147         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32149         this_arg_conv.is_owned = false;
32150         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32151         CHECK_ACCESS(min_value_msat_ptr);
32152         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32153         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32154         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
32155         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
32156         return tag_ptr(ret_conv, true);
32157 }
32158
32159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1for_1hash(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
32160         LDKChannelManager this_arg_conv;
32161         this_arg_conv.inner = untag_ptr(this_arg);
32162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32164         this_arg_conv.is_owned = false;
32165         LDKThirtyTwoBytes payment_hash_ref;
32166         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32167         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32168         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32169         CHECK_ACCESS(min_value_msat_ptr);
32170         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32171         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32172         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
32173         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
32174         return tag_ptr(ret_conv, true);
32175 }
32176
32177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1for_1hash_1legacy(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
32178         LDKChannelManager this_arg_conv;
32179         this_arg_conv.inner = untag_ptr(this_arg);
32180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32182         this_arg_conv.is_owned = false;
32183         LDKThirtyTwoBytes payment_hash_ref;
32184         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32185         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32186         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32187         CHECK_ACCESS(min_value_msat_ptr);
32188         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32189         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32190         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
32191         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
32192         return tag_ptr(ret_conv, true);
32193 }
32194
32195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
32196         LDKChannelManager this_arg_conv;
32197         this_arg_conv.inner = untag_ptr(this_arg);
32198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32200         this_arg_conv.is_owned = false;
32201         LDKThirtyTwoBytes payment_hash_ref;
32202         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32203         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32204         LDKThirtyTwoBytes payment_secret_ref;
32205         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
32206         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
32207         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
32208         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
32209         return tag_ptr(ret_conv, true);
32210 }
32211
32212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32213         LDKChannelManager this_arg_conv;
32214         this_arg_conv.inner = untag_ptr(this_arg);
32215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32217         this_arg_conv.is_owned = false;
32218         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
32219         return ret_conv;
32220 }
32221
32222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
32223         LDKChannelManager this_arg_conv;
32224         this_arg_conv.inner = untag_ptr(this_arg);
32225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32227         this_arg_conv.is_owned = false;
32228         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
32229         int64_t ret_ref = 0;
32230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32232         return ret_ref;
32233 }
32234
32235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32236         LDKChannelManager this_arg_conv;
32237         this_arg_conv.inner = untag_ptr(this_arg);
32238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32240         this_arg_conv.is_owned = false;
32241         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32242         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
32243         return tag_ptr(ret_ret, true);
32244 }
32245
32246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32247         LDKChannelManager this_arg_conv;
32248         this_arg_conv.inner = untag_ptr(this_arg);
32249         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32251         this_arg_conv.is_owned = false;
32252         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
32253         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
32254         return tag_ptr(ret_ret, true);
32255 }
32256
32257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
32258         LDKChannelManager this_arg_conv;
32259         this_arg_conv.inner = untag_ptr(this_arg);
32260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32262         this_arg_conv.is_owned = false;
32263         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
32264         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
32265         return tag_ptr(ret_ret, true);
32266 }
32267
32268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
32269         LDKChannelManager this_arg_conv;
32270         this_arg_conv.inner = untag_ptr(this_arg);
32271         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32273         this_arg_conv.is_owned = false;
32274         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
32275         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
32276         return tag_ptr(ret_ret, true);
32277 }
32278
32279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
32280         LDKChannelManager this_arg_conv;
32281         this_arg_conv.inner = untag_ptr(this_arg);
32282         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32284         this_arg_conv.is_owned = false;
32285         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
32286         return ret_conv;
32287 }
32288
32289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
32290         LDKChannelManager this_arg_conv;
32291         this_arg_conv.inner = untag_ptr(this_arg);
32292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32294         this_arg_conv.is_owned = false;
32295         ChannelManager_await_persistable_update(&this_arg_conv);
32296 }
32297
32298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
32299         LDKChannelManager this_arg_conv;
32300         this_arg_conv.inner = untag_ptr(this_arg);
32301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32303         this_arg_conv.is_owned = false;
32304         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
32305         int64_t ret_ref = 0;
32306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32308         return ret_ref;
32309 }
32310
32311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
32312         LDKChannelManager this_arg_conv;
32313         this_arg_conv.inner = untag_ptr(this_arg);
32314         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32316         this_arg_conv.is_owned = false;
32317         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
32318         int64_t ret_ref = 0;
32319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32321         return ret_ref;
32322 }
32323
32324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
32325         LDKChannelManager this_arg_conv;
32326         this_arg_conv.inner = untag_ptr(this_arg);
32327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32329         this_arg_conv.is_owned = false;
32330         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32331         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
32332         return tag_ptr(ret_ret, true);
32333 }
32334
32335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1node_1features(JNIEnv *env, jclass clz) {
32336         LDKNodeFeatures ret_var = provided_node_features();
32337         int64_t ret_ref = 0;
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32340         return ret_ref;
32341 }
32342
32343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1channel_1features(JNIEnv *env, jclass clz) {
32344         LDKChannelFeatures ret_var = provided_channel_features();
32345         int64_t ret_ref = 0;
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32348         return ret_ref;
32349 }
32350
32351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz) {
32352         LDKInitFeatures ret_var = provided_init_features();
32353         int64_t ret_ref = 0;
32354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32356         return ret_ref;
32357 }
32358
32359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
32360         LDKCounterpartyForwardingInfo obj_conv;
32361         obj_conv.inner = untag_ptr(obj);
32362         obj_conv.is_owned = ptr_is_owned(obj);
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32364         obj_conv.is_owned = false;
32365         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
32366         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32367         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32368         CVec_u8Z_free(ret_var);
32369         return ret_arr;
32370 }
32371
32372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32373         LDKu8slice ser_ref;
32374         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32375         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32376         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
32377         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
32378         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32379         return tag_ptr(ret_conv, true);
32380 }
32381
32382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
32383         LDKChannelCounterparty obj_conv;
32384         obj_conv.inner = untag_ptr(obj);
32385         obj_conv.is_owned = ptr_is_owned(obj);
32386         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32387         obj_conv.is_owned = false;
32388         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
32389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32391         CVec_u8Z_free(ret_var);
32392         return ret_arr;
32393 }
32394
32395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32396         LDKu8slice ser_ref;
32397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32399         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
32400         *ret_conv = ChannelCounterparty_read(ser_ref);
32401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32402         return tag_ptr(ret_conv, true);
32403 }
32404
32405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
32406         LDKChannelDetails obj_conv;
32407         obj_conv.inner = untag_ptr(obj);
32408         obj_conv.is_owned = ptr_is_owned(obj);
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32410         obj_conv.is_owned = false;
32411         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
32412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32414         CVec_u8Z_free(ret_var);
32415         return ret_arr;
32416 }
32417
32418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32419         LDKu8slice ser_ref;
32420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32422         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
32423         *ret_conv = ChannelDetails_read(ser_ref);
32424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32425         return tag_ptr(ret_conv, true);
32426 }
32427
32428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
32429         LDKPhantomRouteHints obj_conv;
32430         obj_conv.inner = untag_ptr(obj);
32431         obj_conv.is_owned = ptr_is_owned(obj);
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32433         obj_conv.is_owned = false;
32434         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
32435         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32436         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32437         CVec_u8Z_free(ret_var);
32438         return ret_arr;
32439 }
32440
32441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32442         LDKu8slice ser_ref;
32443         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32444         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32445         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
32446         *ret_conv = PhantomRouteHints_read(ser_ref);
32447         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32448         return tag_ptr(ret_conv, true);
32449 }
32450
32451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
32452         LDKChannelManager obj_conv;
32453         obj_conv.inner = untag_ptr(obj);
32454         obj_conv.is_owned = ptr_is_owned(obj);
32455         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32456         obj_conv.is_owned = false;
32457         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
32458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32460         CVec_u8Z_free(ret_var);
32461         return ret_arr;
32462 }
32463
32464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32465         LDKChannelManagerReadArgs this_obj_conv;
32466         this_obj_conv.inner = untag_ptr(this_obj);
32467         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32469         ChannelManagerReadArgs_free(this_obj_conv);
32470 }
32471
32472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
32473         LDKChannelManagerReadArgs this_ptr_conv;
32474         this_ptr_conv.inner = untag_ptr(this_ptr);
32475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32477         this_ptr_conv.is_owned = false;
32478         // WARNING: This object doesn't live past this scope, needs clone!
32479         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
32480         return ret_ret;
32481 }
32482
32483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32484         LDKChannelManagerReadArgs this_ptr_conv;
32485         this_ptr_conv.inner = untag_ptr(this_ptr);
32486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32488         this_ptr_conv.is_owned = false;
32489         void* val_ptr = untag_ptr(val);
32490         CHECK_ACCESS(val_ptr);
32491         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
32492         if (val_conv.free == LDKKeysInterface_JCalls_free) {
32493                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32494                 LDKKeysInterface_JCalls_cloned(&val_conv);
32495         }
32496         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
32497 }
32498
32499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
32500         LDKChannelManagerReadArgs this_ptr_conv;
32501         this_ptr_conv.inner = untag_ptr(this_ptr);
32502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32504         this_ptr_conv.is_owned = false;
32505         // WARNING: This object doesn't live past this scope, needs clone!
32506         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
32507         return ret_ret;
32508 }
32509
32510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32511         LDKChannelManagerReadArgs this_ptr_conv;
32512         this_ptr_conv.inner = untag_ptr(this_ptr);
32513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32515         this_ptr_conv.is_owned = false;
32516         void* val_ptr = untag_ptr(val);
32517         CHECK_ACCESS(val_ptr);
32518         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
32519         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
32520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32521                 LDKFeeEstimator_JCalls_cloned(&val_conv);
32522         }
32523         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
32524 }
32525
32526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
32527         LDKChannelManagerReadArgs this_ptr_conv;
32528         this_ptr_conv.inner = untag_ptr(this_ptr);
32529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32531         this_ptr_conv.is_owned = false;
32532         // WARNING: This object doesn't live past this scope, needs clone!
32533         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
32534         return ret_ret;
32535 }
32536
32537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32538         LDKChannelManagerReadArgs this_ptr_conv;
32539         this_ptr_conv.inner = untag_ptr(this_ptr);
32540         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32542         this_ptr_conv.is_owned = false;
32543         void* val_ptr = untag_ptr(val);
32544         CHECK_ACCESS(val_ptr);
32545         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
32546         if (val_conv.free == LDKWatch_JCalls_free) {
32547                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32548                 LDKWatch_JCalls_cloned(&val_conv);
32549         }
32550         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
32551 }
32552
32553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
32554         LDKChannelManagerReadArgs this_ptr_conv;
32555         this_ptr_conv.inner = untag_ptr(this_ptr);
32556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32558         this_ptr_conv.is_owned = false;
32559         // WARNING: This object doesn't live past this scope, needs clone!
32560         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
32561         return ret_ret;
32562 }
32563
32564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32565         LDKChannelManagerReadArgs this_ptr_conv;
32566         this_ptr_conv.inner = untag_ptr(this_ptr);
32567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32569         this_ptr_conv.is_owned = false;
32570         void* val_ptr = untag_ptr(val);
32571         CHECK_ACCESS(val_ptr);
32572         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
32573         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
32574                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32575                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
32576         }
32577         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
32578 }
32579
32580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
32581         LDKChannelManagerReadArgs this_ptr_conv;
32582         this_ptr_conv.inner = untag_ptr(this_ptr);
32583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32585         this_ptr_conv.is_owned = false;
32586         // WARNING: This object doesn't live past this scope, needs clone!
32587         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
32588         return ret_ret;
32589 }
32590
32591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32592         LDKChannelManagerReadArgs this_ptr_conv;
32593         this_ptr_conv.inner = untag_ptr(this_ptr);
32594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32596         this_ptr_conv.is_owned = false;
32597         void* val_ptr = untag_ptr(val);
32598         CHECK_ACCESS(val_ptr);
32599         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
32600         if (val_conv.free == LDKLogger_JCalls_free) {
32601                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32602                 LDKLogger_JCalls_cloned(&val_conv);
32603         }
32604         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
32605 }
32606
32607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32608         LDKChannelManagerReadArgs this_ptr_conv;
32609         this_ptr_conv.inner = untag_ptr(this_ptr);
32610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32612         this_ptr_conv.is_owned = false;
32613         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
32614         int64_t ret_ref = 0;
32615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32617         return ret_ref;
32618 }
32619
32620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32621         LDKChannelManagerReadArgs this_ptr_conv;
32622         this_ptr_conv.inner = untag_ptr(this_ptr);
32623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32625         this_ptr_conv.is_owned = false;
32626         LDKUserConfig val_conv;
32627         val_conv.inner = untag_ptr(val);
32628         val_conv.is_owned = ptr_is_owned(val);
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32630         val_conv = UserConfig_clone(&val_conv);
32631         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
32632 }
32633
32634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
32635         void* keys_manager_ptr = untag_ptr(keys_manager);
32636         CHECK_ACCESS(keys_manager_ptr);
32637         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32638         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32640                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32641         }
32642         void* fee_estimator_ptr = untag_ptr(fee_estimator);
32643         CHECK_ACCESS(fee_estimator_ptr);
32644         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
32645         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
32646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32647                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
32648         }
32649         void* chain_monitor_ptr = untag_ptr(chain_monitor);
32650         CHECK_ACCESS(chain_monitor_ptr);
32651         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
32652         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
32653                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32654                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
32655         }
32656         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
32657         CHECK_ACCESS(tx_broadcaster_ptr);
32658         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
32659         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32661                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
32662         }
32663         void* logger_ptr = untag_ptr(logger);
32664         CHECK_ACCESS(logger_ptr);
32665         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32666         if (logger_conv.free == LDKLogger_JCalls_free) {
32667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32668                 LDKLogger_JCalls_cloned(&logger_conv);
32669         }
32670         LDKUserConfig default_config_conv;
32671         default_config_conv.inner = untag_ptr(default_config);
32672         default_config_conv.is_owned = ptr_is_owned(default_config);
32673         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
32674         default_config_conv = UserConfig_clone(&default_config_conv);
32675         LDKCVec_ChannelMonitorZ channel_monitors_constr;
32676         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
32677         if (channel_monitors_constr.datalen > 0)
32678                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
32679         else
32680                 channel_monitors_constr.data = NULL;
32681         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
32682         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
32683                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
32684                 LDKChannelMonitor channel_monitors_conv_16_conv;
32685                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
32686                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
32687                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
32688                 channel_monitors_conv_16_conv.is_owned = false;
32689                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
32690         }
32691         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
32692         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
32693         int64_t ret_ref = 0;
32694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32696         return ret_ref;
32697 }
32698
32699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
32700         LDKu8slice ser_ref;
32701         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32702         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32703         LDKChannelManagerReadArgs arg_conv;
32704         arg_conv.inner = untag_ptr(arg);
32705         arg_conv.is_owned = ptr_is_owned(arg);
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32707         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
32708         
32709         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
32710         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
32711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32712         return tag_ptr(ret_conv, true);
32713 }
32714
32715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32716         LDKExpandedKey this_obj_conv;
32717         this_obj_conv.inner = untag_ptr(this_obj);
32718         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32720         ExpandedKey_free(this_obj_conv);
32721 }
32722
32723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
32724         unsigned char key_material_arr[32];
32725         CHECK((*env)->GetArrayLength(env, key_material) == 32);
32726         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
32727         unsigned char (*key_material_ref)[32] = &key_material_arr;
32728         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
32729         int64_t ret_ref = 0;
32730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32732         return ret_ref;
32733 }
32734
32735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
32736         LDKExpandedKey keys_conv;
32737         keys_conv.inner = untag_ptr(keys);
32738         keys_conv.is_owned = ptr_is_owned(keys);
32739         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32740         keys_conv.is_owned = false;
32741         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32742         CHECK_ACCESS(min_value_msat_ptr);
32743         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32744         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32745         void* keys_manager_ptr = untag_ptr(keys_manager);
32746         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
32747         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
32748         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
32749         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
32750         return tag_ptr(ret_conv, true);
32751 }
32752
32753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
32754         LDKExpandedKey keys_conv;
32755         keys_conv.inner = untag_ptr(keys);
32756         keys_conv.is_owned = ptr_is_owned(keys);
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32758         keys_conv.is_owned = false;
32759         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32760         CHECK_ACCESS(min_value_msat_ptr);
32761         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32762         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32763         LDKThirtyTwoBytes payment_hash_ref;
32764         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32765         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32766         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
32767         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
32768         return tag_ptr(ret_conv, true);
32769 }
32770
32771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32772         if (!ptr_is_owned(this_ptr)) return;
32773         void* this_ptr_ptr = untag_ptr(this_ptr);
32774         CHECK_ACCESS(this_ptr_ptr);
32775         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
32776         FREE(untag_ptr(this_ptr));
32777         DecodeError_free(this_ptr_conv);
32778 }
32779
32780 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
32781         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32782         *ret_copy = DecodeError_clone(arg);
32783         int64_t ret_ref = tag_ptr(ret_copy, true);
32784         return ret_ref;
32785 }
32786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32787         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
32788         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
32789         return ret_conv;
32790 }
32791
32792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32793         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
32794         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32795         *ret_copy = DecodeError_clone(orig_conv);
32796         int64_t ret_ref = tag_ptr(ret_copy, true);
32797         return ret_ref;
32798 }
32799
32800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
32801         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32802         *ret_copy = DecodeError_unknown_version();
32803         int64_t ret_ref = tag_ptr(ret_copy, true);
32804         return ret_ref;
32805 }
32806
32807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
32808         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32809         *ret_copy = DecodeError_unknown_required_feature();
32810         int64_t ret_ref = tag_ptr(ret_copy, true);
32811         return ret_ref;
32812 }
32813
32814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
32815         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32816         *ret_copy = DecodeError_invalid_value();
32817         int64_t ret_ref = tag_ptr(ret_copy, true);
32818         return ret_ref;
32819 }
32820
32821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
32822         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32823         *ret_copy = DecodeError_short_read();
32824         int64_t ret_ref = tag_ptr(ret_copy, true);
32825         return ret_ref;
32826 }
32827
32828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
32829         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32830         *ret_copy = DecodeError_bad_length_descriptor();
32831         int64_t ret_ref = tag_ptr(ret_copy, true);
32832         return ret_ref;
32833 }
32834
32835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
32836         LDKIOError a_conv = LDKIOError_from_java(env, a);
32837         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32838         *ret_copy = DecodeError_io(a_conv);
32839         int64_t ret_ref = tag_ptr(ret_copy, true);
32840         return ret_ref;
32841 }
32842
32843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
32844         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32845         *ret_copy = DecodeError_unsupported_compression();
32846         int64_t ret_ref = tag_ptr(ret_copy, true);
32847         return ret_ref;
32848 }
32849
32850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32851         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
32852         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
32853         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
32854         return ret_conv;
32855 }
32856
32857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32858         LDKInit this_obj_conv;
32859         this_obj_conv.inner = untag_ptr(this_obj);
32860         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32862         Init_free(this_obj_conv);
32863 }
32864
32865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32866         LDKInit this_ptr_conv;
32867         this_ptr_conv.inner = untag_ptr(this_ptr);
32868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32870         this_ptr_conv.is_owned = false;
32871         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
32872         int64_t ret_ref = 0;
32873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32875         return ret_ref;
32876 }
32877
32878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32879         LDKInit this_ptr_conv;
32880         this_ptr_conv.inner = untag_ptr(this_ptr);
32881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32883         this_ptr_conv.is_owned = false;
32884         LDKInitFeatures val_conv;
32885         val_conv.inner = untag_ptr(val);
32886         val_conv.is_owned = ptr_is_owned(val);
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32888         val_conv = InitFeatures_clone(&val_conv);
32889         Init_set_features(&this_ptr_conv, val_conv);
32890 }
32891
32892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
32893         LDKInit this_ptr_conv;
32894         this_ptr_conv.inner = untag_ptr(this_ptr);
32895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32897         this_ptr_conv.is_owned = false;
32898         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
32899         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
32900         int64_t ret_ref = tag_ptr(ret_copy, true);
32901         return ret_ref;
32902 }
32903
32904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32905         LDKInit this_ptr_conv;
32906         this_ptr_conv.inner = untag_ptr(this_ptr);
32907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32909         this_ptr_conv.is_owned = false;
32910         void* val_ptr = untag_ptr(val);
32911         CHECK_ACCESS(val_ptr);
32912         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
32913         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
32914         Init_set_remote_network_address(&this_ptr_conv, val_conv);
32915 }
32916
32917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t remote_network_address_arg) {
32918         LDKInitFeatures features_arg_conv;
32919         features_arg_conv.inner = untag_ptr(features_arg);
32920         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32922         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32923         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
32924         CHECK_ACCESS(remote_network_address_arg_ptr);
32925         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
32926         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
32927         int64_t ret_ref = 0;
32928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32930         return ret_ref;
32931 }
32932
32933 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
32934         LDKInit ret_var = Init_clone(arg);
32935         int64_t ret_ref = 0;
32936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32938         return ret_ref;
32939 }
32940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32941         LDKInit arg_conv;
32942         arg_conv.inner = untag_ptr(arg);
32943         arg_conv.is_owned = ptr_is_owned(arg);
32944         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32945         arg_conv.is_owned = false;
32946         int64_t ret_conv = Init_clone_ptr(&arg_conv);
32947         return ret_conv;
32948 }
32949
32950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32951         LDKInit orig_conv;
32952         orig_conv.inner = untag_ptr(orig);
32953         orig_conv.is_owned = ptr_is_owned(orig);
32954         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32955         orig_conv.is_owned = false;
32956         LDKInit ret_var = Init_clone(&orig_conv);
32957         int64_t ret_ref = 0;
32958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32960         return ret_ref;
32961 }
32962
32963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32964         LDKInit a_conv;
32965         a_conv.inner = untag_ptr(a);
32966         a_conv.is_owned = ptr_is_owned(a);
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32968         a_conv.is_owned = false;
32969         LDKInit b_conv;
32970         b_conv.inner = untag_ptr(b);
32971         b_conv.is_owned = ptr_is_owned(b);
32972         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32973         b_conv.is_owned = false;
32974         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
32975         return ret_conv;
32976 }
32977
32978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32979         LDKErrorMessage this_obj_conv;
32980         this_obj_conv.inner = untag_ptr(this_obj);
32981         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32983         ErrorMessage_free(this_obj_conv);
32984 }
32985
32986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32987         LDKErrorMessage this_ptr_conv;
32988         this_ptr_conv.inner = untag_ptr(this_ptr);
32989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32991         this_ptr_conv.is_owned = false;
32992         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
32994         return ret_arr;
32995 }
32996
32997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32998         LDKErrorMessage this_ptr_conv;
32999         this_ptr_conv.inner = untag_ptr(this_ptr);
33000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33002         this_ptr_conv.is_owned = false;
33003         LDKThirtyTwoBytes val_ref;
33004         CHECK((*env)->GetArrayLength(env, val) == 32);
33005         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33006         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
33007 }
33008
33009 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
33010         LDKErrorMessage this_ptr_conv;
33011         this_ptr_conv.inner = untag_ptr(this_ptr);
33012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33014         this_ptr_conv.is_owned = false;
33015         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
33016         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33017         Str_free(ret_str);
33018         return ret_conv;
33019 }
33020
33021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
33022         LDKErrorMessage this_ptr_conv;
33023         this_ptr_conv.inner = untag_ptr(this_ptr);
33024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33026         this_ptr_conv.is_owned = false;
33027         LDKStr val_conv = java_to_owned_str(env, val);
33028         ErrorMessage_set_data(&this_ptr_conv, val_conv);
33029 }
33030
33031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
33032         LDKThirtyTwoBytes channel_id_arg_ref;
33033         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33034         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33035         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
33036         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
33037         int64_t ret_ref = 0;
33038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33040         return ret_ref;
33041 }
33042
33043 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
33044         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
33045         int64_t ret_ref = 0;
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33048         return ret_ref;
33049 }
33050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33051         LDKErrorMessage arg_conv;
33052         arg_conv.inner = untag_ptr(arg);
33053         arg_conv.is_owned = ptr_is_owned(arg);
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33055         arg_conv.is_owned = false;
33056         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
33057         return ret_conv;
33058 }
33059
33060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33061         LDKErrorMessage orig_conv;
33062         orig_conv.inner = untag_ptr(orig);
33063         orig_conv.is_owned = ptr_is_owned(orig);
33064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33065         orig_conv.is_owned = false;
33066         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
33067         int64_t ret_ref = 0;
33068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33070         return ret_ref;
33071 }
33072
33073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33074         LDKErrorMessage a_conv;
33075         a_conv.inner = untag_ptr(a);
33076         a_conv.is_owned = ptr_is_owned(a);
33077         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33078         a_conv.is_owned = false;
33079         LDKErrorMessage b_conv;
33080         b_conv.inner = untag_ptr(b);
33081         b_conv.is_owned = ptr_is_owned(b);
33082         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33083         b_conv.is_owned = false;
33084         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
33085         return ret_conv;
33086 }
33087
33088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33089         LDKWarningMessage this_obj_conv;
33090         this_obj_conv.inner = untag_ptr(this_obj);
33091         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33093         WarningMessage_free(this_obj_conv);
33094 }
33095
33096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33097         LDKWarningMessage this_ptr_conv;
33098         this_ptr_conv.inner = untag_ptr(this_ptr);
33099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33101         this_ptr_conv.is_owned = false;
33102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
33104         return ret_arr;
33105 }
33106
33107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33108         LDKWarningMessage this_ptr_conv;
33109         this_ptr_conv.inner = untag_ptr(this_ptr);
33110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33112         this_ptr_conv.is_owned = false;
33113         LDKThirtyTwoBytes val_ref;
33114         CHECK((*env)->GetArrayLength(env, val) == 32);
33115         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33116         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
33117 }
33118
33119 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
33120         LDKWarningMessage this_ptr_conv;
33121         this_ptr_conv.inner = untag_ptr(this_ptr);
33122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33124         this_ptr_conv.is_owned = false;
33125         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
33126         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33127         Str_free(ret_str);
33128         return ret_conv;
33129 }
33130
33131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
33132         LDKWarningMessage this_ptr_conv;
33133         this_ptr_conv.inner = untag_ptr(this_ptr);
33134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33136         this_ptr_conv.is_owned = false;
33137         LDKStr val_conv = java_to_owned_str(env, val);
33138         WarningMessage_set_data(&this_ptr_conv, val_conv);
33139 }
33140
33141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
33142         LDKThirtyTwoBytes channel_id_arg_ref;
33143         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33144         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33145         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
33146         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
33147         int64_t ret_ref = 0;
33148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33150         return ret_ref;
33151 }
33152
33153 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
33154         LDKWarningMessage ret_var = WarningMessage_clone(arg);
33155         int64_t ret_ref = 0;
33156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33158         return ret_ref;
33159 }
33160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33161         LDKWarningMessage arg_conv;
33162         arg_conv.inner = untag_ptr(arg);
33163         arg_conv.is_owned = ptr_is_owned(arg);
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33165         arg_conv.is_owned = false;
33166         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
33167         return ret_conv;
33168 }
33169
33170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33171         LDKWarningMessage orig_conv;
33172         orig_conv.inner = untag_ptr(orig);
33173         orig_conv.is_owned = ptr_is_owned(orig);
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33175         orig_conv.is_owned = false;
33176         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
33177         int64_t ret_ref = 0;
33178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33180         return ret_ref;
33181 }
33182
33183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33184         LDKWarningMessage a_conv;
33185         a_conv.inner = untag_ptr(a);
33186         a_conv.is_owned = ptr_is_owned(a);
33187         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33188         a_conv.is_owned = false;
33189         LDKWarningMessage b_conv;
33190         b_conv.inner = untag_ptr(b);
33191         b_conv.is_owned = ptr_is_owned(b);
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33193         b_conv.is_owned = false;
33194         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
33195         return ret_conv;
33196 }
33197
33198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33199         LDKPing this_obj_conv;
33200         this_obj_conv.inner = untag_ptr(this_obj);
33201         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33203         Ping_free(this_obj_conv);
33204 }
33205
33206 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33207         LDKPing this_ptr_conv;
33208         this_ptr_conv.inner = untag_ptr(this_ptr);
33209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33211         this_ptr_conv.is_owned = false;
33212         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
33213         return ret_conv;
33214 }
33215
33216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33217         LDKPing this_ptr_conv;
33218         this_ptr_conv.inner = untag_ptr(this_ptr);
33219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33221         this_ptr_conv.is_owned = false;
33222         Ping_set_ponglen(&this_ptr_conv, val);
33223 }
33224
33225 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33226         LDKPing this_ptr_conv;
33227         this_ptr_conv.inner = untag_ptr(this_ptr);
33228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33230         this_ptr_conv.is_owned = false;
33231         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
33232         return ret_conv;
33233 }
33234
33235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33236         LDKPing this_ptr_conv;
33237         this_ptr_conv.inner = untag_ptr(this_ptr);
33238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33240         this_ptr_conv.is_owned = false;
33241         Ping_set_byteslen(&this_ptr_conv, val);
33242 }
33243
33244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
33245         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
33246         int64_t ret_ref = 0;
33247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33249         return ret_ref;
33250 }
33251
33252 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
33253         LDKPing ret_var = Ping_clone(arg);
33254         int64_t ret_ref = 0;
33255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33257         return ret_ref;
33258 }
33259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33260         LDKPing arg_conv;
33261         arg_conv.inner = untag_ptr(arg);
33262         arg_conv.is_owned = ptr_is_owned(arg);
33263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33264         arg_conv.is_owned = false;
33265         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
33266         return ret_conv;
33267 }
33268
33269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33270         LDKPing orig_conv;
33271         orig_conv.inner = untag_ptr(orig);
33272         orig_conv.is_owned = ptr_is_owned(orig);
33273         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33274         orig_conv.is_owned = false;
33275         LDKPing ret_var = Ping_clone(&orig_conv);
33276         int64_t ret_ref = 0;
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33279         return ret_ref;
33280 }
33281
33282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33283         LDKPing a_conv;
33284         a_conv.inner = untag_ptr(a);
33285         a_conv.is_owned = ptr_is_owned(a);
33286         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33287         a_conv.is_owned = false;
33288         LDKPing b_conv;
33289         b_conv.inner = untag_ptr(b);
33290         b_conv.is_owned = ptr_is_owned(b);
33291         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33292         b_conv.is_owned = false;
33293         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
33294         return ret_conv;
33295 }
33296
33297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33298         LDKPong this_obj_conv;
33299         this_obj_conv.inner = untag_ptr(this_obj);
33300         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33302         Pong_free(this_obj_conv);
33303 }
33304
33305 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33306         LDKPong this_ptr_conv;
33307         this_ptr_conv.inner = untag_ptr(this_ptr);
33308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33310         this_ptr_conv.is_owned = false;
33311         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
33312         return ret_conv;
33313 }
33314
33315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33316         LDKPong this_ptr_conv;
33317         this_ptr_conv.inner = untag_ptr(this_ptr);
33318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33320         this_ptr_conv.is_owned = false;
33321         Pong_set_byteslen(&this_ptr_conv, val);
33322 }
33323
33324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
33325         LDKPong ret_var = Pong_new(byteslen_arg);
33326         int64_t ret_ref = 0;
33327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33329         return ret_ref;
33330 }
33331
33332 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
33333         LDKPong ret_var = Pong_clone(arg);
33334         int64_t ret_ref = 0;
33335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33336         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33337         return ret_ref;
33338 }
33339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33340         LDKPong arg_conv;
33341         arg_conv.inner = untag_ptr(arg);
33342         arg_conv.is_owned = ptr_is_owned(arg);
33343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33344         arg_conv.is_owned = false;
33345         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
33346         return ret_conv;
33347 }
33348
33349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33350         LDKPong orig_conv;
33351         orig_conv.inner = untag_ptr(orig);
33352         orig_conv.is_owned = ptr_is_owned(orig);
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33354         orig_conv.is_owned = false;
33355         LDKPong ret_var = Pong_clone(&orig_conv);
33356         int64_t ret_ref = 0;
33357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33359         return ret_ref;
33360 }
33361
33362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33363         LDKPong a_conv;
33364         a_conv.inner = untag_ptr(a);
33365         a_conv.is_owned = ptr_is_owned(a);
33366         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33367         a_conv.is_owned = false;
33368         LDKPong b_conv;
33369         b_conv.inner = untag_ptr(b);
33370         b_conv.is_owned = ptr_is_owned(b);
33371         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33372         b_conv.is_owned = false;
33373         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
33374         return ret_conv;
33375 }
33376
33377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33378         LDKOpenChannel this_obj_conv;
33379         this_obj_conv.inner = untag_ptr(this_obj);
33380         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33382         OpenChannel_free(this_obj_conv);
33383 }
33384
33385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33386         LDKOpenChannel this_ptr_conv;
33387         this_ptr_conv.inner = untag_ptr(this_ptr);
33388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33390         this_ptr_conv.is_owned = false;
33391         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
33393         return ret_arr;
33394 }
33395
33396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33397         LDKOpenChannel this_ptr_conv;
33398         this_ptr_conv.inner = untag_ptr(this_ptr);
33399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33401         this_ptr_conv.is_owned = false;
33402         LDKThirtyTwoBytes val_ref;
33403         CHECK((*env)->GetArrayLength(env, val) == 32);
33404         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33405         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
33406 }
33407
33408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33409         LDKOpenChannel this_ptr_conv;
33410         this_ptr_conv.inner = untag_ptr(this_ptr);
33411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33413         this_ptr_conv.is_owned = false;
33414         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
33416         return ret_arr;
33417 }
33418
33419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33420         LDKOpenChannel this_ptr_conv;
33421         this_ptr_conv.inner = untag_ptr(this_ptr);
33422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33424         this_ptr_conv.is_owned = false;
33425         LDKThirtyTwoBytes val_ref;
33426         CHECK((*env)->GetArrayLength(env, val) == 32);
33427         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33428         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
33429 }
33430
33431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33432         LDKOpenChannel this_ptr_conv;
33433         this_ptr_conv.inner = untag_ptr(this_ptr);
33434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33436         this_ptr_conv.is_owned = false;
33437         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
33438         return ret_conv;
33439 }
33440
33441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33442         LDKOpenChannel this_ptr_conv;
33443         this_ptr_conv.inner = untag_ptr(this_ptr);
33444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33446         this_ptr_conv.is_owned = false;
33447         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
33448 }
33449
33450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33451         LDKOpenChannel this_ptr_conv;
33452         this_ptr_conv.inner = untag_ptr(this_ptr);
33453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33455         this_ptr_conv.is_owned = false;
33456         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
33457         return ret_conv;
33458 }
33459
33460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33461         LDKOpenChannel this_ptr_conv;
33462         this_ptr_conv.inner = untag_ptr(this_ptr);
33463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33465         this_ptr_conv.is_owned = false;
33466         OpenChannel_set_push_msat(&this_ptr_conv, val);
33467 }
33468
33469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33470         LDKOpenChannel this_ptr_conv;
33471         this_ptr_conv.inner = untag_ptr(this_ptr);
33472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33474         this_ptr_conv.is_owned = false;
33475         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
33476         return ret_conv;
33477 }
33478
33479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33480         LDKOpenChannel this_ptr_conv;
33481         this_ptr_conv.inner = untag_ptr(this_ptr);
33482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33484         this_ptr_conv.is_owned = false;
33485         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
33486 }
33487
33488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33489         LDKOpenChannel this_ptr_conv;
33490         this_ptr_conv.inner = untag_ptr(this_ptr);
33491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33493         this_ptr_conv.is_owned = false;
33494         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
33495         return ret_conv;
33496 }
33497
33498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33499         LDKOpenChannel this_ptr_conv;
33500         this_ptr_conv.inner = untag_ptr(this_ptr);
33501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33503         this_ptr_conv.is_owned = false;
33504         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
33505 }
33506
33507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33508         LDKOpenChannel this_ptr_conv;
33509         this_ptr_conv.inner = untag_ptr(this_ptr);
33510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33512         this_ptr_conv.is_owned = false;
33513         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
33514         return ret_conv;
33515 }
33516
33517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33518         LDKOpenChannel this_ptr_conv;
33519         this_ptr_conv.inner = untag_ptr(this_ptr);
33520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33522         this_ptr_conv.is_owned = false;
33523         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
33524 }
33525
33526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33527         LDKOpenChannel this_ptr_conv;
33528         this_ptr_conv.inner = untag_ptr(this_ptr);
33529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33531         this_ptr_conv.is_owned = false;
33532         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
33533         return ret_conv;
33534 }
33535
33536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33537         LDKOpenChannel this_ptr_conv;
33538         this_ptr_conv.inner = untag_ptr(this_ptr);
33539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33541         this_ptr_conv.is_owned = false;
33542         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
33543 }
33544
33545 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33546         LDKOpenChannel this_ptr_conv;
33547         this_ptr_conv.inner = untag_ptr(this_ptr);
33548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33550         this_ptr_conv.is_owned = false;
33551         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
33552         return ret_conv;
33553 }
33554
33555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33556         LDKOpenChannel this_ptr_conv;
33557         this_ptr_conv.inner = untag_ptr(this_ptr);
33558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33560         this_ptr_conv.is_owned = false;
33561         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
33562 }
33563
33564 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33565         LDKOpenChannel this_ptr_conv;
33566         this_ptr_conv.inner = untag_ptr(this_ptr);
33567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33569         this_ptr_conv.is_owned = false;
33570         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
33571         return ret_conv;
33572 }
33573
33574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33575         LDKOpenChannel this_ptr_conv;
33576         this_ptr_conv.inner = untag_ptr(this_ptr);
33577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33579         this_ptr_conv.is_owned = false;
33580         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
33581 }
33582
33583 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
33584         LDKOpenChannel this_ptr_conv;
33585         this_ptr_conv.inner = untag_ptr(this_ptr);
33586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33588         this_ptr_conv.is_owned = false;
33589         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
33590         return ret_conv;
33591 }
33592
33593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33594         LDKOpenChannel this_ptr_conv;
33595         this_ptr_conv.inner = untag_ptr(this_ptr);
33596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33598         this_ptr_conv.is_owned = false;
33599         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
33600 }
33601
33602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33603         LDKOpenChannel this_ptr_conv;
33604         this_ptr_conv.inner = untag_ptr(this_ptr);
33605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33607         this_ptr_conv.is_owned = false;
33608         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33609         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
33610         return ret_arr;
33611 }
33612
33613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33614         LDKOpenChannel this_ptr_conv;
33615         this_ptr_conv.inner = untag_ptr(this_ptr);
33616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33618         this_ptr_conv.is_owned = false;
33619         LDKPublicKey val_ref;
33620         CHECK((*env)->GetArrayLength(env, val) == 33);
33621         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33622         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
33623 }
33624
33625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33626         LDKOpenChannel this_ptr_conv;
33627         this_ptr_conv.inner = untag_ptr(this_ptr);
33628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33630         this_ptr_conv.is_owned = false;
33631         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
33633         return ret_arr;
33634 }
33635
33636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33637         LDKOpenChannel this_ptr_conv;
33638         this_ptr_conv.inner = untag_ptr(this_ptr);
33639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33641         this_ptr_conv.is_owned = false;
33642         LDKPublicKey val_ref;
33643         CHECK((*env)->GetArrayLength(env, val) == 33);
33644         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33645         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
33646 }
33647
33648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33649         LDKOpenChannel this_ptr_conv;
33650         this_ptr_conv.inner = untag_ptr(this_ptr);
33651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33653         this_ptr_conv.is_owned = false;
33654         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
33656         return ret_arr;
33657 }
33658
33659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33660         LDKOpenChannel this_ptr_conv;
33661         this_ptr_conv.inner = untag_ptr(this_ptr);
33662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33664         this_ptr_conv.is_owned = false;
33665         LDKPublicKey val_ref;
33666         CHECK((*env)->GetArrayLength(env, val) == 33);
33667         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33668         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
33669 }
33670
33671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33672         LDKOpenChannel this_ptr_conv;
33673         this_ptr_conv.inner = untag_ptr(this_ptr);
33674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33676         this_ptr_conv.is_owned = false;
33677         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33678         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
33679         return ret_arr;
33680 }
33681
33682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33683         LDKOpenChannel this_ptr_conv;
33684         this_ptr_conv.inner = untag_ptr(this_ptr);
33685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33687         this_ptr_conv.is_owned = false;
33688         LDKPublicKey val_ref;
33689         CHECK((*env)->GetArrayLength(env, val) == 33);
33690         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33691         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33692 }
33693
33694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33695         LDKOpenChannel this_ptr_conv;
33696         this_ptr_conv.inner = untag_ptr(this_ptr);
33697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33699         this_ptr_conv.is_owned = false;
33700         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33702         return ret_arr;
33703 }
33704
33705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33706         LDKOpenChannel this_ptr_conv;
33707         this_ptr_conv.inner = untag_ptr(this_ptr);
33708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33710         this_ptr_conv.is_owned = false;
33711         LDKPublicKey val_ref;
33712         CHECK((*env)->GetArrayLength(env, val) == 33);
33713         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33714         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33715 }
33716
33717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33718         LDKOpenChannel this_ptr_conv;
33719         this_ptr_conv.inner = untag_ptr(this_ptr);
33720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33722         this_ptr_conv.is_owned = false;
33723         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33725         return ret_arr;
33726 }
33727
33728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33729         LDKOpenChannel this_ptr_conv;
33730         this_ptr_conv.inner = untag_ptr(this_ptr);
33731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33733         this_ptr_conv.is_owned = false;
33734         LDKPublicKey val_ref;
33735         CHECK((*env)->GetArrayLength(env, val) == 33);
33736         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33737         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33738 }
33739
33740 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33741         LDKOpenChannel this_ptr_conv;
33742         this_ptr_conv.inner = untag_ptr(this_ptr);
33743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33745         this_ptr_conv.is_owned = false;
33746         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
33747         return ret_conv;
33748 }
33749
33750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33751         LDKOpenChannel this_ptr_conv;
33752         this_ptr_conv.inner = untag_ptr(this_ptr);
33753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33755         this_ptr_conv.is_owned = false;
33756         OpenChannel_set_channel_flags(&this_ptr_conv, val);
33757 }
33758
33759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33760         LDKOpenChannel this_ptr_conv;
33761         this_ptr_conv.inner = untag_ptr(this_ptr);
33762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33764         this_ptr_conv.is_owned = false;
33765         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
33766         int64_t ret_ref = 0;
33767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33769         return ret_ref;
33770 }
33771
33772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33773         LDKOpenChannel this_ptr_conv;
33774         this_ptr_conv.inner = untag_ptr(this_ptr);
33775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33777         this_ptr_conv.is_owned = false;
33778         LDKChannelTypeFeatures val_conv;
33779         val_conv.inner = untag_ptr(val);
33780         val_conv.is_owned = ptr_is_owned(val);
33781         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33782         val_conv = ChannelTypeFeatures_clone(&val_conv);
33783         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
33784 }
33785
33786 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
33787         LDKOpenChannel ret_var = OpenChannel_clone(arg);
33788         int64_t ret_ref = 0;
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33791         return ret_ref;
33792 }
33793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33794         LDKOpenChannel arg_conv;
33795         arg_conv.inner = untag_ptr(arg);
33796         arg_conv.is_owned = ptr_is_owned(arg);
33797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33798         arg_conv.is_owned = false;
33799         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
33800         return ret_conv;
33801 }
33802
33803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33804         LDKOpenChannel orig_conv;
33805         orig_conv.inner = untag_ptr(orig);
33806         orig_conv.is_owned = ptr_is_owned(orig);
33807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33808         orig_conv.is_owned = false;
33809         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
33810         int64_t ret_ref = 0;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33813         return ret_ref;
33814 }
33815
33816 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33817         LDKOpenChannel a_conv;
33818         a_conv.inner = untag_ptr(a);
33819         a_conv.is_owned = ptr_is_owned(a);
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33821         a_conv.is_owned = false;
33822         LDKOpenChannel b_conv;
33823         b_conv.inner = untag_ptr(b);
33824         b_conv.is_owned = ptr_is_owned(b);
33825         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33826         b_conv.is_owned = false;
33827         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
33828         return ret_conv;
33829 }
33830
33831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33832         LDKAcceptChannel this_obj_conv;
33833         this_obj_conv.inner = untag_ptr(this_obj);
33834         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33836         AcceptChannel_free(this_obj_conv);
33837 }
33838
33839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33840         LDKAcceptChannel this_ptr_conv;
33841         this_ptr_conv.inner = untag_ptr(this_ptr);
33842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33844         this_ptr_conv.is_owned = false;
33845         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33846         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
33847         return ret_arr;
33848 }
33849
33850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33851         LDKAcceptChannel this_ptr_conv;
33852         this_ptr_conv.inner = untag_ptr(this_ptr);
33853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33855         this_ptr_conv.is_owned = false;
33856         LDKThirtyTwoBytes val_ref;
33857         CHECK((*env)->GetArrayLength(env, val) == 32);
33858         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33859         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
33860 }
33861
33862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33863         LDKAcceptChannel this_ptr_conv;
33864         this_ptr_conv.inner = untag_ptr(this_ptr);
33865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33867         this_ptr_conv.is_owned = false;
33868         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
33869         return ret_conv;
33870 }
33871
33872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33873         LDKAcceptChannel this_ptr_conv;
33874         this_ptr_conv.inner = untag_ptr(this_ptr);
33875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33877         this_ptr_conv.is_owned = false;
33878         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
33879 }
33880
33881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33882         LDKAcceptChannel this_ptr_conv;
33883         this_ptr_conv.inner = untag_ptr(this_ptr);
33884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33886         this_ptr_conv.is_owned = false;
33887         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
33888         return ret_conv;
33889 }
33890
33891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33892         LDKAcceptChannel this_ptr_conv;
33893         this_ptr_conv.inner = untag_ptr(this_ptr);
33894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33896         this_ptr_conv.is_owned = false;
33897         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
33898 }
33899
33900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33901         LDKAcceptChannel this_ptr_conv;
33902         this_ptr_conv.inner = untag_ptr(this_ptr);
33903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33905         this_ptr_conv.is_owned = false;
33906         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
33907         return ret_conv;
33908 }
33909
33910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33911         LDKAcceptChannel this_ptr_conv;
33912         this_ptr_conv.inner = untag_ptr(this_ptr);
33913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33915         this_ptr_conv.is_owned = false;
33916         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
33917 }
33918
33919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33920         LDKAcceptChannel this_ptr_conv;
33921         this_ptr_conv.inner = untag_ptr(this_ptr);
33922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33924         this_ptr_conv.is_owned = false;
33925         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
33926         return ret_conv;
33927 }
33928
33929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33930         LDKAcceptChannel this_ptr_conv;
33931         this_ptr_conv.inner = untag_ptr(this_ptr);
33932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33934         this_ptr_conv.is_owned = false;
33935         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
33936 }
33937
33938 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
33939         LDKAcceptChannel this_ptr_conv;
33940         this_ptr_conv.inner = untag_ptr(this_ptr);
33941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33943         this_ptr_conv.is_owned = false;
33944         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
33945         return ret_conv;
33946 }
33947
33948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33949         LDKAcceptChannel this_ptr_conv;
33950         this_ptr_conv.inner = untag_ptr(this_ptr);
33951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33953         this_ptr_conv.is_owned = false;
33954         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
33955 }
33956
33957 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33958         LDKAcceptChannel this_ptr_conv;
33959         this_ptr_conv.inner = untag_ptr(this_ptr);
33960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33962         this_ptr_conv.is_owned = false;
33963         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
33964         return ret_conv;
33965 }
33966
33967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33968         LDKAcceptChannel this_ptr_conv;
33969         this_ptr_conv.inner = untag_ptr(this_ptr);
33970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33972         this_ptr_conv.is_owned = false;
33973         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
33974 }
33975
33976 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
33977         LDKAcceptChannel this_ptr_conv;
33978         this_ptr_conv.inner = untag_ptr(this_ptr);
33979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33981         this_ptr_conv.is_owned = false;
33982         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
33983         return ret_conv;
33984 }
33985
33986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33987         LDKAcceptChannel this_ptr_conv;
33988         this_ptr_conv.inner = untag_ptr(this_ptr);
33989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33991         this_ptr_conv.is_owned = false;
33992         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
33993 }
33994
33995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33996         LDKAcceptChannel this_ptr_conv;
33997         this_ptr_conv.inner = untag_ptr(this_ptr);
33998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34000         this_ptr_conv.is_owned = false;
34001         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
34003         return ret_arr;
34004 }
34005
34006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34007         LDKAcceptChannel this_ptr_conv;
34008         this_ptr_conv.inner = untag_ptr(this_ptr);
34009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34011         this_ptr_conv.is_owned = false;
34012         LDKPublicKey val_ref;
34013         CHECK((*env)->GetArrayLength(env, val) == 33);
34014         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34015         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
34016 }
34017
34018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34019         LDKAcceptChannel this_ptr_conv;
34020         this_ptr_conv.inner = untag_ptr(this_ptr);
34021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34023         this_ptr_conv.is_owned = false;
34024         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34025         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
34026         return ret_arr;
34027 }
34028
34029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34030         LDKAcceptChannel this_ptr_conv;
34031         this_ptr_conv.inner = untag_ptr(this_ptr);
34032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34034         this_ptr_conv.is_owned = false;
34035         LDKPublicKey val_ref;
34036         CHECK((*env)->GetArrayLength(env, val) == 33);
34037         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34038         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
34039 }
34040
34041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34042         LDKAcceptChannel this_ptr_conv;
34043         this_ptr_conv.inner = untag_ptr(this_ptr);
34044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34046         this_ptr_conv.is_owned = false;
34047         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
34049         return ret_arr;
34050 }
34051
34052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34053         LDKAcceptChannel this_ptr_conv;
34054         this_ptr_conv.inner = untag_ptr(this_ptr);
34055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34057         this_ptr_conv.is_owned = false;
34058         LDKPublicKey val_ref;
34059         CHECK((*env)->GetArrayLength(env, val) == 33);
34060         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34061         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
34062 }
34063
34064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34065         LDKAcceptChannel this_ptr_conv;
34066         this_ptr_conv.inner = untag_ptr(this_ptr);
34067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34069         this_ptr_conv.is_owned = false;
34070         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
34072         return ret_arr;
34073 }
34074
34075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34076         LDKAcceptChannel this_ptr_conv;
34077         this_ptr_conv.inner = untag_ptr(this_ptr);
34078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34080         this_ptr_conv.is_owned = false;
34081         LDKPublicKey val_ref;
34082         CHECK((*env)->GetArrayLength(env, val) == 33);
34083         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34084         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34085 }
34086
34087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34088         LDKAcceptChannel this_ptr_conv;
34089         this_ptr_conv.inner = untag_ptr(this_ptr);
34090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34092         this_ptr_conv.is_owned = false;
34093         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
34095         return ret_arr;
34096 }
34097
34098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34099         LDKAcceptChannel this_ptr_conv;
34100         this_ptr_conv.inner = untag_ptr(this_ptr);
34101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34103         this_ptr_conv.is_owned = false;
34104         LDKPublicKey val_ref;
34105         CHECK((*env)->GetArrayLength(env, val) == 33);
34106         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34107         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
34108 }
34109
34110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34111         LDKAcceptChannel this_ptr_conv;
34112         this_ptr_conv.inner = untag_ptr(this_ptr);
34113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34115         this_ptr_conv.is_owned = false;
34116         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
34118         return ret_arr;
34119 }
34120
34121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34122         LDKAcceptChannel this_ptr_conv;
34123         this_ptr_conv.inner = untag_ptr(this_ptr);
34124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34126         this_ptr_conv.is_owned = false;
34127         LDKPublicKey val_ref;
34128         CHECK((*env)->GetArrayLength(env, val) == 33);
34129         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34130         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
34131 }
34132
34133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
34134         LDKAcceptChannel this_ptr_conv;
34135         this_ptr_conv.inner = untag_ptr(this_ptr);
34136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34138         this_ptr_conv.is_owned = false;
34139         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
34140         int64_t ret_ref = 0;
34141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34143         return ret_ref;
34144 }
34145
34146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34147         LDKAcceptChannel this_ptr_conv;
34148         this_ptr_conv.inner = untag_ptr(this_ptr);
34149         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34151         this_ptr_conv.is_owned = false;
34152         LDKChannelTypeFeatures val_conv;
34153         val_conv.inner = untag_ptr(val);
34154         val_conv.is_owned = ptr_is_owned(val);
34155         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34156         val_conv = ChannelTypeFeatures_clone(&val_conv);
34157         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
34158 }
34159
34160 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
34161         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
34162         int64_t ret_ref = 0;
34163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34165         return ret_ref;
34166 }
34167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34168         LDKAcceptChannel arg_conv;
34169         arg_conv.inner = untag_ptr(arg);
34170         arg_conv.is_owned = ptr_is_owned(arg);
34171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34172         arg_conv.is_owned = false;
34173         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
34174         return ret_conv;
34175 }
34176
34177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34178         LDKAcceptChannel orig_conv;
34179         orig_conv.inner = untag_ptr(orig);
34180         orig_conv.is_owned = ptr_is_owned(orig);
34181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34182         orig_conv.is_owned = false;
34183         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
34184         int64_t ret_ref = 0;
34185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34187         return ret_ref;
34188 }
34189
34190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34191         LDKAcceptChannel a_conv;
34192         a_conv.inner = untag_ptr(a);
34193         a_conv.is_owned = ptr_is_owned(a);
34194         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34195         a_conv.is_owned = false;
34196         LDKAcceptChannel b_conv;
34197         b_conv.inner = untag_ptr(b);
34198         b_conv.is_owned = ptr_is_owned(b);
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34200         b_conv.is_owned = false;
34201         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
34202         return ret_conv;
34203 }
34204
34205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34206         LDKFundingCreated this_obj_conv;
34207         this_obj_conv.inner = untag_ptr(this_obj);
34208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34210         FundingCreated_free(this_obj_conv);
34211 }
34212
34213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34214         LDKFundingCreated this_ptr_conv;
34215         this_ptr_conv.inner = untag_ptr(this_ptr);
34216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34218         this_ptr_conv.is_owned = false;
34219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
34221         return ret_arr;
34222 }
34223
34224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34225         LDKFundingCreated this_ptr_conv;
34226         this_ptr_conv.inner = untag_ptr(this_ptr);
34227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34229         this_ptr_conv.is_owned = false;
34230         LDKThirtyTwoBytes val_ref;
34231         CHECK((*env)->GetArrayLength(env, val) == 32);
34232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34233         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
34234 }
34235
34236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
34237         LDKFundingCreated this_ptr_conv;
34238         this_ptr_conv.inner = untag_ptr(this_ptr);
34239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34241         this_ptr_conv.is_owned = false;
34242         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34243         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
34244         return ret_arr;
34245 }
34246
34247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34248         LDKFundingCreated this_ptr_conv;
34249         this_ptr_conv.inner = untag_ptr(this_ptr);
34250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34252         this_ptr_conv.is_owned = false;
34253         LDKThirtyTwoBytes val_ref;
34254         CHECK((*env)->GetArrayLength(env, val) == 32);
34255         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34256         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
34257 }
34258
34259 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
34260         LDKFundingCreated this_ptr_conv;
34261         this_ptr_conv.inner = untag_ptr(this_ptr);
34262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34264         this_ptr_conv.is_owned = false;
34265         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
34266         return ret_conv;
34267 }
34268
34269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34270         LDKFundingCreated this_ptr_conv;
34271         this_ptr_conv.inner = untag_ptr(this_ptr);
34272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34274         this_ptr_conv.is_owned = false;
34275         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
34276 }
34277
34278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34279         LDKFundingCreated this_ptr_conv;
34280         this_ptr_conv.inner = untag_ptr(this_ptr);
34281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34283         this_ptr_conv.is_owned = false;
34284         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34285         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
34286         return ret_arr;
34287 }
34288
34289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34290         LDKFundingCreated this_ptr_conv;
34291         this_ptr_conv.inner = untag_ptr(this_ptr);
34292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34294         this_ptr_conv.is_owned = false;
34295         LDKSignature val_ref;
34296         CHECK((*env)->GetArrayLength(env, val) == 64);
34297         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34298         FundingCreated_set_signature(&this_ptr_conv, val_ref);
34299 }
34300
34301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
34302         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
34303         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
34304         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
34305         LDKThirtyTwoBytes funding_txid_arg_ref;
34306         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
34307         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
34308         LDKSignature signature_arg_ref;
34309         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34310         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34311         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
34312         int64_t ret_ref = 0;
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34315         return ret_ref;
34316 }
34317
34318 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
34319         LDKFundingCreated ret_var = FundingCreated_clone(arg);
34320         int64_t ret_ref = 0;
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34322         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34323         return ret_ref;
34324 }
34325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34326         LDKFundingCreated arg_conv;
34327         arg_conv.inner = untag_ptr(arg);
34328         arg_conv.is_owned = ptr_is_owned(arg);
34329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34330         arg_conv.is_owned = false;
34331         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
34332         return ret_conv;
34333 }
34334
34335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34336         LDKFundingCreated orig_conv;
34337         orig_conv.inner = untag_ptr(orig);
34338         orig_conv.is_owned = ptr_is_owned(orig);
34339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34340         orig_conv.is_owned = false;
34341         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
34342         int64_t ret_ref = 0;
34343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34345         return ret_ref;
34346 }
34347
34348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34349         LDKFundingCreated a_conv;
34350         a_conv.inner = untag_ptr(a);
34351         a_conv.is_owned = ptr_is_owned(a);
34352         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34353         a_conv.is_owned = false;
34354         LDKFundingCreated b_conv;
34355         b_conv.inner = untag_ptr(b);
34356         b_conv.is_owned = ptr_is_owned(b);
34357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34358         b_conv.is_owned = false;
34359         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
34360         return ret_conv;
34361 }
34362
34363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34364         LDKFundingSigned this_obj_conv;
34365         this_obj_conv.inner = untag_ptr(this_obj);
34366         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34368         FundingSigned_free(this_obj_conv);
34369 }
34370
34371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34372         LDKFundingSigned this_ptr_conv;
34373         this_ptr_conv.inner = untag_ptr(this_ptr);
34374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34376         this_ptr_conv.is_owned = false;
34377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
34379         return ret_arr;
34380 }
34381
34382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34383         LDKFundingSigned this_ptr_conv;
34384         this_ptr_conv.inner = untag_ptr(this_ptr);
34385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34387         this_ptr_conv.is_owned = false;
34388         LDKThirtyTwoBytes val_ref;
34389         CHECK((*env)->GetArrayLength(env, val) == 32);
34390         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34391         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
34392 }
34393
34394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34395         LDKFundingSigned this_ptr_conv;
34396         this_ptr_conv.inner = untag_ptr(this_ptr);
34397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34399         this_ptr_conv.is_owned = false;
34400         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34401         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
34402         return ret_arr;
34403 }
34404
34405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34406         LDKFundingSigned this_ptr_conv;
34407         this_ptr_conv.inner = untag_ptr(this_ptr);
34408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34410         this_ptr_conv.is_owned = false;
34411         LDKSignature val_ref;
34412         CHECK((*env)->GetArrayLength(env, val) == 64);
34413         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34414         FundingSigned_set_signature(&this_ptr_conv, val_ref);
34415 }
34416
34417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
34418         LDKThirtyTwoBytes channel_id_arg_ref;
34419         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34420         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34421         LDKSignature signature_arg_ref;
34422         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34423         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34424         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
34425         int64_t ret_ref = 0;
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34428         return ret_ref;
34429 }
34430
34431 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
34432         LDKFundingSigned ret_var = FundingSigned_clone(arg);
34433         int64_t ret_ref = 0;
34434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34436         return ret_ref;
34437 }
34438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34439         LDKFundingSigned arg_conv;
34440         arg_conv.inner = untag_ptr(arg);
34441         arg_conv.is_owned = ptr_is_owned(arg);
34442         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34443         arg_conv.is_owned = false;
34444         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
34445         return ret_conv;
34446 }
34447
34448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34449         LDKFundingSigned orig_conv;
34450         orig_conv.inner = untag_ptr(orig);
34451         orig_conv.is_owned = ptr_is_owned(orig);
34452         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34453         orig_conv.is_owned = false;
34454         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
34455         int64_t ret_ref = 0;
34456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34458         return ret_ref;
34459 }
34460
34461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34462         LDKFundingSigned a_conv;
34463         a_conv.inner = untag_ptr(a);
34464         a_conv.is_owned = ptr_is_owned(a);
34465         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34466         a_conv.is_owned = false;
34467         LDKFundingSigned b_conv;
34468         b_conv.inner = untag_ptr(b);
34469         b_conv.is_owned = ptr_is_owned(b);
34470         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34471         b_conv.is_owned = false;
34472         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
34473         return ret_conv;
34474 }
34475
34476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34477         LDKChannelReady this_obj_conv;
34478         this_obj_conv.inner = untag_ptr(this_obj);
34479         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34481         ChannelReady_free(this_obj_conv);
34482 }
34483
34484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34485         LDKChannelReady this_ptr_conv;
34486         this_ptr_conv.inner = untag_ptr(this_ptr);
34487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34489         this_ptr_conv.is_owned = false;
34490         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
34492         return ret_arr;
34493 }
34494
34495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34496         LDKChannelReady this_ptr_conv;
34497         this_ptr_conv.inner = untag_ptr(this_ptr);
34498         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34500         this_ptr_conv.is_owned = false;
34501         LDKThirtyTwoBytes val_ref;
34502         CHECK((*env)->GetArrayLength(env, val) == 32);
34503         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34504         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
34505 }
34506
34507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34508         LDKChannelReady this_ptr_conv;
34509         this_ptr_conv.inner = untag_ptr(this_ptr);
34510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34512         this_ptr_conv.is_owned = false;
34513         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34515         return ret_arr;
34516 }
34517
34518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34519         LDKChannelReady this_ptr_conv;
34520         this_ptr_conv.inner = untag_ptr(this_ptr);
34521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         this_ptr_conv.is_owned = false;
34524         LDKPublicKey val_ref;
34525         CHECK((*env)->GetArrayLength(env, val) == 33);
34526         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34527         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34528 }
34529
34530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
34531         LDKChannelReady this_ptr_conv;
34532         this_ptr_conv.inner = untag_ptr(this_ptr);
34533         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34535         this_ptr_conv.is_owned = false;
34536         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34537         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
34538         int64_t ret_ref = tag_ptr(ret_copy, true);
34539         return ret_ref;
34540 }
34541
34542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34543         LDKChannelReady this_ptr_conv;
34544         this_ptr_conv.inner = untag_ptr(this_ptr);
34545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34547         this_ptr_conv.is_owned = false;
34548         void* val_ptr = untag_ptr(val);
34549         CHECK_ACCESS(val_ptr);
34550         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34551         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34552         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
34553 }
34554
34555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
34556         LDKThirtyTwoBytes channel_id_arg_ref;
34557         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34558         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34559         LDKPublicKey next_per_commitment_point_arg_ref;
34560         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34561         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34562         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
34563         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
34564         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
34565         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
34566         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
34567         int64_t ret_ref = 0;
34568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34569         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34570         return ret_ref;
34571 }
34572
34573 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
34574         LDKChannelReady ret_var = ChannelReady_clone(arg);
34575         int64_t ret_ref = 0;
34576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34578         return ret_ref;
34579 }
34580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34581         LDKChannelReady arg_conv;
34582         arg_conv.inner = untag_ptr(arg);
34583         arg_conv.is_owned = ptr_is_owned(arg);
34584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34585         arg_conv.is_owned = false;
34586         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
34587         return ret_conv;
34588 }
34589
34590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34591         LDKChannelReady orig_conv;
34592         orig_conv.inner = untag_ptr(orig);
34593         orig_conv.is_owned = ptr_is_owned(orig);
34594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34595         orig_conv.is_owned = false;
34596         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
34597         int64_t ret_ref = 0;
34598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34600         return ret_ref;
34601 }
34602
34603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34604         LDKChannelReady a_conv;
34605         a_conv.inner = untag_ptr(a);
34606         a_conv.is_owned = ptr_is_owned(a);
34607         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34608         a_conv.is_owned = false;
34609         LDKChannelReady b_conv;
34610         b_conv.inner = untag_ptr(b);
34611         b_conv.is_owned = ptr_is_owned(b);
34612         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34613         b_conv.is_owned = false;
34614         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
34615         return ret_conv;
34616 }
34617
34618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34619         LDKShutdown this_obj_conv;
34620         this_obj_conv.inner = untag_ptr(this_obj);
34621         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34623         Shutdown_free(this_obj_conv);
34624 }
34625
34626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34627         LDKShutdown this_ptr_conv;
34628         this_ptr_conv.inner = untag_ptr(this_ptr);
34629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34631         this_ptr_conv.is_owned = false;
34632         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
34634         return ret_arr;
34635 }
34636
34637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34638         LDKShutdown this_ptr_conv;
34639         this_ptr_conv.inner = untag_ptr(this_ptr);
34640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34642         this_ptr_conv.is_owned = false;
34643         LDKThirtyTwoBytes val_ref;
34644         CHECK((*env)->GetArrayLength(env, val) == 32);
34645         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34646         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
34647 }
34648
34649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
34650         LDKShutdown this_ptr_conv;
34651         this_ptr_conv.inner = untag_ptr(this_ptr);
34652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34654         this_ptr_conv.is_owned = false;
34655         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
34656         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34657         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34658         return ret_arr;
34659 }
34660
34661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34662         LDKShutdown this_ptr_conv;
34663         this_ptr_conv.inner = untag_ptr(this_ptr);
34664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34666         this_ptr_conv.is_owned = false;
34667         LDKCVec_u8Z val_ref;
34668         val_ref.datalen = (*env)->GetArrayLength(env, val);
34669         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34670         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34671         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
34672 }
34673
34674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
34675         LDKThirtyTwoBytes channel_id_arg_ref;
34676         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34677         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34678         LDKCVec_u8Z scriptpubkey_arg_ref;
34679         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
34680         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
34681         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
34682         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
34683         int64_t ret_ref = 0;
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34686         return ret_ref;
34687 }
34688
34689 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
34690         LDKShutdown ret_var = Shutdown_clone(arg);
34691         int64_t ret_ref = 0;
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34694         return ret_ref;
34695 }
34696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34697         LDKShutdown arg_conv;
34698         arg_conv.inner = untag_ptr(arg);
34699         arg_conv.is_owned = ptr_is_owned(arg);
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34701         arg_conv.is_owned = false;
34702         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
34703         return ret_conv;
34704 }
34705
34706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34707         LDKShutdown orig_conv;
34708         orig_conv.inner = untag_ptr(orig);
34709         orig_conv.is_owned = ptr_is_owned(orig);
34710         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34711         orig_conv.is_owned = false;
34712         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
34713         int64_t ret_ref = 0;
34714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34716         return ret_ref;
34717 }
34718
34719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34720         LDKShutdown a_conv;
34721         a_conv.inner = untag_ptr(a);
34722         a_conv.is_owned = ptr_is_owned(a);
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34724         a_conv.is_owned = false;
34725         LDKShutdown b_conv;
34726         b_conv.inner = untag_ptr(b);
34727         b_conv.is_owned = ptr_is_owned(b);
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34729         b_conv.is_owned = false;
34730         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
34731         return ret_conv;
34732 }
34733
34734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34735         LDKClosingSignedFeeRange this_obj_conv;
34736         this_obj_conv.inner = untag_ptr(this_obj);
34737         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34739         ClosingSignedFeeRange_free(this_obj_conv);
34740 }
34741
34742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34743         LDKClosingSignedFeeRange this_ptr_conv;
34744         this_ptr_conv.inner = untag_ptr(this_ptr);
34745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34747         this_ptr_conv.is_owned = false;
34748         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
34749         return ret_conv;
34750 }
34751
34752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34753         LDKClosingSignedFeeRange this_ptr_conv;
34754         this_ptr_conv.inner = untag_ptr(this_ptr);
34755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34757         this_ptr_conv.is_owned = false;
34758         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
34759 }
34760
34761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34762         LDKClosingSignedFeeRange this_ptr_conv;
34763         this_ptr_conv.inner = untag_ptr(this_ptr);
34764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34766         this_ptr_conv.is_owned = false;
34767         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
34768         return ret_conv;
34769 }
34770
34771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34772         LDKClosingSignedFeeRange this_ptr_conv;
34773         this_ptr_conv.inner = untag_ptr(this_ptr);
34774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34776         this_ptr_conv.is_owned = false;
34777         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
34778 }
34779
34780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
34781         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
34782         int64_t ret_ref = 0;
34783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34785         return ret_ref;
34786 }
34787
34788 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
34789         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
34790         int64_t ret_ref = 0;
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34793         return ret_ref;
34794 }
34795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34796         LDKClosingSignedFeeRange arg_conv;
34797         arg_conv.inner = untag_ptr(arg);
34798         arg_conv.is_owned = ptr_is_owned(arg);
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34800         arg_conv.is_owned = false;
34801         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
34802         return ret_conv;
34803 }
34804
34805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34806         LDKClosingSignedFeeRange orig_conv;
34807         orig_conv.inner = untag_ptr(orig);
34808         orig_conv.is_owned = ptr_is_owned(orig);
34809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34810         orig_conv.is_owned = false;
34811         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
34812         int64_t ret_ref = 0;
34813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34815         return ret_ref;
34816 }
34817
34818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34819         LDKClosingSignedFeeRange a_conv;
34820         a_conv.inner = untag_ptr(a);
34821         a_conv.is_owned = ptr_is_owned(a);
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34823         a_conv.is_owned = false;
34824         LDKClosingSignedFeeRange b_conv;
34825         b_conv.inner = untag_ptr(b);
34826         b_conv.is_owned = ptr_is_owned(b);
34827         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34828         b_conv.is_owned = false;
34829         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
34830         return ret_conv;
34831 }
34832
34833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34834         LDKClosingSigned this_obj_conv;
34835         this_obj_conv.inner = untag_ptr(this_obj);
34836         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34838         ClosingSigned_free(this_obj_conv);
34839 }
34840
34841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34842         LDKClosingSigned this_ptr_conv;
34843         this_ptr_conv.inner = untag_ptr(this_ptr);
34844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34846         this_ptr_conv.is_owned = false;
34847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
34849         return ret_arr;
34850 }
34851
34852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34853         LDKClosingSigned this_ptr_conv;
34854         this_ptr_conv.inner = untag_ptr(this_ptr);
34855         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34857         this_ptr_conv.is_owned = false;
34858         LDKThirtyTwoBytes val_ref;
34859         CHECK((*env)->GetArrayLength(env, val) == 32);
34860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34861         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
34862 }
34863
34864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34865         LDKClosingSigned this_ptr_conv;
34866         this_ptr_conv.inner = untag_ptr(this_ptr);
34867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34869         this_ptr_conv.is_owned = false;
34870         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
34871         return ret_conv;
34872 }
34873
34874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34875         LDKClosingSigned this_ptr_conv;
34876         this_ptr_conv.inner = untag_ptr(this_ptr);
34877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34879         this_ptr_conv.is_owned = false;
34880         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
34881 }
34882
34883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34884         LDKClosingSigned this_ptr_conv;
34885         this_ptr_conv.inner = untag_ptr(this_ptr);
34886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34888         this_ptr_conv.is_owned = false;
34889         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
34891         return ret_arr;
34892 }
34893
34894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34895         LDKClosingSigned this_ptr_conv;
34896         this_ptr_conv.inner = untag_ptr(this_ptr);
34897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34899         this_ptr_conv.is_owned = false;
34900         LDKSignature val_ref;
34901         CHECK((*env)->GetArrayLength(env, val) == 64);
34902         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34903         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
34904 }
34905
34906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34907         LDKClosingSigned this_ptr_conv;
34908         this_ptr_conv.inner = untag_ptr(this_ptr);
34909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34911         this_ptr_conv.is_owned = false;
34912         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
34913         int64_t ret_ref = 0;
34914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34916         return ret_ref;
34917 }
34918
34919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34920         LDKClosingSigned this_ptr_conv;
34921         this_ptr_conv.inner = untag_ptr(this_ptr);
34922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34924         this_ptr_conv.is_owned = false;
34925         LDKClosingSignedFeeRange val_conv;
34926         val_conv.inner = untag_ptr(val);
34927         val_conv.is_owned = ptr_is_owned(val);
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34929         val_conv = ClosingSignedFeeRange_clone(&val_conv);
34930         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
34931 }
34932
34933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
34934         LDKThirtyTwoBytes channel_id_arg_ref;
34935         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34936         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34937         LDKSignature signature_arg_ref;
34938         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34939         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34940         LDKClosingSignedFeeRange fee_range_arg_conv;
34941         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
34942         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
34944         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
34945         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
34946         int64_t ret_ref = 0;
34947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34949         return ret_ref;
34950 }
34951
34952 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
34953         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
34954         int64_t ret_ref = 0;
34955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34957         return ret_ref;
34958 }
34959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34960         LDKClosingSigned arg_conv;
34961         arg_conv.inner = untag_ptr(arg);
34962         arg_conv.is_owned = ptr_is_owned(arg);
34963         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34964         arg_conv.is_owned = false;
34965         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
34966         return ret_conv;
34967 }
34968
34969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34970         LDKClosingSigned orig_conv;
34971         orig_conv.inner = untag_ptr(orig);
34972         orig_conv.is_owned = ptr_is_owned(orig);
34973         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34974         orig_conv.is_owned = false;
34975         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
34976         int64_t ret_ref = 0;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34979         return ret_ref;
34980 }
34981
34982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34983         LDKClosingSigned a_conv;
34984         a_conv.inner = untag_ptr(a);
34985         a_conv.is_owned = ptr_is_owned(a);
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34987         a_conv.is_owned = false;
34988         LDKClosingSigned b_conv;
34989         b_conv.inner = untag_ptr(b);
34990         b_conv.is_owned = ptr_is_owned(b);
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34992         b_conv.is_owned = false;
34993         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
34994         return ret_conv;
34995 }
34996
34997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34998         LDKUpdateAddHTLC this_obj_conv;
34999         this_obj_conv.inner = untag_ptr(this_obj);
35000         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35002         UpdateAddHTLC_free(this_obj_conv);
35003 }
35004
35005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35006         LDKUpdateAddHTLC this_ptr_conv;
35007         this_ptr_conv.inner = untag_ptr(this_ptr);
35008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35010         this_ptr_conv.is_owned = false;
35011         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
35013         return ret_arr;
35014 }
35015
35016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35017         LDKUpdateAddHTLC this_ptr_conv;
35018         this_ptr_conv.inner = untag_ptr(this_ptr);
35019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35021         this_ptr_conv.is_owned = false;
35022         LDKThirtyTwoBytes val_ref;
35023         CHECK((*env)->GetArrayLength(env, val) == 32);
35024         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35025         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
35026 }
35027
35028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35029         LDKUpdateAddHTLC this_ptr_conv;
35030         this_ptr_conv.inner = untag_ptr(this_ptr);
35031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35033         this_ptr_conv.is_owned = false;
35034         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
35035         return ret_conv;
35036 }
35037
35038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35039         LDKUpdateAddHTLC this_ptr_conv;
35040         this_ptr_conv.inner = untag_ptr(this_ptr);
35041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35043         this_ptr_conv.is_owned = false;
35044         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
35045 }
35046
35047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35048         LDKUpdateAddHTLC this_ptr_conv;
35049         this_ptr_conv.inner = untag_ptr(this_ptr);
35050         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35052         this_ptr_conv.is_owned = false;
35053         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
35054         return ret_conv;
35055 }
35056
35057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35058         LDKUpdateAddHTLC this_ptr_conv;
35059         this_ptr_conv.inner = untag_ptr(this_ptr);
35060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35062         this_ptr_conv.is_owned = false;
35063         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
35064 }
35065
35066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35067         LDKUpdateAddHTLC this_ptr_conv;
35068         this_ptr_conv.inner = untag_ptr(this_ptr);
35069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35071         this_ptr_conv.is_owned = false;
35072         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
35074         return ret_arr;
35075 }
35076
35077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35078         LDKUpdateAddHTLC this_ptr_conv;
35079         this_ptr_conv.inner = untag_ptr(this_ptr);
35080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35082         this_ptr_conv.is_owned = false;
35083         LDKThirtyTwoBytes val_ref;
35084         CHECK((*env)->GetArrayLength(env, val) == 32);
35085         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35086         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
35087 }
35088
35089 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
35090         LDKUpdateAddHTLC this_ptr_conv;
35091         this_ptr_conv.inner = untag_ptr(this_ptr);
35092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35094         this_ptr_conv.is_owned = false;
35095         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
35096         return ret_conv;
35097 }
35098
35099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35100         LDKUpdateAddHTLC this_ptr_conv;
35101         this_ptr_conv.inner = untag_ptr(this_ptr);
35102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35104         this_ptr_conv.is_owned = false;
35105         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
35106 }
35107
35108 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
35109         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
35110         int64_t ret_ref = 0;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35113         return ret_ref;
35114 }
35115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35116         LDKUpdateAddHTLC arg_conv;
35117         arg_conv.inner = untag_ptr(arg);
35118         arg_conv.is_owned = ptr_is_owned(arg);
35119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35120         arg_conv.is_owned = false;
35121         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
35122         return ret_conv;
35123 }
35124
35125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35126         LDKUpdateAddHTLC orig_conv;
35127         orig_conv.inner = untag_ptr(orig);
35128         orig_conv.is_owned = ptr_is_owned(orig);
35129         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35130         orig_conv.is_owned = false;
35131         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
35132         int64_t ret_ref = 0;
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35135         return ret_ref;
35136 }
35137
35138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35139         LDKUpdateAddHTLC a_conv;
35140         a_conv.inner = untag_ptr(a);
35141         a_conv.is_owned = ptr_is_owned(a);
35142         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35143         a_conv.is_owned = false;
35144         LDKUpdateAddHTLC b_conv;
35145         b_conv.inner = untag_ptr(b);
35146         b_conv.is_owned = ptr_is_owned(b);
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35148         b_conv.is_owned = false;
35149         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
35150         return ret_conv;
35151 }
35152
35153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35154         LDKOnionMessage this_obj_conv;
35155         this_obj_conv.inner = untag_ptr(this_obj);
35156         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35158         OnionMessage_free(this_obj_conv);
35159 }
35160
35161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35162         LDKOnionMessage this_ptr_conv;
35163         this_ptr_conv.inner = untag_ptr(this_ptr);
35164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35166         this_ptr_conv.is_owned = false;
35167         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
35169         return ret_arr;
35170 }
35171
35172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35173         LDKOnionMessage this_ptr_conv;
35174         this_ptr_conv.inner = untag_ptr(this_ptr);
35175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35177         this_ptr_conv.is_owned = false;
35178         LDKPublicKey val_ref;
35179         CHECK((*env)->GetArrayLength(env, val) == 33);
35180         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35181         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
35182 }
35183
35184 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
35185         LDKOnionMessage ret_var = OnionMessage_clone(arg);
35186         int64_t ret_ref = 0;
35187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35189         return ret_ref;
35190 }
35191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35192         LDKOnionMessage arg_conv;
35193         arg_conv.inner = untag_ptr(arg);
35194         arg_conv.is_owned = ptr_is_owned(arg);
35195         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35196         arg_conv.is_owned = false;
35197         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
35198         return ret_conv;
35199 }
35200
35201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35202         LDKOnionMessage orig_conv;
35203         orig_conv.inner = untag_ptr(orig);
35204         orig_conv.is_owned = ptr_is_owned(orig);
35205         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35206         orig_conv.is_owned = false;
35207         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
35208         int64_t ret_ref = 0;
35209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35211         return ret_ref;
35212 }
35213
35214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35215         LDKOnionMessage a_conv;
35216         a_conv.inner = untag_ptr(a);
35217         a_conv.is_owned = ptr_is_owned(a);
35218         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35219         a_conv.is_owned = false;
35220         LDKOnionMessage b_conv;
35221         b_conv.inner = untag_ptr(b);
35222         b_conv.is_owned = ptr_is_owned(b);
35223         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35224         b_conv.is_owned = false;
35225         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
35226         return ret_conv;
35227 }
35228
35229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35230         LDKUpdateFulfillHTLC this_obj_conv;
35231         this_obj_conv.inner = untag_ptr(this_obj);
35232         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35234         UpdateFulfillHTLC_free(this_obj_conv);
35235 }
35236
35237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35238         LDKUpdateFulfillHTLC this_ptr_conv;
35239         this_ptr_conv.inner = untag_ptr(this_ptr);
35240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35242         this_ptr_conv.is_owned = false;
35243         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
35245         return ret_arr;
35246 }
35247
35248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35249         LDKUpdateFulfillHTLC this_ptr_conv;
35250         this_ptr_conv.inner = untag_ptr(this_ptr);
35251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35253         this_ptr_conv.is_owned = false;
35254         LDKThirtyTwoBytes val_ref;
35255         CHECK((*env)->GetArrayLength(env, val) == 32);
35256         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35257         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
35258 }
35259
35260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35261         LDKUpdateFulfillHTLC this_ptr_conv;
35262         this_ptr_conv.inner = untag_ptr(this_ptr);
35263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35265         this_ptr_conv.is_owned = false;
35266         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
35267         return ret_conv;
35268 }
35269
35270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35271         LDKUpdateFulfillHTLC this_ptr_conv;
35272         this_ptr_conv.inner = untag_ptr(this_ptr);
35273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35275         this_ptr_conv.is_owned = false;
35276         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
35277 }
35278
35279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
35280         LDKUpdateFulfillHTLC this_ptr_conv;
35281         this_ptr_conv.inner = untag_ptr(this_ptr);
35282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35284         this_ptr_conv.is_owned = false;
35285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
35287         return ret_arr;
35288 }
35289
35290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35291         LDKUpdateFulfillHTLC this_ptr_conv;
35292         this_ptr_conv.inner = untag_ptr(this_ptr);
35293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35295         this_ptr_conv.is_owned = false;
35296         LDKThirtyTwoBytes val_ref;
35297         CHECK((*env)->GetArrayLength(env, val) == 32);
35298         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35299         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
35300 }
35301
35302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
35303         LDKThirtyTwoBytes channel_id_arg_ref;
35304         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35305         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35306         LDKThirtyTwoBytes payment_preimage_arg_ref;
35307         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
35308         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
35309         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
35310         int64_t ret_ref = 0;
35311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35313         return ret_ref;
35314 }
35315
35316 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
35317         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
35318         int64_t ret_ref = 0;
35319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35321         return ret_ref;
35322 }
35323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35324         LDKUpdateFulfillHTLC arg_conv;
35325         arg_conv.inner = untag_ptr(arg);
35326         arg_conv.is_owned = ptr_is_owned(arg);
35327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35328         arg_conv.is_owned = false;
35329         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
35330         return ret_conv;
35331 }
35332
35333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35334         LDKUpdateFulfillHTLC orig_conv;
35335         orig_conv.inner = untag_ptr(orig);
35336         orig_conv.is_owned = ptr_is_owned(orig);
35337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35338         orig_conv.is_owned = false;
35339         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
35340         int64_t ret_ref = 0;
35341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35343         return ret_ref;
35344 }
35345
35346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35347         LDKUpdateFulfillHTLC a_conv;
35348         a_conv.inner = untag_ptr(a);
35349         a_conv.is_owned = ptr_is_owned(a);
35350         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35351         a_conv.is_owned = false;
35352         LDKUpdateFulfillHTLC b_conv;
35353         b_conv.inner = untag_ptr(b);
35354         b_conv.is_owned = ptr_is_owned(b);
35355         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35356         b_conv.is_owned = false;
35357         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
35358         return ret_conv;
35359 }
35360
35361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35362         LDKUpdateFailHTLC this_obj_conv;
35363         this_obj_conv.inner = untag_ptr(this_obj);
35364         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35366         UpdateFailHTLC_free(this_obj_conv);
35367 }
35368
35369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35370         LDKUpdateFailHTLC this_ptr_conv;
35371         this_ptr_conv.inner = untag_ptr(this_ptr);
35372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35374         this_ptr_conv.is_owned = false;
35375         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
35377         return ret_arr;
35378 }
35379
35380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35381         LDKUpdateFailHTLC this_ptr_conv;
35382         this_ptr_conv.inner = untag_ptr(this_ptr);
35383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35385         this_ptr_conv.is_owned = false;
35386         LDKThirtyTwoBytes val_ref;
35387         CHECK((*env)->GetArrayLength(env, val) == 32);
35388         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35389         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
35390 }
35391
35392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35393         LDKUpdateFailHTLC this_ptr_conv;
35394         this_ptr_conv.inner = untag_ptr(this_ptr);
35395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35397         this_ptr_conv.is_owned = false;
35398         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
35399         return ret_conv;
35400 }
35401
35402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35403         LDKUpdateFailHTLC this_ptr_conv;
35404         this_ptr_conv.inner = untag_ptr(this_ptr);
35405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35407         this_ptr_conv.is_owned = false;
35408         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
35409 }
35410
35411 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
35412         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
35413         int64_t ret_ref = 0;
35414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35415         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35416         return ret_ref;
35417 }
35418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35419         LDKUpdateFailHTLC arg_conv;
35420         arg_conv.inner = untag_ptr(arg);
35421         arg_conv.is_owned = ptr_is_owned(arg);
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35423         arg_conv.is_owned = false;
35424         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
35425         return ret_conv;
35426 }
35427
35428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35429         LDKUpdateFailHTLC orig_conv;
35430         orig_conv.inner = untag_ptr(orig);
35431         orig_conv.is_owned = ptr_is_owned(orig);
35432         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35433         orig_conv.is_owned = false;
35434         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
35435         int64_t ret_ref = 0;
35436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35438         return ret_ref;
35439 }
35440
35441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35442         LDKUpdateFailHTLC a_conv;
35443         a_conv.inner = untag_ptr(a);
35444         a_conv.is_owned = ptr_is_owned(a);
35445         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35446         a_conv.is_owned = false;
35447         LDKUpdateFailHTLC b_conv;
35448         b_conv.inner = untag_ptr(b);
35449         b_conv.is_owned = ptr_is_owned(b);
35450         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35451         b_conv.is_owned = false;
35452         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
35453         return ret_conv;
35454 }
35455
35456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35457         LDKUpdateFailMalformedHTLC this_obj_conv;
35458         this_obj_conv.inner = untag_ptr(this_obj);
35459         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35461         UpdateFailMalformedHTLC_free(this_obj_conv);
35462 }
35463
35464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35465         LDKUpdateFailMalformedHTLC this_ptr_conv;
35466         this_ptr_conv.inner = untag_ptr(this_ptr);
35467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35469         this_ptr_conv.is_owned = false;
35470         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
35472         return ret_arr;
35473 }
35474
35475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35476         LDKUpdateFailMalformedHTLC this_ptr_conv;
35477         this_ptr_conv.inner = untag_ptr(this_ptr);
35478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35480         this_ptr_conv.is_owned = false;
35481         LDKThirtyTwoBytes val_ref;
35482         CHECK((*env)->GetArrayLength(env, val) == 32);
35483         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35484         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
35485 }
35486
35487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35488         LDKUpdateFailMalformedHTLC this_ptr_conv;
35489         this_ptr_conv.inner = untag_ptr(this_ptr);
35490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35492         this_ptr_conv.is_owned = false;
35493         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
35494         return ret_conv;
35495 }
35496
35497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35498         LDKUpdateFailMalformedHTLC this_ptr_conv;
35499         this_ptr_conv.inner = untag_ptr(this_ptr);
35500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35502         this_ptr_conv.is_owned = false;
35503         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
35504 }
35505
35506 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
35507         LDKUpdateFailMalformedHTLC this_ptr_conv;
35508         this_ptr_conv.inner = untag_ptr(this_ptr);
35509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35511         this_ptr_conv.is_owned = false;
35512         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
35513         return ret_conv;
35514 }
35515
35516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35517         LDKUpdateFailMalformedHTLC this_ptr_conv;
35518         this_ptr_conv.inner = untag_ptr(this_ptr);
35519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35521         this_ptr_conv.is_owned = false;
35522         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
35523 }
35524
35525 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
35526         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
35527         int64_t ret_ref = 0;
35528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35530         return ret_ref;
35531 }
35532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35533         LDKUpdateFailMalformedHTLC arg_conv;
35534         arg_conv.inner = untag_ptr(arg);
35535         arg_conv.is_owned = ptr_is_owned(arg);
35536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35537         arg_conv.is_owned = false;
35538         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
35539         return ret_conv;
35540 }
35541
35542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35543         LDKUpdateFailMalformedHTLC orig_conv;
35544         orig_conv.inner = untag_ptr(orig);
35545         orig_conv.is_owned = ptr_is_owned(orig);
35546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35547         orig_conv.is_owned = false;
35548         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
35549         int64_t ret_ref = 0;
35550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35552         return ret_ref;
35553 }
35554
35555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35556         LDKUpdateFailMalformedHTLC a_conv;
35557         a_conv.inner = untag_ptr(a);
35558         a_conv.is_owned = ptr_is_owned(a);
35559         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35560         a_conv.is_owned = false;
35561         LDKUpdateFailMalformedHTLC b_conv;
35562         b_conv.inner = untag_ptr(b);
35563         b_conv.is_owned = ptr_is_owned(b);
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35565         b_conv.is_owned = false;
35566         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
35567         return ret_conv;
35568 }
35569
35570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35571         LDKCommitmentSigned this_obj_conv;
35572         this_obj_conv.inner = untag_ptr(this_obj);
35573         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35575         CommitmentSigned_free(this_obj_conv);
35576 }
35577
35578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35579         LDKCommitmentSigned this_ptr_conv;
35580         this_ptr_conv.inner = untag_ptr(this_ptr);
35581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35583         this_ptr_conv.is_owned = false;
35584         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
35586         return ret_arr;
35587 }
35588
35589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35590         LDKCommitmentSigned this_ptr_conv;
35591         this_ptr_conv.inner = untag_ptr(this_ptr);
35592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35594         this_ptr_conv.is_owned = false;
35595         LDKThirtyTwoBytes val_ref;
35596         CHECK((*env)->GetArrayLength(env, val) == 32);
35597         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35598         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
35599 }
35600
35601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35602         LDKCommitmentSigned this_ptr_conv;
35603         this_ptr_conv.inner = untag_ptr(this_ptr);
35604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35606         this_ptr_conv.is_owned = false;
35607         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
35609         return ret_arr;
35610 }
35611
35612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35613         LDKCommitmentSigned this_ptr_conv;
35614         this_ptr_conv.inner = untag_ptr(this_ptr);
35615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35617         this_ptr_conv.is_owned = false;
35618         LDKSignature val_ref;
35619         CHECK((*env)->GetArrayLength(env, val) == 64);
35620         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35621         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
35622 }
35623
35624 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
35625         LDKCommitmentSigned this_ptr_conv;
35626         this_ptr_conv.inner = untag_ptr(this_ptr);
35627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35629         this_ptr_conv.is_owned = false;
35630         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
35631         jobjectArray ret_arr = NULL;
35632         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
35633         ;
35634         for (size_t i = 0; i < ret_var.datalen; i++) {
35635                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
35636                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
35637                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
35638         }
35639         
35640         FREE(ret_var.data);
35641         return ret_arr;
35642 }
35643
35644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
35645         LDKCommitmentSigned this_ptr_conv;
35646         this_ptr_conv.inner = untag_ptr(this_ptr);
35647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35649         this_ptr_conv.is_owned = false;
35650         LDKCVec_SignatureZ val_constr;
35651         val_constr.datalen = (*env)->GetArrayLength(env, val);
35652         if (val_constr.datalen > 0)
35653                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35654         else
35655                 val_constr.data = NULL;
35656         for (size_t i = 0; i < val_constr.datalen; i++) {
35657                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
35658                 LDKSignature val_conv_8_ref;
35659                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
35660                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
35661                 val_constr.data[i] = val_conv_8_ref;
35662         }
35663         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
35664 }
35665
35666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg, jobjectArray htlc_signatures_arg) {
35667         LDKThirtyTwoBytes channel_id_arg_ref;
35668         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35669         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35670         LDKSignature signature_arg_ref;
35671         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35672         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35673         LDKCVec_SignatureZ htlc_signatures_arg_constr;
35674         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
35675         if (htlc_signatures_arg_constr.datalen > 0)
35676                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35677         else
35678                 htlc_signatures_arg_constr.data = NULL;
35679         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
35680                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
35681                 LDKSignature htlc_signatures_arg_conv_8_ref;
35682                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
35683                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
35684                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
35685         }
35686         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
35687         int64_t ret_ref = 0;
35688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35690         return ret_ref;
35691 }
35692
35693 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
35694         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
35695         int64_t ret_ref = 0;
35696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35698         return ret_ref;
35699 }
35700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35701         LDKCommitmentSigned arg_conv;
35702         arg_conv.inner = untag_ptr(arg);
35703         arg_conv.is_owned = ptr_is_owned(arg);
35704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35705         arg_conv.is_owned = false;
35706         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
35707         return ret_conv;
35708 }
35709
35710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35711         LDKCommitmentSigned orig_conv;
35712         orig_conv.inner = untag_ptr(orig);
35713         orig_conv.is_owned = ptr_is_owned(orig);
35714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35715         orig_conv.is_owned = false;
35716         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
35717         int64_t ret_ref = 0;
35718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35720         return ret_ref;
35721 }
35722
35723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35724         LDKCommitmentSigned a_conv;
35725         a_conv.inner = untag_ptr(a);
35726         a_conv.is_owned = ptr_is_owned(a);
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35728         a_conv.is_owned = false;
35729         LDKCommitmentSigned b_conv;
35730         b_conv.inner = untag_ptr(b);
35731         b_conv.is_owned = ptr_is_owned(b);
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35733         b_conv.is_owned = false;
35734         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
35735         return ret_conv;
35736 }
35737
35738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35739         LDKRevokeAndACK this_obj_conv;
35740         this_obj_conv.inner = untag_ptr(this_obj);
35741         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35743         RevokeAndACK_free(this_obj_conv);
35744 }
35745
35746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35747         LDKRevokeAndACK this_ptr_conv;
35748         this_ptr_conv.inner = untag_ptr(this_ptr);
35749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35751         this_ptr_conv.is_owned = false;
35752         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
35754         return ret_arr;
35755 }
35756
35757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35758         LDKRevokeAndACK this_ptr_conv;
35759         this_ptr_conv.inner = untag_ptr(this_ptr);
35760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35762         this_ptr_conv.is_owned = false;
35763         LDKThirtyTwoBytes val_ref;
35764         CHECK((*env)->GetArrayLength(env, val) == 32);
35765         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35766         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
35767 }
35768
35769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
35770         LDKRevokeAndACK this_ptr_conv;
35771         this_ptr_conv.inner = untag_ptr(this_ptr);
35772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35774         this_ptr_conv.is_owned = false;
35775         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
35777         return ret_arr;
35778 }
35779
35780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35781         LDKRevokeAndACK this_ptr_conv;
35782         this_ptr_conv.inner = untag_ptr(this_ptr);
35783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35785         this_ptr_conv.is_owned = false;
35786         LDKThirtyTwoBytes val_ref;
35787         CHECK((*env)->GetArrayLength(env, val) == 32);
35788         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35789         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
35790 }
35791
35792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35793         LDKRevokeAndACK this_ptr_conv;
35794         this_ptr_conv.inner = untag_ptr(this_ptr);
35795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35797         this_ptr_conv.is_owned = false;
35798         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
35800         return ret_arr;
35801 }
35802
35803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35804         LDKRevokeAndACK this_ptr_conv;
35805         this_ptr_conv.inner = untag_ptr(this_ptr);
35806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35808         this_ptr_conv.is_owned = false;
35809         LDKPublicKey val_ref;
35810         CHECK((*env)->GetArrayLength(env, val) == 33);
35811         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35812         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
35813 }
35814
35815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
35816         LDKThirtyTwoBytes channel_id_arg_ref;
35817         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35818         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35819         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
35820         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
35821         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
35822         LDKPublicKey next_per_commitment_point_arg_ref;
35823         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
35824         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
35825         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
35826         int64_t ret_ref = 0;
35827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35829         return ret_ref;
35830 }
35831
35832 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
35833         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
35834         int64_t ret_ref = 0;
35835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35837         return ret_ref;
35838 }
35839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35840         LDKRevokeAndACK arg_conv;
35841         arg_conv.inner = untag_ptr(arg);
35842         arg_conv.is_owned = ptr_is_owned(arg);
35843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35844         arg_conv.is_owned = false;
35845         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
35846         return ret_conv;
35847 }
35848
35849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35850         LDKRevokeAndACK orig_conv;
35851         orig_conv.inner = untag_ptr(orig);
35852         orig_conv.is_owned = ptr_is_owned(orig);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35854         orig_conv.is_owned = false;
35855         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
35856         int64_t ret_ref = 0;
35857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35859         return ret_ref;
35860 }
35861
35862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35863         LDKRevokeAndACK a_conv;
35864         a_conv.inner = untag_ptr(a);
35865         a_conv.is_owned = ptr_is_owned(a);
35866         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35867         a_conv.is_owned = false;
35868         LDKRevokeAndACK b_conv;
35869         b_conv.inner = untag_ptr(b);
35870         b_conv.is_owned = ptr_is_owned(b);
35871         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35872         b_conv.is_owned = false;
35873         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
35874         return ret_conv;
35875 }
35876
35877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35878         LDKUpdateFee this_obj_conv;
35879         this_obj_conv.inner = untag_ptr(this_obj);
35880         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35882         UpdateFee_free(this_obj_conv);
35883 }
35884
35885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35886         LDKUpdateFee this_ptr_conv;
35887         this_ptr_conv.inner = untag_ptr(this_ptr);
35888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35890         this_ptr_conv.is_owned = false;
35891         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
35893         return ret_arr;
35894 }
35895
35896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35897         LDKUpdateFee this_ptr_conv;
35898         this_ptr_conv.inner = untag_ptr(this_ptr);
35899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35901         this_ptr_conv.is_owned = false;
35902         LDKThirtyTwoBytes val_ref;
35903         CHECK((*env)->GetArrayLength(env, val) == 32);
35904         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35905         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
35906 }
35907
35908 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35909         LDKUpdateFee this_ptr_conv;
35910         this_ptr_conv.inner = untag_ptr(this_ptr);
35911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35913         this_ptr_conv.is_owned = false;
35914         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
35915         return ret_conv;
35916 }
35917
35918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35919         LDKUpdateFee this_ptr_conv;
35920         this_ptr_conv.inner = untag_ptr(this_ptr);
35921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35923         this_ptr_conv.is_owned = false;
35924         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
35925 }
35926
35927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
35928         LDKThirtyTwoBytes channel_id_arg_ref;
35929         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35930         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35931         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
35932         int64_t ret_ref = 0;
35933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35935         return ret_ref;
35936 }
35937
35938 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
35939         LDKUpdateFee ret_var = UpdateFee_clone(arg);
35940         int64_t ret_ref = 0;
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35943         return ret_ref;
35944 }
35945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35946         LDKUpdateFee arg_conv;
35947         arg_conv.inner = untag_ptr(arg);
35948         arg_conv.is_owned = ptr_is_owned(arg);
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35950         arg_conv.is_owned = false;
35951         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
35952         return ret_conv;
35953 }
35954
35955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35956         LDKUpdateFee orig_conv;
35957         orig_conv.inner = untag_ptr(orig);
35958         orig_conv.is_owned = ptr_is_owned(orig);
35959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35960         orig_conv.is_owned = false;
35961         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
35962         int64_t ret_ref = 0;
35963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35965         return ret_ref;
35966 }
35967
35968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35969         LDKUpdateFee a_conv;
35970         a_conv.inner = untag_ptr(a);
35971         a_conv.is_owned = ptr_is_owned(a);
35972         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35973         a_conv.is_owned = false;
35974         LDKUpdateFee b_conv;
35975         b_conv.inner = untag_ptr(b);
35976         b_conv.is_owned = ptr_is_owned(b);
35977         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35978         b_conv.is_owned = false;
35979         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
35980         return ret_conv;
35981 }
35982
35983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35984         LDKDataLossProtect this_obj_conv;
35985         this_obj_conv.inner = untag_ptr(this_obj);
35986         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35988         DataLossProtect_free(this_obj_conv);
35989 }
35990
35991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
35992         LDKDataLossProtect this_ptr_conv;
35993         this_ptr_conv.inner = untag_ptr(this_ptr);
35994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35996         this_ptr_conv.is_owned = false;
35997         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
35999         return ret_arr;
36000 }
36001
36002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36003         LDKDataLossProtect this_ptr_conv;
36004         this_ptr_conv.inner = untag_ptr(this_ptr);
36005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36007         this_ptr_conv.is_owned = false;
36008         LDKThirtyTwoBytes val_ref;
36009         CHECK((*env)->GetArrayLength(env, val) == 32);
36010         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36011         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
36012 }
36013
36014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36015         LDKDataLossProtect this_ptr_conv;
36016         this_ptr_conv.inner = untag_ptr(this_ptr);
36017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36019         this_ptr_conv.is_owned = false;
36020         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
36022         return ret_arr;
36023 }
36024
36025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36026         LDKDataLossProtect this_ptr_conv;
36027         this_ptr_conv.inner = untag_ptr(this_ptr);
36028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36030         this_ptr_conv.is_owned = false;
36031         LDKPublicKey val_ref;
36032         CHECK((*env)->GetArrayLength(env, val) == 33);
36033         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36034         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
36035 }
36036
36037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv *env, jclass clz, int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
36038         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
36039         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
36040         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
36041         LDKPublicKey my_current_per_commitment_point_arg_ref;
36042         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
36043         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
36044         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
36045         int64_t ret_ref = 0;
36046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36048         return ret_ref;
36049 }
36050
36051 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
36052         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
36053         int64_t ret_ref = 0;
36054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36056         return ret_ref;
36057 }
36058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36059         LDKDataLossProtect arg_conv;
36060         arg_conv.inner = untag_ptr(arg);
36061         arg_conv.is_owned = ptr_is_owned(arg);
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36063         arg_conv.is_owned = false;
36064         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
36065         return ret_conv;
36066 }
36067
36068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36069         LDKDataLossProtect orig_conv;
36070         orig_conv.inner = untag_ptr(orig);
36071         orig_conv.is_owned = ptr_is_owned(orig);
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36073         orig_conv.is_owned = false;
36074         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
36075         int64_t ret_ref = 0;
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36078         return ret_ref;
36079 }
36080
36081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36082         LDKDataLossProtect a_conv;
36083         a_conv.inner = untag_ptr(a);
36084         a_conv.is_owned = ptr_is_owned(a);
36085         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36086         a_conv.is_owned = false;
36087         LDKDataLossProtect b_conv;
36088         b_conv.inner = untag_ptr(b);
36089         b_conv.is_owned = ptr_is_owned(b);
36090         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36091         b_conv.is_owned = false;
36092         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
36093         return ret_conv;
36094 }
36095
36096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36097         LDKChannelReestablish this_obj_conv;
36098         this_obj_conv.inner = untag_ptr(this_obj);
36099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36101         ChannelReestablish_free(this_obj_conv);
36102 }
36103
36104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36105         LDKChannelReestablish this_ptr_conv;
36106         this_ptr_conv.inner = untag_ptr(this_ptr);
36107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36109         this_ptr_conv.is_owned = false;
36110         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36111         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
36112         return ret_arr;
36113 }
36114
36115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36116         LDKChannelReestablish this_ptr_conv;
36117         this_ptr_conv.inner = untag_ptr(this_ptr);
36118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36120         this_ptr_conv.is_owned = false;
36121         LDKThirtyTwoBytes val_ref;
36122         CHECK((*env)->GetArrayLength(env, val) == 32);
36123         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36124         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
36125 }
36126
36127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
36128         LDKChannelReestablish this_ptr_conv;
36129         this_ptr_conv.inner = untag_ptr(this_ptr);
36130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36132         this_ptr_conv.is_owned = false;
36133         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
36134         return ret_conv;
36135 }
36136
36137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36138         LDKChannelReestablish this_ptr_conv;
36139         this_ptr_conv.inner = untag_ptr(this_ptr);
36140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36142         this_ptr_conv.is_owned = false;
36143         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
36144 }
36145
36146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
36147         LDKChannelReestablish this_ptr_conv;
36148         this_ptr_conv.inner = untag_ptr(this_ptr);
36149         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36151         this_ptr_conv.is_owned = false;
36152         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
36153         return ret_conv;
36154 }
36155
36156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36157         LDKChannelReestablish this_ptr_conv;
36158         this_ptr_conv.inner = untag_ptr(this_ptr);
36159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36161         this_ptr_conv.is_owned = false;
36162         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
36163 }
36164
36165 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
36166         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
36167         int64_t ret_ref = 0;
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36170         return ret_ref;
36171 }
36172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36173         LDKChannelReestablish arg_conv;
36174         arg_conv.inner = untag_ptr(arg);
36175         arg_conv.is_owned = ptr_is_owned(arg);
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36177         arg_conv.is_owned = false;
36178         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
36179         return ret_conv;
36180 }
36181
36182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36183         LDKChannelReestablish orig_conv;
36184         orig_conv.inner = untag_ptr(orig);
36185         orig_conv.is_owned = ptr_is_owned(orig);
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36187         orig_conv.is_owned = false;
36188         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
36189         int64_t ret_ref = 0;
36190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36192         return ret_ref;
36193 }
36194
36195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36196         LDKChannelReestablish a_conv;
36197         a_conv.inner = untag_ptr(a);
36198         a_conv.is_owned = ptr_is_owned(a);
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36200         a_conv.is_owned = false;
36201         LDKChannelReestablish b_conv;
36202         b_conv.inner = untag_ptr(b);
36203         b_conv.is_owned = ptr_is_owned(b);
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36205         b_conv.is_owned = false;
36206         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
36207         return ret_conv;
36208 }
36209
36210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36211         LDKAnnouncementSignatures this_obj_conv;
36212         this_obj_conv.inner = untag_ptr(this_obj);
36213         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36215         AnnouncementSignatures_free(this_obj_conv);
36216 }
36217
36218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36219         LDKAnnouncementSignatures this_ptr_conv;
36220         this_ptr_conv.inner = untag_ptr(this_ptr);
36221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36223         this_ptr_conv.is_owned = false;
36224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
36226         return ret_arr;
36227 }
36228
36229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36230         LDKAnnouncementSignatures this_ptr_conv;
36231         this_ptr_conv.inner = untag_ptr(this_ptr);
36232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36234         this_ptr_conv.is_owned = false;
36235         LDKThirtyTwoBytes val_ref;
36236         CHECK((*env)->GetArrayLength(env, val) == 32);
36237         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36238         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
36239 }
36240
36241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36242         LDKAnnouncementSignatures this_ptr_conv;
36243         this_ptr_conv.inner = untag_ptr(this_ptr);
36244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36246         this_ptr_conv.is_owned = false;
36247         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
36248         return ret_conv;
36249 }
36250
36251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36252         LDKAnnouncementSignatures this_ptr_conv;
36253         this_ptr_conv.inner = untag_ptr(this_ptr);
36254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36256         this_ptr_conv.is_owned = false;
36257         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
36258 }
36259
36260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36261         LDKAnnouncementSignatures this_ptr_conv;
36262         this_ptr_conv.inner = untag_ptr(this_ptr);
36263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36265         this_ptr_conv.is_owned = false;
36266         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36267         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
36268         return ret_arr;
36269 }
36270
36271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36272         LDKAnnouncementSignatures this_ptr_conv;
36273         this_ptr_conv.inner = untag_ptr(this_ptr);
36274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36276         this_ptr_conv.is_owned = false;
36277         LDKSignature val_ref;
36278         CHECK((*env)->GetArrayLength(env, val) == 64);
36279         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36280         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
36281 }
36282
36283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36284         LDKAnnouncementSignatures this_ptr_conv;
36285         this_ptr_conv.inner = untag_ptr(this_ptr);
36286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36288         this_ptr_conv.is_owned = false;
36289         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
36291         return ret_arr;
36292 }
36293
36294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36295         LDKAnnouncementSignatures this_ptr_conv;
36296         this_ptr_conv.inner = untag_ptr(this_ptr);
36297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36299         this_ptr_conv.is_owned = false;
36300         LDKSignature val_ref;
36301         CHECK((*env)->GetArrayLength(env, val) == 64);
36302         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36303         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
36304 }
36305
36306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
36307         LDKThirtyTwoBytes channel_id_arg_ref;
36308         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36309         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36310         LDKSignature node_signature_arg_ref;
36311         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
36312         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
36313         LDKSignature bitcoin_signature_arg_ref;
36314         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
36315         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
36316         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
36317         int64_t ret_ref = 0;
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36320         return ret_ref;
36321 }
36322
36323 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
36324         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
36325         int64_t ret_ref = 0;
36326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36328         return ret_ref;
36329 }
36330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36331         LDKAnnouncementSignatures arg_conv;
36332         arg_conv.inner = untag_ptr(arg);
36333         arg_conv.is_owned = ptr_is_owned(arg);
36334         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36335         arg_conv.is_owned = false;
36336         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
36337         return ret_conv;
36338 }
36339
36340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36341         LDKAnnouncementSignatures orig_conv;
36342         orig_conv.inner = untag_ptr(orig);
36343         orig_conv.is_owned = ptr_is_owned(orig);
36344         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36345         orig_conv.is_owned = false;
36346         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
36347         int64_t ret_ref = 0;
36348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36350         return ret_ref;
36351 }
36352
36353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36354         LDKAnnouncementSignatures a_conv;
36355         a_conv.inner = untag_ptr(a);
36356         a_conv.is_owned = ptr_is_owned(a);
36357         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36358         a_conv.is_owned = false;
36359         LDKAnnouncementSignatures b_conv;
36360         b_conv.inner = untag_ptr(b);
36361         b_conv.is_owned = ptr_is_owned(b);
36362         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36363         b_conv.is_owned = false;
36364         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
36365         return ret_conv;
36366 }
36367
36368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36369         if (!ptr_is_owned(this_ptr)) return;
36370         void* this_ptr_ptr = untag_ptr(this_ptr);
36371         CHECK_ACCESS(this_ptr_ptr);
36372         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
36373         FREE(untag_ptr(this_ptr));
36374         NetAddress_free(this_ptr_conv);
36375 }
36376
36377 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
36378         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36379         *ret_copy = NetAddress_clone(arg);
36380         int64_t ret_ref = tag_ptr(ret_copy, true);
36381         return ret_ref;
36382 }
36383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36384         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
36385         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
36386         return ret_conv;
36387 }
36388
36389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36390         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
36391         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36392         *ret_copy = NetAddress_clone(orig_conv);
36393         int64_t ret_ref = tag_ptr(ret_copy, true);
36394         return ret_ref;
36395 }
36396
36397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
36398         LDKFourBytes addr_ref;
36399         CHECK((*env)->GetArrayLength(env, addr) == 4);
36400         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
36401         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36402         *ret_copy = NetAddress_ipv4(addr_ref, port);
36403         int64_t ret_ref = tag_ptr(ret_copy, true);
36404         return ret_ref;
36405 }
36406
36407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
36408         LDKSixteenBytes addr_ref;
36409         CHECK((*env)->GetArrayLength(env, addr) == 16);
36410         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
36411         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36412         *ret_copy = NetAddress_ipv6(addr_ref, port);
36413         int64_t ret_ref = tag_ptr(ret_copy, true);
36414         return ret_ref;
36415 }
36416
36417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
36418         LDKTwelveBytes a_ref;
36419         CHECK((*env)->GetArrayLength(env, a) == 12);
36420         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
36421         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36422         *ret_copy = NetAddress_onion_v2(a_ref);
36423         int64_t ret_ref = tag_ptr(ret_copy, true);
36424         return ret_ref;
36425 }
36426
36427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
36428         LDKThirtyTwoBytes ed25519_pubkey_ref;
36429         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
36430         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
36431         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36432         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
36433         int64_t ret_ref = tag_ptr(ret_copy, true);
36434         return ret_ref;
36435 }
36436
36437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
36438         LDKHostname hostname_conv;
36439         hostname_conv.inner = untag_ptr(hostname);
36440         hostname_conv.is_owned = ptr_is_owned(hostname);
36441         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
36442         hostname_conv = Hostname_clone(&hostname_conv);
36443         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36444         *ret_copy = NetAddress_hostname(hostname_conv, port);
36445         int64_t ret_ref = tag_ptr(ret_copy, true);
36446         return ret_ref;
36447 }
36448
36449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36450         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
36451         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
36452         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
36453         return ret_conv;
36454 }
36455
36456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
36457         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
36458         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
36459         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36460         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36461         CVec_u8Z_free(ret_var);
36462         return ret_arr;
36463 }
36464
36465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36466         LDKu8slice ser_ref;
36467         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36468         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36469         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
36470         *ret_conv = NetAddress_read(ser_ref);
36471         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36472         return tag_ptr(ret_conv, true);
36473 }
36474
36475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36476         LDKUnsignedNodeAnnouncement this_obj_conv;
36477         this_obj_conv.inner = untag_ptr(this_obj);
36478         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36480         UnsignedNodeAnnouncement_free(this_obj_conv);
36481 }
36482
36483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36484         LDKUnsignedNodeAnnouncement this_ptr_conv;
36485         this_ptr_conv.inner = untag_ptr(this_ptr);
36486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36488         this_ptr_conv.is_owned = false;
36489         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
36490         int64_t ret_ref = 0;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36493         return ret_ref;
36494 }
36495
36496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36497         LDKUnsignedNodeAnnouncement this_ptr_conv;
36498         this_ptr_conv.inner = untag_ptr(this_ptr);
36499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36501         this_ptr_conv.is_owned = false;
36502         LDKNodeFeatures val_conv;
36503         val_conv.inner = untag_ptr(val);
36504         val_conv.is_owned = ptr_is_owned(val);
36505         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36506         val_conv = NodeFeatures_clone(&val_conv);
36507         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
36508 }
36509
36510 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36511         LDKUnsignedNodeAnnouncement this_ptr_conv;
36512         this_ptr_conv.inner = untag_ptr(this_ptr);
36513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36515         this_ptr_conv.is_owned = false;
36516         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
36517         return ret_conv;
36518 }
36519
36520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36521         LDKUnsignedNodeAnnouncement this_ptr_conv;
36522         this_ptr_conv.inner = untag_ptr(this_ptr);
36523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36525         this_ptr_conv.is_owned = false;
36526         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
36527 }
36528
36529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36530         LDKUnsignedNodeAnnouncement this_ptr_conv;
36531         this_ptr_conv.inner = untag_ptr(this_ptr);
36532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36534         this_ptr_conv.is_owned = false;
36535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
36537         return ret_arr;
36538 }
36539
36540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36541         LDKUnsignedNodeAnnouncement this_ptr_conv;
36542         this_ptr_conv.inner = untag_ptr(this_ptr);
36543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36545         this_ptr_conv.is_owned = false;
36546         LDKPublicKey val_ref;
36547         CHECK((*env)->GetArrayLength(env, val) == 33);
36548         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36549         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
36550 }
36551
36552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
36553         LDKUnsignedNodeAnnouncement this_ptr_conv;
36554         this_ptr_conv.inner = untag_ptr(this_ptr);
36555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36557         this_ptr_conv.is_owned = false;
36558         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
36559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
36560         return ret_arr;
36561 }
36562
36563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36564         LDKUnsignedNodeAnnouncement this_ptr_conv;
36565         this_ptr_conv.inner = untag_ptr(this_ptr);
36566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36568         this_ptr_conv.is_owned = false;
36569         LDKThreeBytes val_ref;
36570         CHECK((*env)->GetArrayLength(env, val) == 3);
36571         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
36572         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
36573 }
36574
36575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36576         LDKUnsignedNodeAnnouncement this_ptr_conv;
36577         this_ptr_conv.inner = untag_ptr(this_ptr);
36578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36580         this_ptr_conv.is_owned = false;
36581         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
36583         return ret_arr;
36584 }
36585
36586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36587         LDKUnsignedNodeAnnouncement this_ptr_conv;
36588         this_ptr_conv.inner = untag_ptr(this_ptr);
36589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36591         this_ptr_conv.is_owned = false;
36592         LDKThirtyTwoBytes val_ref;
36593         CHECK((*env)->GetArrayLength(env, val) == 32);
36594         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36595         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
36596 }
36597
36598 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
36599         LDKUnsignedNodeAnnouncement this_ptr_conv;
36600         this_ptr_conv.inner = untag_ptr(this_ptr);
36601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36603         this_ptr_conv.is_owned = false;
36604         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
36605         int64_tArray ret_arr = NULL;
36606         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36607         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36608         for (size_t m = 0; m < ret_var.datalen; m++) {
36609                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36610                 *ret_conv_12_copy = ret_var.data[m];
36611                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
36612                 ret_arr_ptr[m] = ret_conv_12_ref;
36613         }
36614         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36615         FREE(ret_var.data);
36616         return ret_arr;
36617 }
36618
36619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36620         LDKUnsignedNodeAnnouncement this_ptr_conv;
36621         this_ptr_conv.inner = untag_ptr(this_ptr);
36622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36624         this_ptr_conv.is_owned = false;
36625         LDKCVec_NetAddressZ val_constr;
36626         val_constr.datalen = (*env)->GetArrayLength(env, val);
36627         if (val_constr.datalen > 0)
36628                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36629         else
36630                 val_constr.data = NULL;
36631         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36632         for (size_t m = 0; m < val_constr.datalen; m++) {
36633                 int64_t val_conv_12 = val_vals[m];
36634                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
36635                 CHECK_ACCESS(val_conv_12_ptr);
36636                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36637                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
36638                 val_constr.data[m] = val_conv_12_conv;
36639         }
36640         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36641         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
36642 }
36643
36644 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
36645         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
36646         int64_t ret_ref = 0;
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36649         return ret_ref;
36650 }
36651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36652         LDKUnsignedNodeAnnouncement arg_conv;
36653         arg_conv.inner = untag_ptr(arg);
36654         arg_conv.is_owned = ptr_is_owned(arg);
36655         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36656         arg_conv.is_owned = false;
36657         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
36658         return ret_conv;
36659 }
36660
36661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36662         LDKUnsignedNodeAnnouncement orig_conv;
36663         orig_conv.inner = untag_ptr(orig);
36664         orig_conv.is_owned = ptr_is_owned(orig);
36665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36666         orig_conv.is_owned = false;
36667         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
36668         int64_t ret_ref = 0;
36669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36671         return ret_ref;
36672 }
36673
36674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36675         LDKUnsignedNodeAnnouncement a_conv;
36676         a_conv.inner = untag_ptr(a);
36677         a_conv.is_owned = ptr_is_owned(a);
36678         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36679         a_conv.is_owned = false;
36680         LDKUnsignedNodeAnnouncement b_conv;
36681         b_conv.inner = untag_ptr(b);
36682         b_conv.is_owned = ptr_is_owned(b);
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36684         b_conv.is_owned = false;
36685         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
36686         return ret_conv;
36687 }
36688
36689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36690         LDKNodeAnnouncement this_obj_conv;
36691         this_obj_conv.inner = untag_ptr(this_obj);
36692         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36694         NodeAnnouncement_free(this_obj_conv);
36695 }
36696
36697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36698         LDKNodeAnnouncement this_ptr_conv;
36699         this_ptr_conv.inner = untag_ptr(this_ptr);
36700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36702         this_ptr_conv.is_owned = false;
36703         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
36705         return ret_arr;
36706 }
36707
36708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36709         LDKNodeAnnouncement this_ptr_conv;
36710         this_ptr_conv.inner = untag_ptr(this_ptr);
36711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36713         this_ptr_conv.is_owned = false;
36714         LDKSignature val_ref;
36715         CHECK((*env)->GetArrayLength(env, val) == 64);
36716         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36717         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
36718 }
36719
36720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36721         LDKNodeAnnouncement this_ptr_conv;
36722         this_ptr_conv.inner = untag_ptr(this_ptr);
36723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36725         this_ptr_conv.is_owned = false;
36726         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
36727         int64_t ret_ref = 0;
36728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36730         return ret_ref;
36731 }
36732
36733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36734         LDKNodeAnnouncement this_ptr_conv;
36735         this_ptr_conv.inner = untag_ptr(this_ptr);
36736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36738         this_ptr_conv.is_owned = false;
36739         LDKUnsignedNodeAnnouncement val_conv;
36740         val_conv.inner = untag_ptr(val);
36741         val_conv.is_owned = ptr_is_owned(val);
36742         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36743         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
36744         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
36745 }
36746
36747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36748         LDKSignature signature_arg_ref;
36749         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36750         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36751         LDKUnsignedNodeAnnouncement contents_arg_conv;
36752         contents_arg_conv.inner = untag_ptr(contents_arg);
36753         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36755         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
36756         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
36757         int64_t ret_ref = 0;
36758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36760         return ret_ref;
36761 }
36762
36763 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
36764         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
36765         int64_t ret_ref = 0;
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36768         return ret_ref;
36769 }
36770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36771         LDKNodeAnnouncement arg_conv;
36772         arg_conv.inner = untag_ptr(arg);
36773         arg_conv.is_owned = ptr_is_owned(arg);
36774         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36775         arg_conv.is_owned = false;
36776         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
36777         return ret_conv;
36778 }
36779
36780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36781         LDKNodeAnnouncement orig_conv;
36782         orig_conv.inner = untag_ptr(orig);
36783         orig_conv.is_owned = ptr_is_owned(orig);
36784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36785         orig_conv.is_owned = false;
36786         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
36787         int64_t ret_ref = 0;
36788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36790         return ret_ref;
36791 }
36792
36793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36794         LDKNodeAnnouncement a_conv;
36795         a_conv.inner = untag_ptr(a);
36796         a_conv.is_owned = ptr_is_owned(a);
36797         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36798         a_conv.is_owned = false;
36799         LDKNodeAnnouncement b_conv;
36800         b_conv.inner = untag_ptr(b);
36801         b_conv.is_owned = ptr_is_owned(b);
36802         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36803         b_conv.is_owned = false;
36804         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
36805         return ret_conv;
36806 }
36807
36808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36809         LDKUnsignedChannelAnnouncement this_obj_conv;
36810         this_obj_conv.inner = untag_ptr(this_obj);
36811         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36813         UnsignedChannelAnnouncement_free(this_obj_conv);
36814 }
36815
36816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36817         LDKUnsignedChannelAnnouncement this_ptr_conv;
36818         this_ptr_conv.inner = untag_ptr(this_ptr);
36819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36821         this_ptr_conv.is_owned = false;
36822         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
36823         int64_t ret_ref = 0;
36824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36826         return ret_ref;
36827 }
36828
36829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36830         LDKUnsignedChannelAnnouncement this_ptr_conv;
36831         this_ptr_conv.inner = untag_ptr(this_ptr);
36832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36834         this_ptr_conv.is_owned = false;
36835         LDKChannelFeatures val_conv;
36836         val_conv.inner = untag_ptr(val);
36837         val_conv.is_owned = ptr_is_owned(val);
36838         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36839         val_conv = ChannelFeatures_clone(&val_conv);
36840         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
36841 }
36842
36843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36844         LDKUnsignedChannelAnnouncement this_ptr_conv;
36845         this_ptr_conv.inner = untag_ptr(this_ptr);
36846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36848         this_ptr_conv.is_owned = false;
36849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
36851         return ret_arr;
36852 }
36853
36854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36855         LDKUnsignedChannelAnnouncement this_ptr_conv;
36856         this_ptr_conv.inner = untag_ptr(this_ptr);
36857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36859         this_ptr_conv.is_owned = false;
36860         LDKThirtyTwoBytes val_ref;
36861         CHECK((*env)->GetArrayLength(env, val) == 32);
36862         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36863         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
36864 }
36865
36866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36867         LDKUnsignedChannelAnnouncement this_ptr_conv;
36868         this_ptr_conv.inner = untag_ptr(this_ptr);
36869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36871         this_ptr_conv.is_owned = false;
36872         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
36873         return ret_conv;
36874 }
36875
36876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36877         LDKUnsignedChannelAnnouncement this_ptr_conv;
36878         this_ptr_conv.inner = untag_ptr(this_ptr);
36879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36881         this_ptr_conv.is_owned = false;
36882         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
36883 }
36884
36885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36886         LDKUnsignedChannelAnnouncement this_ptr_conv;
36887         this_ptr_conv.inner = untag_ptr(this_ptr);
36888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36890         this_ptr_conv.is_owned = false;
36891         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
36893         return ret_arr;
36894 }
36895
36896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36897         LDKUnsignedChannelAnnouncement this_ptr_conv;
36898         this_ptr_conv.inner = untag_ptr(this_ptr);
36899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36901         this_ptr_conv.is_owned = false;
36902         LDKPublicKey val_ref;
36903         CHECK((*env)->GetArrayLength(env, val) == 33);
36904         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36905         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
36906 }
36907
36908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36909         LDKUnsignedChannelAnnouncement this_ptr_conv;
36910         this_ptr_conv.inner = untag_ptr(this_ptr);
36911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36913         this_ptr_conv.is_owned = false;
36914         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
36916         return ret_arr;
36917 }
36918
36919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36920         LDKUnsignedChannelAnnouncement this_ptr_conv;
36921         this_ptr_conv.inner = untag_ptr(this_ptr);
36922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36924         this_ptr_conv.is_owned = false;
36925         LDKPublicKey val_ref;
36926         CHECK((*env)->GetArrayLength(env, val) == 33);
36927         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36928         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
36929 }
36930
36931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36932         LDKUnsignedChannelAnnouncement this_ptr_conv;
36933         this_ptr_conv.inner = untag_ptr(this_ptr);
36934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36936         this_ptr_conv.is_owned = false;
36937         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
36939         return ret_arr;
36940 }
36941
36942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36943         LDKUnsignedChannelAnnouncement this_ptr_conv;
36944         this_ptr_conv.inner = untag_ptr(this_ptr);
36945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36947         this_ptr_conv.is_owned = false;
36948         LDKPublicKey val_ref;
36949         CHECK((*env)->GetArrayLength(env, val) == 33);
36950         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36951         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
36952 }
36953
36954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36955         LDKUnsignedChannelAnnouncement this_ptr_conv;
36956         this_ptr_conv.inner = untag_ptr(this_ptr);
36957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36959         this_ptr_conv.is_owned = false;
36960         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
36962         return ret_arr;
36963 }
36964
36965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36966         LDKUnsignedChannelAnnouncement this_ptr_conv;
36967         this_ptr_conv.inner = untag_ptr(this_ptr);
36968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36970         this_ptr_conv.is_owned = false;
36971         LDKPublicKey val_ref;
36972         CHECK((*env)->GetArrayLength(env, val) == 33);
36973         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36974         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
36975 }
36976
36977 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
36978         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
36979         int64_t ret_ref = 0;
36980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36982         return ret_ref;
36983 }
36984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36985         LDKUnsignedChannelAnnouncement arg_conv;
36986         arg_conv.inner = untag_ptr(arg);
36987         arg_conv.is_owned = ptr_is_owned(arg);
36988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36989         arg_conv.is_owned = false;
36990         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
36991         return ret_conv;
36992 }
36993
36994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36995         LDKUnsignedChannelAnnouncement orig_conv;
36996         orig_conv.inner = untag_ptr(orig);
36997         orig_conv.is_owned = ptr_is_owned(orig);
36998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36999         orig_conv.is_owned = false;
37000         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
37001         int64_t ret_ref = 0;
37002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37004         return ret_ref;
37005 }
37006
37007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37008         LDKUnsignedChannelAnnouncement a_conv;
37009         a_conv.inner = untag_ptr(a);
37010         a_conv.is_owned = ptr_is_owned(a);
37011         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37012         a_conv.is_owned = false;
37013         LDKUnsignedChannelAnnouncement b_conv;
37014         b_conv.inner = untag_ptr(b);
37015         b_conv.is_owned = ptr_is_owned(b);
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37017         b_conv.is_owned = false;
37018         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
37019         return ret_conv;
37020 }
37021
37022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37023         LDKChannelAnnouncement this_obj_conv;
37024         this_obj_conv.inner = untag_ptr(this_obj);
37025         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37027         ChannelAnnouncement_free(this_obj_conv);
37028 }
37029
37030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37031         LDKChannelAnnouncement this_ptr_conv;
37032         this_ptr_conv.inner = untag_ptr(this_ptr);
37033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37035         this_ptr_conv.is_owned = false;
37036         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
37038         return ret_arr;
37039 }
37040
37041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37042         LDKChannelAnnouncement this_ptr_conv;
37043         this_ptr_conv.inner = untag_ptr(this_ptr);
37044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37046         this_ptr_conv.is_owned = false;
37047         LDKSignature val_ref;
37048         CHECK((*env)->GetArrayLength(env, val) == 64);
37049         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37050         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
37051 }
37052
37053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37054         LDKChannelAnnouncement this_ptr_conv;
37055         this_ptr_conv.inner = untag_ptr(this_ptr);
37056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37058         this_ptr_conv.is_owned = false;
37059         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
37061         return ret_arr;
37062 }
37063
37064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37065         LDKChannelAnnouncement this_ptr_conv;
37066         this_ptr_conv.inner = untag_ptr(this_ptr);
37067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37069         this_ptr_conv.is_owned = false;
37070         LDKSignature val_ref;
37071         CHECK((*env)->GetArrayLength(env, val) == 64);
37072         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37073         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
37074 }
37075
37076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37077         LDKChannelAnnouncement this_ptr_conv;
37078         this_ptr_conv.inner = untag_ptr(this_ptr);
37079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37081         this_ptr_conv.is_owned = false;
37082         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
37084         return ret_arr;
37085 }
37086
37087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37088         LDKChannelAnnouncement this_ptr_conv;
37089         this_ptr_conv.inner = untag_ptr(this_ptr);
37090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37092         this_ptr_conv.is_owned = false;
37093         LDKSignature val_ref;
37094         CHECK((*env)->GetArrayLength(env, val) == 64);
37095         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37096         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
37097 }
37098
37099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37100         LDKChannelAnnouncement this_ptr_conv;
37101         this_ptr_conv.inner = untag_ptr(this_ptr);
37102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37104         this_ptr_conv.is_owned = false;
37105         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37106         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
37107         return ret_arr;
37108 }
37109
37110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37111         LDKChannelAnnouncement this_ptr_conv;
37112         this_ptr_conv.inner = untag_ptr(this_ptr);
37113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37115         this_ptr_conv.is_owned = false;
37116         LDKSignature val_ref;
37117         CHECK((*env)->GetArrayLength(env, val) == 64);
37118         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37119         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
37120 }
37121
37122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37123         LDKChannelAnnouncement this_ptr_conv;
37124         this_ptr_conv.inner = untag_ptr(this_ptr);
37125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37127         this_ptr_conv.is_owned = false;
37128         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
37129         int64_t ret_ref = 0;
37130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37132         return ret_ref;
37133 }
37134
37135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37136         LDKChannelAnnouncement this_ptr_conv;
37137         this_ptr_conv.inner = untag_ptr(this_ptr);
37138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37140         this_ptr_conv.is_owned = false;
37141         LDKUnsignedChannelAnnouncement val_conv;
37142         val_conv.inner = untag_ptr(val);
37143         val_conv.is_owned = ptr_is_owned(val);
37144         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37145         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
37146         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
37147 }
37148
37149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray node_signature_1_arg, int8_tArray node_signature_2_arg, int8_tArray bitcoin_signature_1_arg, int8_tArray bitcoin_signature_2_arg, int64_t contents_arg) {
37150         LDKSignature node_signature_1_arg_ref;
37151         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
37152         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
37153         LDKSignature node_signature_2_arg_ref;
37154         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
37155         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
37156         LDKSignature bitcoin_signature_1_arg_ref;
37157         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
37158         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
37159         LDKSignature bitcoin_signature_2_arg_ref;
37160         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
37161         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
37162         LDKUnsignedChannelAnnouncement contents_arg_conv;
37163         contents_arg_conv.inner = untag_ptr(contents_arg);
37164         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37165         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37166         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
37167         LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
37168         int64_t ret_ref = 0;
37169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37171         return ret_ref;
37172 }
37173
37174 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
37175         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
37176         int64_t ret_ref = 0;
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37179         return ret_ref;
37180 }
37181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37182         LDKChannelAnnouncement arg_conv;
37183         arg_conv.inner = untag_ptr(arg);
37184         arg_conv.is_owned = ptr_is_owned(arg);
37185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37186         arg_conv.is_owned = false;
37187         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
37188         return ret_conv;
37189 }
37190
37191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37192         LDKChannelAnnouncement orig_conv;
37193         orig_conv.inner = untag_ptr(orig);
37194         orig_conv.is_owned = ptr_is_owned(orig);
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37196         orig_conv.is_owned = false;
37197         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
37198         int64_t ret_ref = 0;
37199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37201         return ret_ref;
37202 }
37203
37204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37205         LDKChannelAnnouncement a_conv;
37206         a_conv.inner = untag_ptr(a);
37207         a_conv.is_owned = ptr_is_owned(a);
37208         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37209         a_conv.is_owned = false;
37210         LDKChannelAnnouncement b_conv;
37211         b_conv.inner = untag_ptr(b);
37212         b_conv.is_owned = ptr_is_owned(b);
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37214         b_conv.is_owned = false;
37215         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
37216         return ret_conv;
37217 }
37218
37219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37220         LDKUnsignedChannelUpdate this_obj_conv;
37221         this_obj_conv.inner = untag_ptr(this_obj);
37222         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37224         UnsignedChannelUpdate_free(this_obj_conv);
37225 }
37226
37227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37228         LDKUnsignedChannelUpdate this_ptr_conv;
37229         this_ptr_conv.inner = untag_ptr(this_ptr);
37230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37232         this_ptr_conv.is_owned = false;
37233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
37235         return ret_arr;
37236 }
37237
37238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37239         LDKUnsignedChannelUpdate this_ptr_conv;
37240         this_ptr_conv.inner = untag_ptr(this_ptr);
37241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37243         this_ptr_conv.is_owned = false;
37244         LDKThirtyTwoBytes val_ref;
37245         CHECK((*env)->GetArrayLength(env, val) == 32);
37246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37247         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
37248 }
37249
37250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37251         LDKUnsignedChannelUpdate this_ptr_conv;
37252         this_ptr_conv.inner = untag_ptr(this_ptr);
37253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37255         this_ptr_conv.is_owned = false;
37256         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
37257         return ret_conv;
37258 }
37259
37260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37261         LDKUnsignedChannelUpdate this_ptr_conv;
37262         this_ptr_conv.inner = untag_ptr(this_ptr);
37263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37265         this_ptr_conv.is_owned = false;
37266         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
37267 }
37268
37269 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
37270         LDKUnsignedChannelUpdate this_ptr_conv;
37271         this_ptr_conv.inner = untag_ptr(this_ptr);
37272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37274         this_ptr_conv.is_owned = false;
37275         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
37276         return ret_conv;
37277 }
37278
37279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37280         LDKUnsignedChannelUpdate this_ptr_conv;
37281         this_ptr_conv.inner = untag_ptr(this_ptr);
37282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37284         this_ptr_conv.is_owned = false;
37285         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
37286 }
37287
37288 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
37289         LDKUnsignedChannelUpdate this_ptr_conv;
37290         this_ptr_conv.inner = untag_ptr(this_ptr);
37291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37293         this_ptr_conv.is_owned = false;
37294         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
37295         return ret_conv;
37296 }
37297
37298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
37299         LDKUnsignedChannelUpdate this_ptr_conv;
37300         this_ptr_conv.inner = untag_ptr(this_ptr);
37301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37303         this_ptr_conv.is_owned = false;
37304         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
37305 }
37306
37307 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37308         LDKUnsignedChannelUpdate this_ptr_conv;
37309         this_ptr_conv.inner = untag_ptr(this_ptr);
37310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37312         this_ptr_conv.is_owned = false;
37313         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
37314         return ret_conv;
37315 }
37316
37317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37318         LDKUnsignedChannelUpdate this_ptr_conv;
37319         this_ptr_conv.inner = untag_ptr(this_ptr);
37320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37322         this_ptr_conv.is_owned = false;
37323         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
37324 }
37325
37326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37327         LDKUnsignedChannelUpdate this_ptr_conv;
37328         this_ptr_conv.inner = untag_ptr(this_ptr);
37329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37331         this_ptr_conv.is_owned = false;
37332         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
37333         return ret_conv;
37334 }
37335
37336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37337         LDKUnsignedChannelUpdate this_ptr_conv;
37338         this_ptr_conv.inner = untag_ptr(this_ptr);
37339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37341         this_ptr_conv.is_owned = false;
37342         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
37343 }
37344
37345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37346         LDKUnsignedChannelUpdate this_ptr_conv;
37347         this_ptr_conv.inner = untag_ptr(this_ptr);
37348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37350         this_ptr_conv.is_owned = false;
37351         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
37352         return ret_conv;
37353 }
37354
37355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37356         LDKUnsignedChannelUpdate this_ptr_conv;
37357         this_ptr_conv.inner = untag_ptr(this_ptr);
37358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37360         this_ptr_conv.is_owned = false;
37361         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
37362 }
37363
37364 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37365         LDKUnsignedChannelUpdate this_ptr_conv;
37366         this_ptr_conv.inner = untag_ptr(this_ptr);
37367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37369         this_ptr_conv.is_owned = false;
37370         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
37371         return ret_conv;
37372 }
37373
37374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37375         LDKUnsignedChannelUpdate this_ptr_conv;
37376         this_ptr_conv.inner = untag_ptr(this_ptr);
37377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37379         this_ptr_conv.is_owned = false;
37380         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
37381 }
37382
37383 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
37384         LDKUnsignedChannelUpdate this_ptr_conv;
37385         this_ptr_conv.inner = untag_ptr(this_ptr);
37386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37388         this_ptr_conv.is_owned = false;
37389         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
37390         return ret_conv;
37391 }
37392
37393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37394         LDKUnsignedChannelUpdate this_ptr_conv;
37395         this_ptr_conv.inner = untag_ptr(this_ptr);
37396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37398         this_ptr_conv.is_owned = false;
37399         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
37400 }
37401
37402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
37403         LDKUnsignedChannelUpdate this_ptr_conv;
37404         this_ptr_conv.inner = untag_ptr(this_ptr);
37405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37407         this_ptr_conv.is_owned = false;
37408         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
37409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37411         CVec_u8Z_free(ret_var);
37412         return ret_arr;
37413 }
37414
37415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37416         LDKUnsignedChannelUpdate this_ptr_conv;
37417         this_ptr_conv.inner = untag_ptr(this_ptr);
37418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37420         this_ptr_conv.is_owned = false;
37421         LDKCVec_u8Z val_ref;
37422         val_ref.datalen = (*env)->GetArrayLength(env, val);
37423         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
37424         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
37425         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
37426 }
37427
37428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
37429         LDKThirtyTwoBytes chain_hash_arg_ref;
37430         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37431         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37432         LDKCVec_u8Z excess_data_arg_ref;
37433         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
37434         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
37435         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
37436         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
37437         int64_t ret_ref = 0;
37438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37440         return ret_ref;
37441 }
37442
37443 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
37444         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
37445         int64_t ret_ref = 0;
37446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37448         return ret_ref;
37449 }
37450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37451         LDKUnsignedChannelUpdate arg_conv;
37452         arg_conv.inner = untag_ptr(arg);
37453         arg_conv.is_owned = ptr_is_owned(arg);
37454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37455         arg_conv.is_owned = false;
37456         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
37457         return ret_conv;
37458 }
37459
37460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37461         LDKUnsignedChannelUpdate orig_conv;
37462         orig_conv.inner = untag_ptr(orig);
37463         orig_conv.is_owned = ptr_is_owned(orig);
37464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37465         orig_conv.is_owned = false;
37466         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
37467         int64_t ret_ref = 0;
37468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37470         return ret_ref;
37471 }
37472
37473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37474         LDKUnsignedChannelUpdate a_conv;
37475         a_conv.inner = untag_ptr(a);
37476         a_conv.is_owned = ptr_is_owned(a);
37477         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37478         a_conv.is_owned = false;
37479         LDKUnsignedChannelUpdate b_conv;
37480         b_conv.inner = untag_ptr(b);
37481         b_conv.is_owned = ptr_is_owned(b);
37482         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37483         b_conv.is_owned = false;
37484         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
37485         return ret_conv;
37486 }
37487
37488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37489         LDKChannelUpdate this_obj_conv;
37490         this_obj_conv.inner = untag_ptr(this_obj);
37491         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37493         ChannelUpdate_free(this_obj_conv);
37494 }
37495
37496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37497         LDKChannelUpdate this_ptr_conv;
37498         this_ptr_conv.inner = untag_ptr(this_ptr);
37499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37501         this_ptr_conv.is_owned = false;
37502         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
37504         return ret_arr;
37505 }
37506
37507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37508         LDKChannelUpdate this_ptr_conv;
37509         this_ptr_conv.inner = untag_ptr(this_ptr);
37510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37512         this_ptr_conv.is_owned = false;
37513         LDKSignature val_ref;
37514         CHECK((*env)->GetArrayLength(env, val) == 64);
37515         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37516         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
37517 }
37518
37519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37520         LDKChannelUpdate this_ptr_conv;
37521         this_ptr_conv.inner = untag_ptr(this_ptr);
37522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37524         this_ptr_conv.is_owned = false;
37525         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
37526         int64_t ret_ref = 0;
37527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37529         return ret_ref;
37530 }
37531
37532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37533         LDKChannelUpdate this_ptr_conv;
37534         this_ptr_conv.inner = untag_ptr(this_ptr);
37535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37537         this_ptr_conv.is_owned = false;
37538         LDKUnsignedChannelUpdate val_conv;
37539         val_conv.inner = untag_ptr(val);
37540         val_conv.is_owned = ptr_is_owned(val);
37541         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37542         val_conv = UnsignedChannelUpdate_clone(&val_conv);
37543         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
37544 }
37545
37546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
37547         LDKSignature signature_arg_ref;
37548         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37549         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37550         LDKUnsignedChannelUpdate contents_arg_conv;
37551         contents_arg_conv.inner = untag_ptr(contents_arg);
37552         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37553         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37554         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
37555         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
37556         int64_t ret_ref = 0;
37557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37559         return ret_ref;
37560 }
37561
37562 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
37563         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
37564         int64_t ret_ref = 0;
37565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37567         return ret_ref;
37568 }
37569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37570         LDKChannelUpdate arg_conv;
37571         arg_conv.inner = untag_ptr(arg);
37572         arg_conv.is_owned = ptr_is_owned(arg);
37573         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37574         arg_conv.is_owned = false;
37575         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
37576         return ret_conv;
37577 }
37578
37579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37580         LDKChannelUpdate orig_conv;
37581         orig_conv.inner = untag_ptr(orig);
37582         orig_conv.is_owned = ptr_is_owned(orig);
37583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37584         orig_conv.is_owned = false;
37585         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
37586         int64_t ret_ref = 0;
37587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37589         return ret_ref;
37590 }
37591
37592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37593         LDKChannelUpdate a_conv;
37594         a_conv.inner = untag_ptr(a);
37595         a_conv.is_owned = ptr_is_owned(a);
37596         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37597         a_conv.is_owned = false;
37598         LDKChannelUpdate b_conv;
37599         b_conv.inner = untag_ptr(b);
37600         b_conv.is_owned = ptr_is_owned(b);
37601         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37602         b_conv.is_owned = false;
37603         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
37604         return ret_conv;
37605 }
37606
37607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37608         LDKQueryChannelRange this_obj_conv;
37609         this_obj_conv.inner = untag_ptr(this_obj);
37610         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37612         QueryChannelRange_free(this_obj_conv);
37613 }
37614
37615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37616         LDKQueryChannelRange this_ptr_conv;
37617         this_ptr_conv.inner = untag_ptr(this_ptr);
37618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37620         this_ptr_conv.is_owned = false;
37621         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37622         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
37623         return ret_arr;
37624 }
37625
37626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37627         LDKQueryChannelRange this_ptr_conv;
37628         this_ptr_conv.inner = untag_ptr(this_ptr);
37629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37631         this_ptr_conv.is_owned = false;
37632         LDKThirtyTwoBytes val_ref;
37633         CHECK((*env)->GetArrayLength(env, val) == 32);
37634         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37635         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
37636 }
37637
37638 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
37639         LDKQueryChannelRange this_ptr_conv;
37640         this_ptr_conv.inner = untag_ptr(this_ptr);
37641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37643         this_ptr_conv.is_owned = false;
37644         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
37645         return ret_conv;
37646 }
37647
37648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37649         LDKQueryChannelRange this_ptr_conv;
37650         this_ptr_conv.inner = untag_ptr(this_ptr);
37651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37653         this_ptr_conv.is_owned = false;
37654         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
37655 }
37656
37657 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
37658         LDKQueryChannelRange this_ptr_conv;
37659         this_ptr_conv.inner = untag_ptr(this_ptr);
37660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37662         this_ptr_conv.is_owned = false;
37663         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
37664         return ret_conv;
37665 }
37666
37667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37668         LDKQueryChannelRange this_ptr_conv;
37669         this_ptr_conv.inner = untag_ptr(this_ptr);
37670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37672         this_ptr_conv.is_owned = false;
37673         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
37674 }
37675
37676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
37677         LDKThirtyTwoBytes chain_hash_arg_ref;
37678         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37679         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37680         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
37681         int64_t ret_ref = 0;
37682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37684         return ret_ref;
37685 }
37686
37687 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
37688         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
37689         int64_t ret_ref = 0;
37690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37692         return ret_ref;
37693 }
37694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37695         LDKQueryChannelRange arg_conv;
37696         arg_conv.inner = untag_ptr(arg);
37697         arg_conv.is_owned = ptr_is_owned(arg);
37698         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37699         arg_conv.is_owned = false;
37700         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
37701         return ret_conv;
37702 }
37703
37704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37705         LDKQueryChannelRange orig_conv;
37706         orig_conv.inner = untag_ptr(orig);
37707         orig_conv.is_owned = ptr_is_owned(orig);
37708         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37709         orig_conv.is_owned = false;
37710         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
37711         int64_t ret_ref = 0;
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37714         return ret_ref;
37715 }
37716
37717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37718         LDKQueryChannelRange a_conv;
37719         a_conv.inner = untag_ptr(a);
37720         a_conv.is_owned = ptr_is_owned(a);
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37722         a_conv.is_owned = false;
37723         LDKQueryChannelRange b_conv;
37724         b_conv.inner = untag_ptr(b);
37725         b_conv.is_owned = ptr_is_owned(b);
37726         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37727         b_conv.is_owned = false;
37728         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
37729         return ret_conv;
37730 }
37731
37732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37733         LDKReplyChannelRange this_obj_conv;
37734         this_obj_conv.inner = untag_ptr(this_obj);
37735         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37737         ReplyChannelRange_free(this_obj_conv);
37738 }
37739
37740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37741         LDKReplyChannelRange this_ptr_conv;
37742         this_ptr_conv.inner = untag_ptr(this_ptr);
37743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37745         this_ptr_conv.is_owned = false;
37746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
37748         return ret_arr;
37749 }
37750
37751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37752         LDKReplyChannelRange this_ptr_conv;
37753         this_ptr_conv.inner = untag_ptr(this_ptr);
37754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37756         this_ptr_conv.is_owned = false;
37757         LDKThirtyTwoBytes val_ref;
37758         CHECK((*env)->GetArrayLength(env, val) == 32);
37759         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37760         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
37761 }
37762
37763 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
37764         LDKReplyChannelRange this_ptr_conv;
37765         this_ptr_conv.inner = untag_ptr(this_ptr);
37766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37768         this_ptr_conv.is_owned = false;
37769         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
37770         return ret_conv;
37771 }
37772
37773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37774         LDKReplyChannelRange this_ptr_conv;
37775         this_ptr_conv.inner = untag_ptr(this_ptr);
37776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37778         this_ptr_conv.is_owned = false;
37779         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
37780 }
37781
37782 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
37783         LDKReplyChannelRange this_ptr_conv;
37784         this_ptr_conv.inner = untag_ptr(this_ptr);
37785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37787         this_ptr_conv.is_owned = false;
37788         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
37789         return ret_conv;
37790 }
37791
37792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37793         LDKReplyChannelRange this_ptr_conv;
37794         this_ptr_conv.inner = untag_ptr(this_ptr);
37795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37797         this_ptr_conv.is_owned = false;
37798         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
37799 }
37800
37801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
37802         LDKReplyChannelRange this_ptr_conv;
37803         this_ptr_conv.inner = untag_ptr(this_ptr);
37804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37806         this_ptr_conv.is_owned = false;
37807         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
37808         return ret_conv;
37809 }
37810
37811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37812         LDKReplyChannelRange this_ptr_conv;
37813         this_ptr_conv.inner = untag_ptr(this_ptr);
37814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37816         this_ptr_conv.is_owned = false;
37817         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
37818 }
37819
37820 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
37821         LDKReplyChannelRange this_ptr_conv;
37822         this_ptr_conv.inner = untag_ptr(this_ptr);
37823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37825         this_ptr_conv.is_owned = false;
37826         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
37827         int64_tArray ret_arr = NULL;
37828         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37829         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37830         for (size_t g = 0; g < ret_var.datalen; g++) {
37831                 int64_t ret_conv_6_conv = ret_var.data[g];
37832                 ret_arr_ptr[g] = ret_conv_6_conv;
37833         }
37834         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37835         FREE(ret_var.data);
37836         return ret_arr;
37837 }
37838
37839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37840         LDKReplyChannelRange this_ptr_conv;
37841         this_ptr_conv.inner = untag_ptr(this_ptr);
37842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37844         this_ptr_conv.is_owned = false;
37845         LDKCVec_u64Z val_constr;
37846         val_constr.datalen = (*env)->GetArrayLength(env, val);
37847         if (val_constr.datalen > 0)
37848                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37849         else
37850                 val_constr.data = NULL;
37851         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37852         for (size_t g = 0; g < val_constr.datalen; g++) {
37853                 int64_t val_conv_6 = val_vals[g];
37854                 val_constr.data[g] = val_conv_6;
37855         }
37856         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37857         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
37858 }
37859
37860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg, jboolean sync_complete_arg, int64_tArray short_channel_ids_arg) {
37861         LDKThirtyTwoBytes chain_hash_arg_ref;
37862         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37863         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37864         LDKCVec_u64Z short_channel_ids_arg_constr;
37865         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
37866         if (short_channel_ids_arg_constr.datalen > 0)
37867                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37868         else
37869                 short_channel_ids_arg_constr.data = NULL;
37870         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
37871         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
37872                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
37873                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
37874         }
37875         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
37876         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
37877         int64_t ret_ref = 0;
37878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37880         return ret_ref;
37881 }
37882
37883 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
37884         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
37885         int64_t ret_ref = 0;
37886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37888         return ret_ref;
37889 }
37890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37891         LDKReplyChannelRange arg_conv;
37892         arg_conv.inner = untag_ptr(arg);
37893         arg_conv.is_owned = ptr_is_owned(arg);
37894         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37895         arg_conv.is_owned = false;
37896         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
37897         return ret_conv;
37898 }
37899
37900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37901         LDKReplyChannelRange orig_conv;
37902         orig_conv.inner = untag_ptr(orig);
37903         orig_conv.is_owned = ptr_is_owned(orig);
37904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37905         orig_conv.is_owned = false;
37906         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
37907         int64_t ret_ref = 0;
37908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37910         return ret_ref;
37911 }
37912
37913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37914         LDKReplyChannelRange a_conv;
37915         a_conv.inner = untag_ptr(a);
37916         a_conv.is_owned = ptr_is_owned(a);
37917         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37918         a_conv.is_owned = false;
37919         LDKReplyChannelRange b_conv;
37920         b_conv.inner = untag_ptr(b);
37921         b_conv.is_owned = ptr_is_owned(b);
37922         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37923         b_conv.is_owned = false;
37924         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
37925         return ret_conv;
37926 }
37927
37928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37929         LDKQueryShortChannelIds this_obj_conv;
37930         this_obj_conv.inner = untag_ptr(this_obj);
37931         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37933         QueryShortChannelIds_free(this_obj_conv);
37934 }
37935
37936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37937         LDKQueryShortChannelIds this_ptr_conv;
37938         this_ptr_conv.inner = untag_ptr(this_ptr);
37939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37941         this_ptr_conv.is_owned = false;
37942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
37944         return ret_arr;
37945 }
37946
37947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37948         LDKQueryShortChannelIds this_ptr_conv;
37949         this_ptr_conv.inner = untag_ptr(this_ptr);
37950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37952         this_ptr_conv.is_owned = false;
37953         LDKThirtyTwoBytes val_ref;
37954         CHECK((*env)->GetArrayLength(env, val) == 32);
37955         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37956         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
37957 }
37958
37959 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
37960         LDKQueryShortChannelIds this_ptr_conv;
37961         this_ptr_conv.inner = untag_ptr(this_ptr);
37962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37964         this_ptr_conv.is_owned = false;
37965         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
37966         int64_tArray ret_arr = NULL;
37967         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37968         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37969         for (size_t g = 0; g < ret_var.datalen; g++) {
37970                 int64_t ret_conv_6_conv = ret_var.data[g];
37971                 ret_arr_ptr[g] = ret_conv_6_conv;
37972         }
37973         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37974         FREE(ret_var.data);
37975         return ret_arr;
37976 }
37977
37978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37979         LDKQueryShortChannelIds this_ptr_conv;
37980         this_ptr_conv.inner = untag_ptr(this_ptr);
37981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37983         this_ptr_conv.is_owned = false;
37984         LDKCVec_u64Z val_constr;
37985         val_constr.datalen = (*env)->GetArrayLength(env, val);
37986         if (val_constr.datalen > 0)
37987                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37988         else
37989                 val_constr.data = NULL;
37990         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37991         for (size_t g = 0; g < val_constr.datalen; g++) {
37992                 int64_t val_conv_6 = val_vals[g];
37993                 val_constr.data[g] = val_conv_6;
37994         }
37995         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37996         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
37997 }
37998
37999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
38000         LDKThirtyTwoBytes chain_hash_arg_ref;
38001         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38002         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38003         LDKCVec_u64Z short_channel_ids_arg_constr;
38004         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
38005         if (short_channel_ids_arg_constr.datalen > 0)
38006                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38007         else
38008                 short_channel_ids_arg_constr.data = NULL;
38009         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
38010         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
38011                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
38012                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
38013         }
38014         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
38015         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
38016         int64_t ret_ref = 0;
38017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38019         return ret_ref;
38020 }
38021
38022 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
38023         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
38024         int64_t ret_ref = 0;
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38027         return ret_ref;
38028 }
38029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38030         LDKQueryShortChannelIds arg_conv;
38031         arg_conv.inner = untag_ptr(arg);
38032         arg_conv.is_owned = ptr_is_owned(arg);
38033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38034         arg_conv.is_owned = false;
38035         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
38036         return ret_conv;
38037 }
38038
38039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38040         LDKQueryShortChannelIds orig_conv;
38041         orig_conv.inner = untag_ptr(orig);
38042         orig_conv.is_owned = ptr_is_owned(orig);
38043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38044         orig_conv.is_owned = false;
38045         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
38046         int64_t ret_ref = 0;
38047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38049         return ret_ref;
38050 }
38051
38052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38053         LDKQueryShortChannelIds a_conv;
38054         a_conv.inner = untag_ptr(a);
38055         a_conv.is_owned = ptr_is_owned(a);
38056         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38057         a_conv.is_owned = false;
38058         LDKQueryShortChannelIds b_conv;
38059         b_conv.inner = untag_ptr(b);
38060         b_conv.is_owned = ptr_is_owned(b);
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38062         b_conv.is_owned = false;
38063         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
38064         return ret_conv;
38065 }
38066
38067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38068         LDKReplyShortChannelIdsEnd this_obj_conv;
38069         this_obj_conv.inner = untag_ptr(this_obj);
38070         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38072         ReplyShortChannelIdsEnd_free(this_obj_conv);
38073 }
38074
38075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38076         LDKReplyShortChannelIdsEnd this_ptr_conv;
38077         this_ptr_conv.inner = untag_ptr(this_ptr);
38078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38080         this_ptr_conv.is_owned = false;
38081         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
38083         return ret_arr;
38084 }
38085
38086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38087         LDKReplyShortChannelIdsEnd this_ptr_conv;
38088         this_ptr_conv.inner = untag_ptr(this_ptr);
38089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38091         this_ptr_conv.is_owned = false;
38092         LDKThirtyTwoBytes val_ref;
38093         CHECK((*env)->GetArrayLength(env, val) == 32);
38094         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38095         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
38096 }
38097
38098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
38099         LDKReplyShortChannelIdsEnd this_ptr_conv;
38100         this_ptr_conv.inner = untag_ptr(this_ptr);
38101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38103         this_ptr_conv.is_owned = false;
38104         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
38105         return ret_conv;
38106 }
38107
38108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38109         LDKReplyShortChannelIdsEnd this_ptr_conv;
38110         this_ptr_conv.inner = untag_ptr(this_ptr);
38111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38113         this_ptr_conv.is_owned = false;
38114         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
38115 }
38116
38117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
38118         LDKThirtyTwoBytes chain_hash_arg_ref;
38119         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38120         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38121         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
38122         int64_t ret_ref = 0;
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38125         return ret_ref;
38126 }
38127
38128 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
38129         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
38130         int64_t ret_ref = 0;
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38133         return ret_ref;
38134 }
38135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38136         LDKReplyShortChannelIdsEnd arg_conv;
38137         arg_conv.inner = untag_ptr(arg);
38138         arg_conv.is_owned = ptr_is_owned(arg);
38139         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38140         arg_conv.is_owned = false;
38141         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
38142         return ret_conv;
38143 }
38144
38145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38146         LDKReplyShortChannelIdsEnd orig_conv;
38147         orig_conv.inner = untag_ptr(orig);
38148         orig_conv.is_owned = ptr_is_owned(orig);
38149         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38150         orig_conv.is_owned = false;
38151         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
38152         int64_t ret_ref = 0;
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38155         return ret_ref;
38156 }
38157
38158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38159         LDKReplyShortChannelIdsEnd a_conv;
38160         a_conv.inner = untag_ptr(a);
38161         a_conv.is_owned = ptr_is_owned(a);
38162         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38163         a_conv.is_owned = false;
38164         LDKReplyShortChannelIdsEnd b_conv;
38165         b_conv.inner = untag_ptr(b);
38166         b_conv.is_owned = ptr_is_owned(b);
38167         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38168         b_conv.is_owned = false;
38169         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
38170         return ret_conv;
38171 }
38172
38173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38174         LDKGossipTimestampFilter this_obj_conv;
38175         this_obj_conv.inner = untag_ptr(this_obj);
38176         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38178         GossipTimestampFilter_free(this_obj_conv);
38179 }
38180
38181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38182         LDKGossipTimestampFilter this_ptr_conv;
38183         this_ptr_conv.inner = untag_ptr(this_ptr);
38184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38186         this_ptr_conv.is_owned = false;
38187         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
38189         return ret_arr;
38190 }
38191
38192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38193         LDKGossipTimestampFilter this_ptr_conv;
38194         this_ptr_conv.inner = untag_ptr(this_ptr);
38195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38197         this_ptr_conv.is_owned = false;
38198         LDKThirtyTwoBytes val_ref;
38199         CHECK((*env)->GetArrayLength(env, val) == 32);
38200         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38201         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
38202 }
38203
38204 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38205         LDKGossipTimestampFilter this_ptr_conv;
38206         this_ptr_conv.inner = untag_ptr(this_ptr);
38207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38209         this_ptr_conv.is_owned = false;
38210         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
38211         return ret_conv;
38212 }
38213
38214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38215         LDKGossipTimestampFilter this_ptr_conv;
38216         this_ptr_conv.inner = untag_ptr(this_ptr);
38217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38219         this_ptr_conv.is_owned = false;
38220         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
38221 }
38222
38223 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
38224         LDKGossipTimestampFilter this_ptr_conv;
38225         this_ptr_conv.inner = untag_ptr(this_ptr);
38226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38228         this_ptr_conv.is_owned = false;
38229         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
38230         return ret_conv;
38231 }
38232
38233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38234         LDKGossipTimestampFilter this_ptr_conv;
38235         this_ptr_conv.inner = untag_ptr(this_ptr);
38236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38238         this_ptr_conv.is_owned = false;
38239         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
38240 }
38241
38242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
38243         LDKThirtyTwoBytes chain_hash_arg_ref;
38244         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38245         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38246         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
38247         int64_t ret_ref = 0;
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38250         return ret_ref;
38251 }
38252
38253 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
38254         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
38255         int64_t ret_ref = 0;
38256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38258         return ret_ref;
38259 }
38260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38261         LDKGossipTimestampFilter arg_conv;
38262         arg_conv.inner = untag_ptr(arg);
38263         arg_conv.is_owned = ptr_is_owned(arg);
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38265         arg_conv.is_owned = false;
38266         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
38267         return ret_conv;
38268 }
38269
38270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38271         LDKGossipTimestampFilter orig_conv;
38272         orig_conv.inner = untag_ptr(orig);
38273         orig_conv.is_owned = ptr_is_owned(orig);
38274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38275         orig_conv.is_owned = false;
38276         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
38277         int64_t ret_ref = 0;
38278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38280         return ret_ref;
38281 }
38282
38283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38284         LDKGossipTimestampFilter a_conv;
38285         a_conv.inner = untag_ptr(a);
38286         a_conv.is_owned = ptr_is_owned(a);
38287         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38288         a_conv.is_owned = false;
38289         LDKGossipTimestampFilter b_conv;
38290         b_conv.inner = untag_ptr(b);
38291         b_conv.is_owned = ptr_is_owned(b);
38292         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38293         b_conv.is_owned = false;
38294         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
38295         return ret_conv;
38296 }
38297
38298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38299         if (!ptr_is_owned(this_ptr)) return;
38300         void* this_ptr_ptr = untag_ptr(this_ptr);
38301         CHECK_ACCESS(this_ptr_ptr);
38302         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
38303         FREE(untag_ptr(this_ptr));
38304         ErrorAction_free(this_ptr_conv);
38305 }
38306
38307 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
38308         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38309         *ret_copy = ErrorAction_clone(arg);
38310         int64_t ret_ref = tag_ptr(ret_copy, true);
38311         return ret_ref;
38312 }
38313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38314         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
38315         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
38316         return ret_conv;
38317 }
38318
38319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38320         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
38321         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38322         *ret_copy = ErrorAction_clone(orig_conv);
38323         int64_t ret_ref = tag_ptr(ret_copy, true);
38324         return ret_ref;
38325 }
38326
38327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
38328         LDKErrorMessage msg_conv;
38329         msg_conv.inner = untag_ptr(msg);
38330         msg_conv.is_owned = ptr_is_owned(msg);
38331         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38332         msg_conv = ErrorMessage_clone(&msg_conv);
38333         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38334         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
38335         int64_t ret_ref = tag_ptr(ret_copy, true);
38336         return ret_ref;
38337 }
38338
38339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
38340         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38341         *ret_copy = ErrorAction_ignore_error();
38342         int64_t ret_ref = tag_ptr(ret_copy, true);
38343         return ret_ref;
38344 }
38345
38346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
38347         LDKLevel a_conv = LDKLevel_from_java(env, a);
38348         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38349         *ret_copy = ErrorAction_ignore_and_log(a_conv);
38350         int64_t ret_ref = tag_ptr(ret_copy, true);
38351         return ret_ref;
38352 }
38353
38354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
38355         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38356         *ret_copy = ErrorAction_ignore_duplicate_gossip();
38357         int64_t ret_ref = tag_ptr(ret_copy, true);
38358         return ret_ref;
38359 }
38360
38361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
38362         LDKErrorMessage msg_conv;
38363         msg_conv.inner = untag_ptr(msg);
38364         msg_conv.is_owned = ptr_is_owned(msg);
38365         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38366         msg_conv = ErrorMessage_clone(&msg_conv);
38367         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38368         *ret_copy = ErrorAction_send_error_message(msg_conv);
38369         int64_t ret_ref = tag_ptr(ret_copy, true);
38370         return ret_ref;
38371 }
38372
38373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
38374         LDKWarningMessage msg_conv;
38375         msg_conv.inner = untag_ptr(msg);
38376         msg_conv.is_owned = ptr_is_owned(msg);
38377         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38378         msg_conv = WarningMessage_clone(&msg_conv);
38379         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
38380         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38381         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
38382         int64_t ret_ref = tag_ptr(ret_copy, true);
38383         return ret_ref;
38384 }
38385
38386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38387         LDKLightningError this_obj_conv;
38388         this_obj_conv.inner = untag_ptr(this_obj);
38389         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38391         LightningError_free(this_obj_conv);
38392 }
38393
38394 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
38395         LDKLightningError this_ptr_conv;
38396         this_ptr_conv.inner = untag_ptr(this_ptr);
38397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38399         this_ptr_conv.is_owned = false;
38400         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
38401         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
38402         Str_free(ret_str);
38403         return ret_conv;
38404 }
38405
38406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
38407         LDKLightningError this_ptr_conv;
38408         this_ptr_conv.inner = untag_ptr(this_ptr);
38409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38411         this_ptr_conv.is_owned = false;
38412         LDKStr val_conv = java_to_owned_str(env, val);
38413         LightningError_set_err(&this_ptr_conv, val_conv);
38414 }
38415
38416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
38417         LDKLightningError this_ptr_conv;
38418         this_ptr_conv.inner = untag_ptr(this_ptr);
38419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38421         this_ptr_conv.is_owned = false;
38422         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38423         *ret_copy = LightningError_get_action(&this_ptr_conv);
38424         int64_t ret_ref = tag_ptr(ret_copy, true);
38425         return ret_ref;
38426 }
38427
38428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38429         LDKLightningError this_ptr_conv;
38430         this_ptr_conv.inner = untag_ptr(this_ptr);
38431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38433         this_ptr_conv.is_owned = false;
38434         void* val_ptr = untag_ptr(val);
38435         CHECK_ACCESS(val_ptr);
38436         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
38437         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
38438         LightningError_set_action(&this_ptr_conv, val_conv);
38439 }
38440
38441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
38442         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
38443         void* action_arg_ptr = untag_ptr(action_arg);
38444         CHECK_ACCESS(action_arg_ptr);
38445         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
38446         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
38447         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
38448         int64_t ret_ref = 0;
38449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38451         return ret_ref;
38452 }
38453
38454 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
38455         LDKLightningError ret_var = LightningError_clone(arg);
38456         int64_t ret_ref = 0;
38457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38458         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38459         return ret_ref;
38460 }
38461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38462         LDKLightningError arg_conv;
38463         arg_conv.inner = untag_ptr(arg);
38464         arg_conv.is_owned = ptr_is_owned(arg);
38465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38466         arg_conv.is_owned = false;
38467         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
38468         return ret_conv;
38469 }
38470
38471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38472         LDKLightningError orig_conv;
38473         orig_conv.inner = untag_ptr(orig);
38474         orig_conv.is_owned = ptr_is_owned(orig);
38475         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38476         orig_conv.is_owned = false;
38477         LDKLightningError ret_var = LightningError_clone(&orig_conv);
38478         int64_t ret_ref = 0;
38479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38481         return ret_ref;
38482 }
38483
38484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38485         LDKCommitmentUpdate this_obj_conv;
38486         this_obj_conv.inner = untag_ptr(this_obj);
38487         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38489         CommitmentUpdate_free(this_obj_conv);
38490 }
38491
38492 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38493         LDKCommitmentUpdate this_ptr_conv;
38494         this_ptr_conv.inner = untag_ptr(this_ptr);
38495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38497         this_ptr_conv.is_owned = false;
38498         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
38499         int64_tArray ret_arr = NULL;
38500         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38501         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38502         for (size_t p = 0; p < ret_var.datalen; p++) {
38503                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
38504                 int64_t ret_conv_15_ref = 0;
38505                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
38506                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
38507                 ret_arr_ptr[p] = ret_conv_15_ref;
38508         }
38509         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38510         FREE(ret_var.data);
38511         return ret_arr;
38512 }
38513
38514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38515         LDKCommitmentUpdate this_ptr_conv;
38516         this_ptr_conv.inner = untag_ptr(this_ptr);
38517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38519         this_ptr_conv.is_owned = false;
38520         LDKCVec_UpdateAddHTLCZ val_constr;
38521         val_constr.datalen = (*env)->GetArrayLength(env, val);
38522         if (val_constr.datalen > 0)
38523                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
38524         else
38525                 val_constr.data = NULL;
38526         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38527         for (size_t p = 0; p < val_constr.datalen; p++) {
38528                 int64_t val_conv_15 = val_vals[p];
38529                 LDKUpdateAddHTLC val_conv_15_conv;
38530                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
38531                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
38532                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
38533                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
38534                 val_constr.data[p] = val_conv_15_conv;
38535         }
38536         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38537         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
38538 }
38539
38540 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38541         LDKCommitmentUpdate this_ptr_conv;
38542         this_ptr_conv.inner = untag_ptr(this_ptr);
38543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38545         this_ptr_conv.is_owned = false;
38546         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
38547         int64_tArray ret_arr = NULL;
38548         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38549         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38550         for (size_t t = 0; t < ret_var.datalen; t++) {
38551                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
38552                 int64_t ret_conv_19_ref = 0;
38553                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
38554                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
38555                 ret_arr_ptr[t] = ret_conv_19_ref;
38556         }
38557         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38558         FREE(ret_var.data);
38559         return ret_arr;
38560 }
38561
38562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38563         LDKCommitmentUpdate this_ptr_conv;
38564         this_ptr_conv.inner = untag_ptr(this_ptr);
38565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38567         this_ptr_conv.is_owned = false;
38568         LDKCVec_UpdateFulfillHTLCZ val_constr;
38569         val_constr.datalen = (*env)->GetArrayLength(env, val);
38570         if (val_constr.datalen > 0)
38571                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
38572         else
38573                 val_constr.data = NULL;
38574         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38575         for (size_t t = 0; t < val_constr.datalen; t++) {
38576                 int64_t val_conv_19 = val_vals[t];
38577                 LDKUpdateFulfillHTLC val_conv_19_conv;
38578                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
38579                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
38580                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
38581                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
38582                 val_constr.data[t] = val_conv_19_conv;
38583         }
38584         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38585         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
38586 }
38587
38588 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38589         LDKCommitmentUpdate this_ptr_conv;
38590         this_ptr_conv.inner = untag_ptr(this_ptr);
38591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38593         this_ptr_conv.is_owned = false;
38594         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
38595         int64_tArray ret_arr = NULL;
38596         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38597         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38598         for (size_t q = 0; q < ret_var.datalen; q++) {
38599                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
38600                 int64_t ret_conv_16_ref = 0;
38601                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
38602                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
38603                 ret_arr_ptr[q] = ret_conv_16_ref;
38604         }
38605         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38606         FREE(ret_var.data);
38607         return ret_arr;
38608 }
38609
38610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38611         LDKCommitmentUpdate this_ptr_conv;
38612         this_ptr_conv.inner = untag_ptr(this_ptr);
38613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38615         this_ptr_conv.is_owned = false;
38616         LDKCVec_UpdateFailHTLCZ val_constr;
38617         val_constr.datalen = (*env)->GetArrayLength(env, val);
38618         if (val_constr.datalen > 0)
38619                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
38620         else
38621                 val_constr.data = NULL;
38622         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38623         for (size_t q = 0; q < val_constr.datalen; q++) {
38624                 int64_t val_conv_16 = val_vals[q];
38625                 LDKUpdateFailHTLC val_conv_16_conv;
38626                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
38627                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
38628                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
38629                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
38630                 val_constr.data[q] = val_conv_16_conv;
38631         }
38632         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38633         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
38634 }
38635
38636 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38637         LDKCommitmentUpdate this_ptr_conv;
38638         this_ptr_conv.inner = untag_ptr(this_ptr);
38639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38641         this_ptr_conv.is_owned = false;
38642         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
38643         int64_tArray ret_arr = NULL;
38644         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38645         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38646         for (size_t z = 0; z < ret_var.datalen; z++) {
38647                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
38648                 int64_t ret_conv_25_ref = 0;
38649                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
38650                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
38651                 ret_arr_ptr[z] = ret_conv_25_ref;
38652         }
38653         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38654         FREE(ret_var.data);
38655         return ret_arr;
38656 }
38657
38658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38659         LDKCommitmentUpdate this_ptr_conv;
38660         this_ptr_conv.inner = untag_ptr(this_ptr);
38661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38663         this_ptr_conv.is_owned = false;
38664         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
38665         val_constr.datalen = (*env)->GetArrayLength(env, val);
38666         if (val_constr.datalen > 0)
38667                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
38668         else
38669                 val_constr.data = NULL;
38670         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38671         for (size_t z = 0; z < val_constr.datalen; z++) {
38672                 int64_t val_conv_25 = val_vals[z];
38673                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
38674                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
38675                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
38676                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
38677                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
38678                 val_constr.data[z] = val_conv_25_conv;
38679         }
38680         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38681         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
38682 }
38683
38684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
38685         LDKCommitmentUpdate this_ptr_conv;
38686         this_ptr_conv.inner = untag_ptr(this_ptr);
38687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38689         this_ptr_conv.is_owned = false;
38690         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
38691         int64_t ret_ref = 0;
38692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38694         return ret_ref;
38695 }
38696
38697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38698         LDKCommitmentUpdate this_ptr_conv;
38699         this_ptr_conv.inner = untag_ptr(this_ptr);
38700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38702         this_ptr_conv.is_owned = false;
38703         LDKUpdateFee val_conv;
38704         val_conv.inner = untag_ptr(val);
38705         val_conv.is_owned = ptr_is_owned(val);
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38707         val_conv = UpdateFee_clone(&val_conv);
38708         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
38709 }
38710
38711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
38712         LDKCommitmentUpdate this_ptr_conv;
38713         this_ptr_conv.inner = untag_ptr(this_ptr);
38714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38716         this_ptr_conv.is_owned = false;
38717         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
38718         int64_t ret_ref = 0;
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38721         return ret_ref;
38722 }
38723
38724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38725         LDKCommitmentUpdate this_ptr_conv;
38726         this_ptr_conv.inner = untag_ptr(this_ptr);
38727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38729         this_ptr_conv.is_owned = false;
38730         LDKCommitmentSigned val_conv;
38731         val_conv.inner = untag_ptr(val);
38732         val_conv.is_owned = ptr_is_owned(val);
38733         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38734         val_conv = CommitmentSigned_clone(&val_conv);
38735         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
38736 }
38737
38738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv *env, jclass clz, int64_tArray update_add_htlcs_arg, int64_tArray update_fulfill_htlcs_arg, int64_tArray update_fail_htlcs_arg, int64_tArray update_fail_malformed_htlcs_arg, int64_t update_fee_arg, int64_t commitment_signed_arg) {
38739         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
38740         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
38741         if (update_add_htlcs_arg_constr.datalen > 0)
38742                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
38743         else
38744                 update_add_htlcs_arg_constr.data = NULL;
38745         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
38746         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
38747                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
38748                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
38749                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
38750                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
38751                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
38752                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
38753                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
38754         }
38755         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
38756         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
38757         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
38758         if (update_fulfill_htlcs_arg_constr.datalen > 0)
38759                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
38760         else
38761                 update_fulfill_htlcs_arg_constr.data = NULL;
38762         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
38763         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
38764                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
38765                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
38766                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
38767                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
38768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
38769                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
38770                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
38771         }
38772         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
38773         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
38774         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
38775         if (update_fail_htlcs_arg_constr.datalen > 0)
38776                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
38777         else
38778                 update_fail_htlcs_arg_constr.data = NULL;
38779         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
38780         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
38781                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
38782                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
38783                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
38784                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
38785                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
38786                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
38787                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
38788         }
38789         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
38790         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
38791         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
38792         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
38793                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
38794         else
38795                 update_fail_malformed_htlcs_arg_constr.data = NULL;
38796         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
38797         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
38798                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
38799                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
38800                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
38801                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
38802                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
38803                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
38804                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
38805         }
38806         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
38807         LDKUpdateFee update_fee_arg_conv;
38808         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
38809         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
38811         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
38812         LDKCommitmentSigned commitment_signed_arg_conv;
38813         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
38814         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
38815         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
38816         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
38817         LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
38818         int64_t ret_ref = 0;
38819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38821         return ret_ref;
38822 }
38823
38824 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
38825         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
38826         int64_t ret_ref = 0;
38827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38829         return ret_ref;
38830 }
38831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38832         LDKCommitmentUpdate arg_conv;
38833         arg_conv.inner = untag_ptr(arg);
38834         arg_conv.is_owned = ptr_is_owned(arg);
38835         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38836         arg_conv.is_owned = false;
38837         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
38838         return ret_conv;
38839 }
38840
38841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38842         LDKCommitmentUpdate orig_conv;
38843         orig_conv.inner = untag_ptr(orig);
38844         orig_conv.is_owned = ptr_is_owned(orig);
38845         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38846         orig_conv.is_owned = false;
38847         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
38848         int64_t ret_ref = 0;
38849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38850         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38851         return ret_ref;
38852 }
38853
38854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38855         LDKCommitmentUpdate a_conv;
38856         a_conv.inner = untag_ptr(a);
38857         a_conv.is_owned = ptr_is_owned(a);
38858         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38859         a_conv.is_owned = false;
38860         LDKCommitmentUpdate b_conv;
38861         b_conv.inner = untag_ptr(b);
38862         b_conv.is_owned = ptr_is_owned(b);
38863         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38864         b_conv.is_owned = false;
38865         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
38866         return ret_conv;
38867 }
38868
38869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38870         if (!ptr_is_owned(this_ptr)) return;
38871         void* this_ptr_ptr = untag_ptr(this_ptr);
38872         CHECK_ACCESS(this_ptr_ptr);
38873         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
38874         FREE(untag_ptr(this_ptr));
38875         ChannelMessageHandler_free(this_ptr_conv);
38876 }
38877
38878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38879         if (!ptr_is_owned(this_ptr)) return;
38880         void* this_ptr_ptr = untag_ptr(this_ptr);
38881         CHECK_ACCESS(this_ptr_ptr);
38882         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
38883         FREE(untag_ptr(this_ptr));
38884         RoutingMessageHandler_free(this_ptr_conv);
38885 }
38886
38887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38888         if (!ptr_is_owned(this_ptr)) return;
38889         void* this_ptr_ptr = untag_ptr(this_ptr);
38890         CHECK_ACCESS(this_ptr_ptr);
38891         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
38892         FREE(untag_ptr(this_ptr));
38893         OnionMessageHandler_free(this_ptr_conv);
38894 }
38895
38896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
38897         LDKAcceptChannel obj_conv;
38898         obj_conv.inner = untag_ptr(obj);
38899         obj_conv.is_owned = ptr_is_owned(obj);
38900         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38901         obj_conv.is_owned = false;
38902         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
38903         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38904         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38905         CVec_u8Z_free(ret_var);
38906         return ret_arr;
38907 }
38908
38909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38910         LDKu8slice ser_ref;
38911         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38912         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38913         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
38914         *ret_conv = AcceptChannel_read(ser_ref);
38915         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38916         return tag_ptr(ret_conv, true);
38917 }
38918
38919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38920         LDKAnnouncementSignatures obj_conv;
38921         obj_conv.inner = untag_ptr(obj);
38922         obj_conv.is_owned = ptr_is_owned(obj);
38923         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38924         obj_conv.is_owned = false;
38925         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
38926         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38927         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38928         CVec_u8Z_free(ret_var);
38929         return ret_arr;
38930 }
38931
38932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38933         LDKu8slice ser_ref;
38934         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38935         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38936         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
38937         *ret_conv = AnnouncementSignatures_read(ser_ref);
38938         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38939         return tag_ptr(ret_conv, true);
38940 }
38941
38942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
38943         LDKChannelReestablish obj_conv;
38944         obj_conv.inner = untag_ptr(obj);
38945         obj_conv.is_owned = ptr_is_owned(obj);
38946         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38947         obj_conv.is_owned = false;
38948         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
38949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38951         CVec_u8Z_free(ret_var);
38952         return ret_arr;
38953 }
38954
38955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38956         LDKu8slice ser_ref;
38957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38959         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
38960         *ret_conv = ChannelReestablish_read(ser_ref);
38961         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38962         return tag_ptr(ret_conv, true);
38963 }
38964
38965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
38966         LDKClosingSigned obj_conv;
38967         obj_conv.inner = untag_ptr(obj);
38968         obj_conv.is_owned = ptr_is_owned(obj);
38969         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38970         obj_conv.is_owned = false;
38971         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
38972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38974         CVec_u8Z_free(ret_var);
38975         return ret_arr;
38976 }
38977
38978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38979         LDKu8slice ser_ref;
38980         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38981         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38982         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
38983         *ret_conv = ClosingSigned_read(ser_ref);
38984         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38985         return tag_ptr(ret_conv, true);
38986 }
38987
38988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38989         LDKClosingSignedFeeRange obj_conv;
38990         obj_conv.inner = untag_ptr(obj);
38991         obj_conv.is_owned = ptr_is_owned(obj);
38992         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38993         obj_conv.is_owned = false;
38994         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
38995         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38996         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38997         CVec_u8Z_free(ret_var);
38998         return ret_arr;
38999 }
39000
39001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39002         LDKu8slice ser_ref;
39003         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39004         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39005         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
39006         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
39007         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39008         return tag_ptr(ret_conv, true);
39009 }
39010
39011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
39012         LDKCommitmentSigned obj_conv;
39013         obj_conv.inner = untag_ptr(obj);
39014         obj_conv.is_owned = ptr_is_owned(obj);
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39016         obj_conv.is_owned = false;
39017         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
39018         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39019         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39020         CVec_u8Z_free(ret_var);
39021         return ret_arr;
39022 }
39023
39024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39025         LDKu8slice ser_ref;
39026         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39027         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39028         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
39029         *ret_conv = CommitmentSigned_read(ser_ref);
39030         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39031         return tag_ptr(ret_conv, true);
39032 }
39033
39034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
39035         LDKFundingCreated obj_conv;
39036         obj_conv.inner = untag_ptr(obj);
39037         obj_conv.is_owned = ptr_is_owned(obj);
39038         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39039         obj_conv.is_owned = false;
39040         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
39041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39043         CVec_u8Z_free(ret_var);
39044         return ret_arr;
39045 }
39046
39047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39048         LDKu8slice ser_ref;
39049         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39050         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39051         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
39052         *ret_conv = FundingCreated_read(ser_ref);
39053         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39054         return tag_ptr(ret_conv, true);
39055 }
39056
39057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
39058         LDKFundingSigned obj_conv;
39059         obj_conv.inner = untag_ptr(obj);
39060         obj_conv.is_owned = ptr_is_owned(obj);
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39062         obj_conv.is_owned = false;
39063         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
39064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39066         CVec_u8Z_free(ret_var);
39067         return ret_arr;
39068 }
39069
39070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39071         LDKu8slice ser_ref;
39072         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39073         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39074         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
39075         *ret_conv = FundingSigned_read(ser_ref);
39076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39077         return tag_ptr(ret_conv, true);
39078 }
39079
39080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
39081         LDKChannelReady obj_conv;
39082         obj_conv.inner = untag_ptr(obj);
39083         obj_conv.is_owned = ptr_is_owned(obj);
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39085         obj_conv.is_owned = false;
39086         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
39087         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39088         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39089         CVec_u8Z_free(ret_var);
39090         return ret_arr;
39091 }
39092
39093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39094         LDKu8slice ser_ref;
39095         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39096         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39097         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
39098         *ret_conv = ChannelReady_read(ser_ref);
39099         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39100         return tag_ptr(ret_conv, true);
39101 }
39102
39103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
39104         LDKInit obj_conv;
39105         obj_conv.inner = untag_ptr(obj);
39106         obj_conv.is_owned = ptr_is_owned(obj);
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39108         obj_conv.is_owned = false;
39109         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
39110         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39111         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39112         CVec_u8Z_free(ret_var);
39113         return ret_arr;
39114 }
39115
39116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39117         LDKu8slice ser_ref;
39118         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39119         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39120         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
39121         *ret_conv = Init_read(ser_ref);
39122         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39123         return tag_ptr(ret_conv, true);
39124 }
39125
39126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
39127         LDKOpenChannel obj_conv;
39128         obj_conv.inner = untag_ptr(obj);
39129         obj_conv.is_owned = ptr_is_owned(obj);
39130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39131         obj_conv.is_owned = false;
39132         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
39133         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39134         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39135         CVec_u8Z_free(ret_var);
39136         return ret_arr;
39137 }
39138
39139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39140         LDKu8slice ser_ref;
39141         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39142         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39143         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
39144         *ret_conv = OpenChannel_read(ser_ref);
39145         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39146         return tag_ptr(ret_conv, true);
39147 }
39148
39149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
39150         LDKRevokeAndACK obj_conv;
39151         obj_conv.inner = untag_ptr(obj);
39152         obj_conv.is_owned = ptr_is_owned(obj);
39153         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39154         obj_conv.is_owned = false;
39155         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
39156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39158         CVec_u8Z_free(ret_var);
39159         return ret_arr;
39160 }
39161
39162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39163         LDKu8slice ser_ref;
39164         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39165         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39166         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
39167         *ret_conv = RevokeAndACK_read(ser_ref);
39168         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39169         return tag_ptr(ret_conv, true);
39170 }
39171
39172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
39173         LDKShutdown obj_conv;
39174         obj_conv.inner = untag_ptr(obj);
39175         obj_conv.is_owned = ptr_is_owned(obj);
39176         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39177         obj_conv.is_owned = false;
39178         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
39179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39181         CVec_u8Z_free(ret_var);
39182         return ret_arr;
39183 }
39184
39185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39186         LDKu8slice ser_ref;
39187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39189         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
39190         *ret_conv = Shutdown_read(ser_ref);
39191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39192         return tag_ptr(ret_conv, true);
39193 }
39194
39195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39196         LDKUpdateFailHTLC obj_conv;
39197         obj_conv.inner = untag_ptr(obj);
39198         obj_conv.is_owned = ptr_is_owned(obj);
39199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39200         obj_conv.is_owned = false;
39201         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
39202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39204         CVec_u8Z_free(ret_var);
39205         return ret_arr;
39206 }
39207
39208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39209         LDKu8slice ser_ref;
39210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39212         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
39213         *ret_conv = UpdateFailHTLC_read(ser_ref);
39214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39215         return tag_ptr(ret_conv, true);
39216 }
39217
39218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39219         LDKUpdateFailMalformedHTLC obj_conv;
39220         obj_conv.inner = untag_ptr(obj);
39221         obj_conv.is_owned = ptr_is_owned(obj);
39222         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39223         obj_conv.is_owned = false;
39224         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
39225         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39226         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39227         CVec_u8Z_free(ret_var);
39228         return ret_arr;
39229 }
39230
39231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39232         LDKu8slice ser_ref;
39233         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39234         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39235         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
39236         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
39237         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39238         return tag_ptr(ret_conv, true);
39239 }
39240
39241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
39242         LDKUpdateFee obj_conv;
39243         obj_conv.inner = untag_ptr(obj);
39244         obj_conv.is_owned = ptr_is_owned(obj);
39245         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39246         obj_conv.is_owned = false;
39247         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
39248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39250         CVec_u8Z_free(ret_var);
39251         return ret_arr;
39252 }
39253
39254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39255         LDKu8slice ser_ref;
39256         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39257         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39258         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
39259         *ret_conv = UpdateFee_read(ser_ref);
39260         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39261         return tag_ptr(ret_conv, true);
39262 }
39263
39264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39265         LDKUpdateFulfillHTLC obj_conv;
39266         obj_conv.inner = untag_ptr(obj);
39267         obj_conv.is_owned = ptr_is_owned(obj);
39268         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39269         obj_conv.is_owned = false;
39270         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
39271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39273         CVec_u8Z_free(ret_var);
39274         return ret_arr;
39275 }
39276
39277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39278         LDKu8slice ser_ref;
39279         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39280         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39281         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
39282         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
39283         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39284         return tag_ptr(ret_conv, true);
39285 }
39286
39287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39288         LDKUpdateAddHTLC obj_conv;
39289         obj_conv.inner = untag_ptr(obj);
39290         obj_conv.is_owned = ptr_is_owned(obj);
39291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39292         obj_conv.is_owned = false;
39293         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
39294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39296         CVec_u8Z_free(ret_var);
39297         return ret_arr;
39298 }
39299
39300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39301         LDKu8slice ser_ref;
39302         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39303         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39304         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
39305         *ret_conv = UpdateAddHTLC_read(ser_ref);
39306         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39307         return tag_ptr(ret_conv, true);
39308 }
39309
39310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39311         LDKu8slice ser_ref;
39312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39314         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
39315         *ret_conv = OnionMessage_read(ser_ref);
39316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39317         return tag_ptr(ret_conv, true);
39318 }
39319
39320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39321         LDKOnionMessage obj_conv;
39322         obj_conv.inner = untag_ptr(obj);
39323         obj_conv.is_owned = ptr_is_owned(obj);
39324         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39325         obj_conv.is_owned = false;
39326         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
39327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39329         CVec_u8Z_free(ret_var);
39330         return ret_arr;
39331 }
39332
39333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
39334         LDKPing obj_conv;
39335         obj_conv.inner = untag_ptr(obj);
39336         obj_conv.is_owned = ptr_is_owned(obj);
39337         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39338         obj_conv.is_owned = false;
39339         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
39340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39342         CVec_u8Z_free(ret_var);
39343         return ret_arr;
39344 }
39345
39346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39347         LDKu8slice ser_ref;
39348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39350         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
39351         *ret_conv = Ping_read(ser_ref);
39352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39353         return tag_ptr(ret_conv, true);
39354 }
39355
39356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
39357         LDKPong obj_conv;
39358         obj_conv.inner = untag_ptr(obj);
39359         obj_conv.is_owned = ptr_is_owned(obj);
39360         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39361         obj_conv.is_owned = false;
39362         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
39363         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39364         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39365         CVec_u8Z_free(ret_var);
39366         return ret_arr;
39367 }
39368
39369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39370         LDKu8slice ser_ref;
39371         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39372         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39373         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
39374         *ret_conv = Pong_read(ser_ref);
39375         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39376         return tag_ptr(ret_conv, true);
39377 }
39378
39379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39380         LDKUnsignedChannelAnnouncement obj_conv;
39381         obj_conv.inner = untag_ptr(obj);
39382         obj_conv.is_owned = ptr_is_owned(obj);
39383         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39384         obj_conv.is_owned = false;
39385         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
39386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39388         CVec_u8Z_free(ret_var);
39389         return ret_arr;
39390 }
39391
39392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39393         LDKu8slice ser_ref;
39394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39396         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
39397         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
39398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39399         return tag_ptr(ret_conv, true);
39400 }
39401
39402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39403         LDKChannelAnnouncement obj_conv;
39404         obj_conv.inner = untag_ptr(obj);
39405         obj_conv.is_owned = ptr_is_owned(obj);
39406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39407         obj_conv.is_owned = false;
39408         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
39409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39411         CVec_u8Z_free(ret_var);
39412         return ret_arr;
39413 }
39414
39415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39416         LDKu8slice ser_ref;
39417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39419         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
39420         *ret_conv = ChannelAnnouncement_read(ser_ref);
39421         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39422         return tag_ptr(ret_conv, true);
39423 }
39424
39425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39426         LDKUnsignedChannelUpdate obj_conv;
39427         obj_conv.inner = untag_ptr(obj);
39428         obj_conv.is_owned = ptr_is_owned(obj);
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39430         obj_conv.is_owned = false;
39431         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
39432         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39433         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39434         CVec_u8Z_free(ret_var);
39435         return ret_arr;
39436 }
39437
39438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39439         LDKu8slice ser_ref;
39440         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39441         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39442         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
39443         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
39444         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39445         return tag_ptr(ret_conv, true);
39446 }
39447
39448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39449         LDKChannelUpdate obj_conv;
39450         obj_conv.inner = untag_ptr(obj);
39451         obj_conv.is_owned = ptr_is_owned(obj);
39452         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39453         obj_conv.is_owned = false;
39454         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
39455         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39456         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39457         CVec_u8Z_free(ret_var);
39458         return ret_arr;
39459 }
39460
39461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39462         LDKu8slice ser_ref;
39463         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39464         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39465         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
39466         *ret_conv = ChannelUpdate_read(ser_ref);
39467         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39468         return tag_ptr(ret_conv, true);
39469 }
39470
39471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39472         LDKErrorMessage obj_conv;
39473         obj_conv.inner = untag_ptr(obj);
39474         obj_conv.is_owned = ptr_is_owned(obj);
39475         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39476         obj_conv.is_owned = false;
39477         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
39478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39480         CVec_u8Z_free(ret_var);
39481         return ret_arr;
39482 }
39483
39484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39485         LDKu8slice ser_ref;
39486         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39487         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39488         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
39489         *ret_conv = ErrorMessage_read(ser_ref);
39490         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39491         return tag_ptr(ret_conv, true);
39492 }
39493
39494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39495         LDKWarningMessage obj_conv;
39496         obj_conv.inner = untag_ptr(obj);
39497         obj_conv.is_owned = ptr_is_owned(obj);
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39499         obj_conv.is_owned = false;
39500         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
39501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39503         CVec_u8Z_free(ret_var);
39504         return ret_arr;
39505 }
39506
39507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39508         LDKu8slice ser_ref;
39509         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39510         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39511         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
39512         *ret_conv = WarningMessage_read(ser_ref);
39513         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39514         return tag_ptr(ret_conv, true);
39515 }
39516
39517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39518         LDKUnsignedNodeAnnouncement obj_conv;
39519         obj_conv.inner = untag_ptr(obj);
39520         obj_conv.is_owned = ptr_is_owned(obj);
39521         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39522         obj_conv.is_owned = false;
39523         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
39524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39526         CVec_u8Z_free(ret_var);
39527         return ret_arr;
39528 }
39529
39530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39531         LDKu8slice ser_ref;
39532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39534         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
39535         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
39536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39537         return tag_ptr(ret_conv, true);
39538 }
39539
39540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39541         LDKNodeAnnouncement obj_conv;
39542         obj_conv.inner = untag_ptr(obj);
39543         obj_conv.is_owned = ptr_is_owned(obj);
39544         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39545         obj_conv.is_owned = false;
39546         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
39547         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39548         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39549         CVec_u8Z_free(ret_var);
39550         return ret_arr;
39551 }
39552
39553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39554         LDKu8slice ser_ref;
39555         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39556         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39557         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
39558         *ret_conv = NodeAnnouncement_read(ser_ref);
39559         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39560         return tag_ptr(ret_conv, true);
39561 }
39562
39563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39564         LDKu8slice ser_ref;
39565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39567         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
39568         *ret_conv = QueryShortChannelIds_read(ser_ref);
39569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39570         return tag_ptr(ret_conv, true);
39571 }
39572
39573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
39574         LDKQueryShortChannelIds obj_conv;
39575         obj_conv.inner = untag_ptr(obj);
39576         obj_conv.is_owned = ptr_is_owned(obj);
39577         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39578         obj_conv.is_owned = false;
39579         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
39580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39582         CVec_u8Z_free(ret_var);
39583         return ret_arr;
39584 }
39585
39586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
39587         LDKReplyShortChannelIdsEnd obj_conv;
39588         obj_conv.inner = untag_ptr(obj);
39589         obj_conv.is_owned = ptr_is_owned(obj);
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39591         obj_conv.is_owned = false;
39592         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
39593         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39594         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39595         CVec_u8Z_free(ret_var);
39596         return ret_arr;
39597 }
39598
39599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39600         LDKu8slice ser_ref;
39601         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39602         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39603         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
39604         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
39605         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39606         return tag_ptr(ret_conv, true);
39607 }
39608
39609 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
39610         LDKQueryChannelRange this_arg_conv;
39611         this_arg_conv.inner = untag_ptr(this_arg);
39612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39614         this_arg_conv.is_owned = false;
39615         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
39616         return ret_conv;
39617 }
39618
39619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
39620         LDKQueryChannelRange obj_conv;
39621         obj_conv.inner = untag_ptr(obj);
39622         obj_conv.is_owned = ptr_is_owned(obj);
39623         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39624         obj_conv.is_owned = false;
39625         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
39626         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39627         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39628         CVec_u8Z_free(ret_var);
39629         return ret_arr;
39630 }
39631
39632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39633         LDKu8slice ser_ref;
39634         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39635         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39636         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
39637         *ret_conv = QueryChannelRange_read(ser_ref);
39638         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39639         return tag_ptr(ret_conv, true);
39640 }
39641
39642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39643         LDKu8slice ser_ref;
39644         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39645         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39646         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
39647         *ret_conv = ReplyChannelRange_read(ser_ref);
39648         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39649         return tag_ptr(ret_conv, true);
39650 }
39651
39652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
39653         LDKReplyChannelRange obj_conv;
39654         obj_conv.inner = untag_ptr(obj);
39655         obj_conv.is_owned = ptr_is_owned(obj);
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39657         obj_conv.is_owned = false;
39658         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
39659         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39660         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39661         CVec_u8Z_free(ret_var);
39662         return ret_arr;
39663 }
39664
39665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
39666         LDKGossipTimestampFilter obj_conv;
39667         obj_conv.inner = untag_ptr(obj);
39668         obj_conv.is_owned = ptr_is_owned(obj);
39669         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39670         obj_conv.is_owned = false;
39671         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
39672         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39673         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39674         CVec_u8Z_free(ret_var);
39675         return ret_arr;
39676 }
39677
39678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39679         LDKu8slice ser_ref;
39680         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39681         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39682         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
39683         *ret_conv = GossipTimestampFilter_read(ser_ref);
39684         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39685         return tag_ptr(ret_conv, true);
39686 }
39687
39688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39689         if (!ptr_is_owned(this_ptr)) return;
39690         void* this_ptr_ptr = untag_ptr(this_ptr);
39691         CHECK_ACCESS(this_ptr_ptr);
39692         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
39693         FREE(untag_ptr(this_ptr));
39694         CustomMessageHandler_free(this_ptr_conv);
39695 }
39696
39697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39698         LDKIgnoringMessageHandler this_obj_conv;
39699         this_obj_conv.inner = untag_ptr(this_obj);
39700         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39702         IgnoringMessageHandler_free(this_obj_conv);
39703 }
39704
39705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
39706         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
39707         int64_t ret_ref = 0;
39708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39710         return ret_ref;
39711 }
39712
39713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39714         LDKIgnoringMessageHandler this_arg_conv;
39715         this_arg_conv.inner = untag_ptr(this_arg);
39716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39718         this_arg_conv.is_owned = false;
39719         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39720         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
39721         return tag_ptr(ret_ret, true);
39722 }
39723
39724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39725         LDKIgnoringMessageHandler this_arg_conv;
39726         this_arg_conv.inner = untag_ptr(this_arg);
39727         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39729         this_arg_conv.is_owned = false;
39730         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39731         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
39732         return tag_ptr(ret_ret, true);
39733 }
39734
39735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39736         LDKIgnoringMessageHandler this_arg_conv;
39737         this_arg_conv.inner = untag_ptr(this_arg);
39738         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39740         this_arg_conv.is_owned = false;
39741         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
39742         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
39743         return tag_ptr(ret_ret, true);
39744 }
39745
39746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39747         LDKIgnoringMessageHandler this_arg_conv;
39748         this_arg_conv.inner = untag_ptr(this_arg);
39749         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39751         this_arg_conv.is_owned = false;
39752         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
39753         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
39754         return tag_ptr(ret_ret, true);
39755 }
39756
39757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39758         LDKIgnoringMessageHandler this_arg_conv;
39759         this_arg_conv.inner = untag_ptr(this_arg);
39760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39762         this_arg_conv.is_owned = false;
39763         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
39764         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
39765         return tag_ptr(ret_ret, true);
39766 }
39767
39768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
39769         LDKIgnoringMessageHandler this_arg_conv;
39770         this_arg_conv.inner = untag_ptr(this_arg);
39771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39773         this_arg_conv.is_owned = false;
39774         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
39775         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
39776         return tag_ptr(ret_ret, true);
39777 }
39778
39779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39780         LDKIgnoringMessageHandler this_arg_conv;
39781         this_arg_conv.inner = untag_ptr(this_arg);
39782         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39784         this_arg_conv.is_owned = false;
39785         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
39786         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
39787         return tag_ptr(ret_ret, true);
39788 }
39789
39790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39791         LDKErroringMessageHandler this_obj_conv;
39792         this_obj_conv.inner = untag_ptr(this_obj);
39793         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39795         ErroringMessageHandler_free(this_obj_conv);
39796 }
39797
39798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
39799         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
39800         int64_t ret_ref = 0;
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39803         return ret_ref;
39804 }
39805
39806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39807         LDKErroringMessageHandler this_arg_conv;
39808         this_arg_conv.inner = untag_ptr(this_arg);
39809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39811         this_arg_conv.is_owned = false;
39812         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39813         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
39814         return tag_ptr(ret_ret, true);
39815 }
39816
39817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39818         LDKErroringMessageHandler this_arg_conv;
39819         this_arg_conv.inner = untag_ptr(this_arg);
39820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39822         this_arg_conv.is_owned = false;
39823         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
39824         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
39825         return tag_ptr(ret_ret, true);
39826 }
39827
39828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39829         LDKMessageHandler this_obj_conv;
39830         this_obj_conv.inner = untag_ptr(this_obj);
39831         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39833         MessageHandler_free(this_obj_conv);
39834 }
39835
39836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39837         LDKMessageHandler this_ptr_conv;
39838         this_ptr_conv.inner = untag_ptr(this_ptr);
39839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39841         this_ptr_conv.is_owned = false;
39842         // WARNING: This object doesn't live past this scope, needs clone!
39843         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
39844         return ret_ret;
39845 }
39846
39847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39848         LDKMessageHandler this_ptr_conv;
39849         this_ptr_conv.inner = untag_ptr(this_ptr);
39850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39852         this_ptr_conv.is_owned = false;
39853         void* val_ptr = untag_ptr(val);
39854         CHECK_ACCESS(val_ptr);
39855         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
39856         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
39857                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39858                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
39859         }
39860         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
39861 }
39862
39863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39864         LDKMessageHandler this_ptr_conv;
39865         this_ptr_conv.inner = untag_ptr(this_ptr);
39866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39868         this_ptr_conv.is_owned = false;
39869         // WARNING: This object doesn't live past this scope, needs clone!
39870         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
39871         return ret_ret;
39872 }
39873
39874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39875         LDKMessageHandler this_ptr_conv;
39876         this_ptr_conv.inner = untag_ptr(this_ptr);
39877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39879         this_ptr_conv.is_owned = false;
39880         void* val_ptr = untag_ptr(val);
39881         CHECK_ACCESS(val_ptr);
39882         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
39883         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
39884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39885                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
39886         }
39887         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
39888 }
39889
39890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39891         LDKMessageHandler this_ptr_conv;
39892         this_ptr_conv.inner = untag_ptr(this_ptr);
39893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39895         this_ptr_conv.is_owned = false;
39896         // WARNING: This object doesn't live past this scope, needs clone!
39897         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
39898         return ret_ret;
39899 }
39900
39901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39902         LDKMessageHandler this_ptr_conv;
39903         this_ptr_conv.inner = untag_ptr(this_ptr);
39904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39906         this_ptr_conv.is_owned = false;
39907         void* val_ptr = untag_ptr(val);
39908         CHECK_ACCESS(val_ptr);
39909         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
39910         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
39911                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39912                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
39913         }
39914         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
39915 }
39916
39917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv *env, jclass clz, int64_t chan_handler_arg, int64_t route_handler_arg, int64_t onion_message_handler_arg) {
39918         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
39919         CHECK_ACCESS(chan_handler_arg_ptr);
39920         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
39921         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
39922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39923                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
39924         }
39925         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
39926         CHECK_ACCESS(route_handler_arg_ptr);
39927         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
39928         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
39929                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39930                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
39931         }
39932         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
39933         CHECK_ACCESS(onion_message_handler_arg_ptr);
39934         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
39935         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
39936                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39937                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
39938         }
39939         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
39940         int64_t ret_ref = 0;
39941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39943         return ret_ref;
39944 }
39945
39946 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
39947         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
39948         *ret_ret = SocketDescriptor_clone(arg);
39949         return tag_ptr(ret_ret, true);
39950 }
39951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39952         void* arg_ptr = untag_ptr(arg);
39953         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
39954         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
39955         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
39956         return ret_conv;
39957 }
39958
39959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39960         void* orig_ptr = untag_ptr(orig);
39961         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
39962         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
39963         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
39964         *ret_ret = SocketDescriptor_clone(orig_conv);
39965         return tag_ptr(ret_ret, true);
39966 }
39967
39968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39969         if (!ptr_is_owned(this_ptr)) return;
39970         void* this_ptr_ptr = untag_ptr(this_ptr);
39971         CHECK_ACCESS(this_ptr_ptr);
39972         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
39973         FREE(untag_ptr(this_ptr));
39974         SocketDescriptor_free(this_ptr_conv);
39975 }
39976
39977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39978         LDKPeerHandleError this_obj_conv;
39979         this_obj_conv.inner = untag_ptr(this_obj);
39980         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39982         PeerHandleError_free(this_obj_conv);
39983 }
39984
39985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
39986         LDKPeerHandleError this_ptr_conv;
39987         this_ptr_conv.inner = untag_ptr(this_ptr);
39988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39990         this_ptr_conv.is_owned = false;
39991         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
39992         return ret_conv;
39993 }
39994
39995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39996         LDKPeerHandleError this_ptr_conv;
39997         this_ptr_conv.inner = untag_ptr(this_ptr);
39998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40000         this_ptr_conv.is_owned = false;
40001         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
40002 }
40003
40004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
40005         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
40006         int64_t ret_ref = 0;
40007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40009         return ret_ref;
40010 }
40011
40012 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
40013         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
40014         int64_t ret_ref = 0;
40015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40017         return ret_ref;
40018 }
40019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40020         LDKPeerHandleError arg_conv;
40021         arg_conv.inner = untag_ptr(arg);
40022         arg_conv.is_owned = ptr_is_owned(arg);
40023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40024         arg_conv.is_owned = false;
40025         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
40026         return ret_conv;
40027 }
40028
40029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40030         LDKPeerHandleError orig_conv;
40031         orig_conv.inner = untag_ptr(orig);
40032         orig_conv.is_owned = ptr_is_owned(orig);
40033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40034         orig_conv.is_owned = false;
40035         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
40036         int64_t ret_ref = 0;
40037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40039         return ret_ref;
40040 }
40041
40042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40043         LDKPeerManager this_obj_conv;
40044         this_obj_conv.inner = untag_ptr(this_obj);
40045         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40047         PeerManager_free(this_obj_conv);
40048 }
40049
40050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int32_t current_time, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
40051         LDKMessageHandler message_handler_conv;
40052         message_handler_conv.inner = untag_ptr(message_handler);
40053         message_handler_conv.is_owned = ptr_is_owned(message_handler);
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
40055         // WARNING: we need a move here but no clone is available for LDKMessageHandler
40056         
40057         LDKSecretKey our_node_secret_ref;
40058         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
40059         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
40060         unsigned char ephemeral_random_data_arr[32];
40061         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
40062         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
40063         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
40064         void* logger_ptr = untag_ptr(logger);
40065         CHECK_ACCESS(logger_ptr);
40066         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40067         if (logger_conv.free == LDKLogger_JCalls_free) {
40068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40069                 LDKLogger_JCalls_cloned(&logger_conv);
40070         }
40071         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
40072         CHECK_ACCESS(custom_message_handler_ptr);
40073         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
40074         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
40075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40076                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
40077         }
40078         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
40079         int64_t ret_ref = 0;
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40082         return ret_ref;
40083 }
40084
40085 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
40086         LDKPeerManager this_arg_conv;
40087         this_arg_conv.inner = untag_ptr(this_arg);
40088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40090         this_arg_conv.is_owned = false;
40091         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
40092         jobjectArray ret_arr = NULL;
40093         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
40094         ;
40095         for (size_t i = 0; i < ret_var.datalen; i++) {
40096                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
40097                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
40098                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
40099         }
40100         
40101         FREE(ret_var.data);
40102         return ret_arr;
40103 }
40104
40105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t descriptor, int64_t remote_network_address) {
40106         LDKPeerManager this_arg_conv;
40107         this_arg_conv.inner = untag_ptr(this_arg);
40108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40110         this_arg_conv.is_owned = false;
40111         LDKPublicKey their_node_id_ref;
40112         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
40113         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
40114         void* descriptor_ptr = untag_ptr(descriptor);
40115         CHECK_ACCESS(descriptor_ptr);
40116         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
40117         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
40118                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40119                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
40120         }
40121         void* remote_network_address_ptr = untag_ptr(remote_network_address);
40122         CHECK_ACCESS(remote_network_address_ptr);
40123         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
40124         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
40125         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
40126         return tag_ptr(ret_conv, true);
40127 }
40128
40129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
40130         LDKPeerManager this_arg_conv;
40131         this_arg_conv.inner = untag_ptr(this_arg);
40132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40134         this_arg_conv.is_owned = false;
40135         void* descriptor_ptr = untag_ptr(descriptor);
40136         CHECK_ACCESS(descriptor_ptr);
40137         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
40138         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
40139                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40140                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
40141         }
40142         void* remote_network_address_ptr = untag_ptr(remote_network_address);
40143         CHECK_ACCESS(remote_network_address_ptr);
40144         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
40145         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
40146         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
40147         return tag_ptr(ret_conv, true);
40148 }
40149
40150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
40151         LDKPeerManager this_arg_conv;
40152         this_arg_conv.inner = untag_ptr(this_arg);
40153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40155         this_arg_conv.is_owned = false;
40156         void* descriptor_ptr = untag_ptr(descriptor);
40157         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
40158         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
40159         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
40160         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
40161         return tag_ptr(ret_conv, true);
40162 }
40163
40164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t peer_descriptor, int8_tArray data) {
40165         LDKPeerManager this_arg_conv;
40166         this_arg_conv.inner = untag_ptr(this_arg);
40167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40169         this_arg_conv.is_owned = false;
40170         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
40171         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
40172         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
40173         LDKu8slice data_ref;
40174         data_ref.datalen = (*env)->GetArrayLength(env, data);
40175         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
40176         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
40177         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
40178         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
40179         return tag_ptr(ret_conv, true);
40180 }
40181
40182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
40183         LDKPeerManager this_arg_conv;
40184         this_arg_conv.inner = untag_ptr(this_arg);
40185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40187         this_arg_conv.is_owned = false;
40188         PeerManager_process_events(&this_arg_conv);
40189 }
40190
40191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
40192         LDKPeerManager this_arg_conv;
40193         this_arg_conv.inner = untag_ptr(this_arg);
40194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40196         this_arg_conv.is_owned = false;
40197         void* descriptor_ptr = untag_ptr(descriptor);
40198         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
40199         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
40200         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
40201 }
40202
40203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
40204         LDKPeerManager this_arg_conv;
40205         this_arg_conv.inner = untag_ptr(this_arg);
40206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40208         this_arg_conv.is_owned = false;
40209         LDKPublicKey node_id_ref;
40210         CHECK((*env)->GetArrayLength(env, node_id) == 33);
40211         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
40212         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
40213 }
40214
40215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
40216         LDKPeerManager this_arg_conv;
40217         this_arg_conv.inner = untag_ptr(this_arg);
40218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40220         this_arg_conv.is_owned = false;
40221         PeerManager_disconnect_all_peers(&this_arg_conv);
40222 }
40223
40224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
40225         LDKPeerManager this_arg_conv;
40226         this_arg_conv.inner = untag_ptr(this_arg);
40227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40229         this_arg_conv.is_owned = false;
40230         PeerManager_timer_tick_occurred(&this_arg_conv);
40231 }
40232
40233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
40234         LDKPeerManager this_arg_conv;
40235         this_arg_conv.inner = untag_ptr(this_arg);
40236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40238         this_arg_conv.is_owned = false;
40239         LDKThreeBytes rgb_ref;
40240         CHECK((*env)->GetArrayLength(env, rgb) == 3);
40241         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
40242         LDKThirtyTwoBytes alias_ref;
40243         CHECK((*env)->GetArrayLength(env, alias) == 32);
40244         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
40245         LDKCVec_NetAddressZ addresses_constr;
40246         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
40247         if (addresses_constr.datalen > 0)
40248                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40249         else
40250                 addresses_constr.data = NULL;
40251         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
40252         for (size_t m = 0; m < addresses_constr.datalen; m++) {
40253                 int64_t addresses_conv_12 = addresses_vals[m];
40254                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
40255                 CHECK_ACCESS(addresses_conv_12_ptr);
40256                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
40257                 addresses_constr.data[m] = addresses_conv_12_conv;
40258         }
40259         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
40260         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
40261 }
40262
40263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
40264         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
40265         return ret_conv;
40266 }
40267
40268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
40269         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
40270         return ret_conv;
40271 }
40272
40273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
40274         unsigned char commitment_seed_arr[32];
40275         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
40276         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
40277         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
40278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
40280         return ret_arr;
40281 }
40282
40283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
40284         LDKCVec_u8Z to_holder_script_ref;
40285         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40286         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40287         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40288         LDKCVec_u8Z to_counterparty_script_ref;
40289         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40290         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40291         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40292         LDKOutPoint funding_outpoint_conv;
40293         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
40294         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
40295         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40296         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40297         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40298         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40299         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40300         Transaction_free(ret_var);
40301         return ret_arr;
40302 }
40303
40304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40305         LDKCounterpartyCommitmentSecrets this_obj_conv;
40306         this_obj_conv.inner = untag_ptr(this_obj);
40307         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40309         CounterpartyCommitmentSecrets_free(this_obj_conv);
40310 }
40311
40312 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
40313         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
40314         int64_t ret_ref = 0;
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40317         return ret_ref;
40318 }
40319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40320         LDKCounterpartyCommitmentSecrets arg_conv;
40321         arg_conv.inner = untag_ptr(arg);
40322         arg_conv.is_owned = ptr_is_owned(arg);
40323         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40324         arg_conv.is_owned = false;
40325         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
40326         return ret_conv;
40327 }
40328
40329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40330         LDKCounterpartyCommitmentSecrets orig_conv;
40331         orig_conv.inner = untag_ptr(orig);
40332         orig_conv.is_owned = ptr_is_owned(orig);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40334         orig_conv.is_owned = false;
40335         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
40336         int64_t ret_ref = 0;
40337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40339         return ret_ref;
40340 }
40341
40342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
40343         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
40344         int64_t ret_ref = 0;
40345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40347         return ret_ref;
40348 }
40349
40350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40351         LDKCounterpartyCommitmentSecrets this_arg_conv;
40352         this_arg_conv.inner = untag_ptr(this_arg);
40353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40355         this_arg_conv.is_owned = false;
40356         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
40357         return ret_conv;
40358 }
40359
40360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1provide_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
40361         LDKCounterpartyCommitmentSecrets this_arg_conv;
40362         this_arg_conv.inner = untag_ptr(this_arg);
40363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40365         this_arg_conv.is_owned = false;
40366         LDKThirtyTwoBytes secret_ref;
40367         CHECK((*env)->GetArrayLength(env, secret) == 32);
40368         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
40369         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
40370         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
40371         return tag_ptr(ret_conv, true);
40372 }
40373
40374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
40375         LDKCounterpartyCommitmentSecrets this_arg_conv;
40376         this_arg_conv.inner = untag_ptr(this_arg);
40377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40379         this_arg_conv.is_owned = false;
40380         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
40382         return ret_arr;
40383 }
40384
40385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
40386         LDKCounterpartyCommitmentSecrets obj_conv;
40387         obj_conv.inner = untag_ptr(obj);
40388         obj_conv.is_owned = ptr_is_owned(obj);
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40390         obj_conv.is_owned = false;
40391         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
40392         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40393         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40394         CVec_u8Z_free(ret_var);
40395         return ret_arr;
40396 }
40397
40398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40399         LDKu8slice ser_ref;
40400         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40401         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40402         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
40403         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
40404         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40405         return tag_ptr(ret_conv, true);
40406 }
40407
40408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) {
40409         LDKPublicKey per_commitment_point_ref;
40410         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40411         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40412         unsigned char base_secret_arr[32];
40413         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
40414         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
40415         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
40416         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
40417         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
40418         return tag_ptr(ret_conv, true);
40419 }
40420
40421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_point) {
40422         LDKPublicKey per_commitment_point_ref;
40423         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40424         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40425         LDKPublicKey base_point_ref;
40426         CHECK((*env)->GetArrayLength(env, base_point) == 33);
40427         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
40428         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
40429         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
40430         return tag_ptr(ret_conv, true);
40431 }
40432
40433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1revocation_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
40434         unsigned char per_commitment_secret_arr[32];
40435         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
40436         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
40437         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
40438         unsigned char countersignatory_revocation_base_secret_arr[32];
40439         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
40440         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
40441         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
40442         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
40443         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
40444         return tag_ptr(ret_conv, true);
40445 }
40446
40447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1public_1revocation_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
40448         LDKPublicKey per_commitment_point_ref;
40449         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40450         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40451         LDKPublicKey countersignatory_revocation_base_point_ref;
40452         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
40453         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
40454         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
40455         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
40456         return tag_ptr(ret_conv, true);
40457 }
40458
40459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40460         LDKTxCreationKeys this_obj_conv;
40461         this_obj_conv.inner = untag_ptr(this_obj);
40462         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40464         TxCreationKeys_free(this_obj_conv);
40465 }
40466
40467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
40468         LDKTxCreationKeys this_ptr_conv;
40469         this_ptr_conv.inner = untag_ptr(this_ptr);
40470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40472         this_ptr_conv.is_owned = false;
40473         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40474         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
40475         return ret_arr;
40476 }
40477
40478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40479         LDKTxCreationKeys this_ptr_conv;
40480         this_ptr_conv.inner = untag_ptr(this_ptr);
40481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40483         this_ptr_conv.is_owned = false;
40484         LDKPublicKey val_ref;
40485         CHECK((*env)->GetArrayLength(env, val) == 33);
40486         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40487         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
40488 }
40489
40490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40491         LDKTxCreationKeys this_ptr_conv;
40492         this_ptr_conv.inner = untag_ptr(this_ptr);
40493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40495         this_ptr_conv.is_owned = false;
40496         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
40498         return ret_arr;
40499 }
40500
40501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40502         LDKTxCreationKeys this_ptr_conv;
40503         this_ptr_conv.inner = untag_ptr(this_ptr);
40504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40506         this_ptr_conv.is_owned = false;
40507         LDKPublicKey val_ref;
40508         CHECK((*env)->GetArrayLength(env, val) == 33);
40509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40510         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
40511 }
40512
40513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40514         LDKTxCreationKeys this_ptr_conv;
40515         this_ptr_conv.inner = untag_ptr(this_ptr);
40516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40518         this_ptr_conv.is_owned = false;
40519         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
40521         return ret_arr;
40522 }
40523
40524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40525         LDKTxCreationKeys this_ptr_conv;
40526         this_ptr_conv.inner = untag_ptr(this_ptr);
40527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40529         this_ptr_conv.is_owned = false;
40530         LDKPublicKey val_ref;
40531         CHECK((*env)->GetArrayLength(env, val) == 33);
40532         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40533         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
40534 }
40535
40536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40537         LDKTxCreationKeys this_ptr_conv;
40538         this_ptr_conv.inner = untag_ptr(this_ptr);
40539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40541         this_ptr_conv.is_owned = false;
40542         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
40544         return ret_arr;
40545 }
40546
40547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40548         LDKTxCreationKeys this_ptr_conv;
40549         this_ptr_conv.inner = untag_ptr(this_ptr);
40550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40552         this_ptr_conv.is_owned = false;
40553         LDKPublicKey val_ref;
40554         CHECK((*env)->GetArrayLength(env, val) == 33);
40555         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40556         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
40557 }
40558
40559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40560         LDKTxCreationKeys this_ptr_conv;
40561         this_ptr_conv.inner = untag_ptr(this_ptr);
40562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40564         this_ptr_conv.is_owned = false;
40565         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
40567         return ret_arr;
40568 }
40569
40570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40571         LDKTxCreationKeys this_ptr_conv;
40572         this_ptr_conv.inner = untag_ptr(this_ptr);
40573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40575         this_ptr_conv.is_owned = false;
40576         LDKPublicKey val_ref;
40577         CHECK((*env)->GetArrayLength(env, val) == 33);
40578         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40579         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
40580 }
40581
40582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv *env, jclass clz, int8_tArray per_commitment_point_arg, int8_tArray revocation_key_arg, int8_tArray broadcaster_htlc_key_arg, int8_tArray countersignatory_htlc_key_arg, int8_tArray broadcaster_delayed_payment_key_arg) {
40583         LDKPublicKey per_commitment_point_arg_ref;
40584         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
40585         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
40586         LDKPublicKey revocation_key_arg_ref;
40587         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
40588         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
40589         LDKPublicKey broadcaster_htlc_key_arg_ref;
40590         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
40591         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
40592         LDKPublicKey countersignatory_htlc_key_arg_ref;
40593         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
40594         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
40595         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
40596         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
40597         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
40598         LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
40599         int64_t ret_ref = 0;
40600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40602         return ret_ref;
40603 }
40604
40605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40606         LDKTxCreationKeys a_conv;
40607         a_conv.inner = untag_ptr(a);
40608         a_conv.is_owned = ptr_is_owned(a);
40609         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40610         a_conv.is_owned = false;
40611         LDKTxCreationKeys b_conv;
40612         b_conv.inner = untag_ptr(b);
40613         b_conv.is_owned = ptr_is_owned(b);
40614         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40615         b_conv.is_owned = false;
40616         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
40617         return ret_conv;
40618 }
40619
40620 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
40621         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
40622         int64_t ret_ref = 0;
40623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40625         return ret_ref;
40626 }
40627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40628         LDKTxCreationKeys arg_conv;
40629         arg_conv.inner = untag_ptr(arg);
40630         arg_conv.is_owned = ptr_is_owned(arg);
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40632         arg_conv.is_owned = false;
40633         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
40634         return ret_conv;
40635 }
40636
40637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40638         LDKTxCreationKeys orig_conv;
40639         orig_conv.inner = untag_ptr(orig);
40640         orig_conv.is_owned = ptr_is_owned(orig);
40641         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40642         orig_conv.is_owned = false;
40643         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
40644         int64_t ret_ref = 0;
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40647         return ret_ref;
40648 }
40649
40650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
40651         LDKTxCreationKeys obj_conv;
40652         obj_conv.inner = untag_ptr(obj);
40653         obj_conv.is_owned = ptr_is_owned(obj);
40654         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40655         obj_conv.is_owned = false;
40656         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
40657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40659         CVec_u8Z_free(ret_var);
40660         return ret_arr;
40661 }
40662
40663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40664         LDKu8slice ser_ref;
40665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40667         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
40668         *ret_conv = TxCreationKeys_read(ser_ref);
40669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40670         return tag_ptr(ret_conv, true);
40671 }
40672
40673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40674         LDKChannelPublicKeys this_obj_conv;
40675         this_obj_conv.inner = untag_ptr(this_obj);
40676         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40678         ChannelPublicKeys_free(this_obj_conv);
40679 }
40680
40681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
40682         LDKChannelPublicKeys this_ptr_conv;
40683         this_ptr_conv.inner = untag_ptr(this_ptr);
40684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40686         this_ptr_conv.is_owned = false;
40687         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
40689         return ret_arr;
40690 }
40691
40692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40693         LDKChannelPublicKeys this_ptr_conv;
40694         this_ptr_conv.inner = untag_ptr(this_ptr);
40695         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40697         this_ptr_conv.is_owned = false;
40698         LDKPublicKey val_ref;
40699         CHECK((*env)->GetArrayLength(env, val) == 33);
40700         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40701         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
40702 }
40703
40704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40705         LDKChannelPublicKeys this_ptr_conv;
40706         this_ptr_conv.inner = untag_ptr(this_ptr);
40707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40709         this_ptr_conv.is_owned = false;
40710         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
40712         return ret_arr;
40713 }
40714
40715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40716         LDKChannelPublicKeys this_ptr_conv;
40717         this_ptr_conv.inner = untag_ptr(this_ptr);
40718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40720         this_ptr_conv.is_owned = false;
40721         LDKPublicKey val_ref;
40722         CHECK((*env)->GetArrayLength(env, val) == 33);
40723         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40724         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
40725 }
40726
40727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
40728         LDKChannelPublicKeys this_ptr_conv;
40729         this_ptr_conv.inner = untag_ptr(this_ptr);
40730         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40732         this_ptr_conv.is_owned = false;
40733         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
40735         return ret_arr;
40736 }
40737
40738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40739         LDKChannelPublicKeys this_ptr_conv;
40740         this_ptr_conv.inner = untag_ptr(this_ptr);
40741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40743         this_ptr_conv.is_owned = false;
40744         LDKPublicKey val_ref;
40745         CHECK((*env)->GetArrayLength(env, val) == 33);
40746         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40747         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
40748 }
40749
40750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40751         LDKChannelPublicKeys this_ptr_conv;
40752         this_ptr_conv.inner = untag_ptr(this_ptr);
40753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40755         this_ptr_conv.is_owned = false;
40756         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
40758         return ret_arr;
40759 }
40760
40761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40762         LDKChannelPublicKeys this_ptr_conv;
40763         this_ptr_conv.inner = untag_ptr(this_ptr);
40764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40766         this_ptr_conv.is_owned = false;
40767         LDKPublicKey val_ref;
40768         CHECK((*env)->GetArrayLength(env, val) == 33);
40769         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40770         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
40771 }
40772
40773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40774         LDKChannelPublicKeys this_ptr_conv;
40775         this_ptr_conv.inner = untag_ptr(this_ptr);
40776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40778         this_ptr_conv.is_owned = false;
40779         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
40781         return ret_arr;
40782 }
40783
40784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40785         LDKChannelPublicKeys this_ptr_conv;
40786         this_ptr_conv.inner = untag_ptr(this_ptr);
40787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40789         this_ptr_conv.is_owned = false;
40790         LDKPublicKey val_ref;
40791         CHECK((*env)->GetArrayLength(env, val) == 33);
40792         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40793         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
40794 }
40795
40796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv *env, jclass clz, int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_point_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg) {
40797         LDKPublicKey funding_pubkey_arg_ref;
40798         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
40799         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
40800         LDKPublicKey revocation_basepoint_arg_ref;
40801         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
40802         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
40803         LDKPublicKey payment_point_arg_ref;
40804         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
40805         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
40806         LDKPublicKey delayed_payment_basepoint_arg_ref;
40807         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
40808         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
40809         LDKPublicKey htlc_basepoint_arg_ref;
40810         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
40811         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
40812         LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
40813         int64_t ret_ref = 0;
40814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40816         return ret_ref;
40817 }
40818
40819 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
40820         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
40821         int64_t ret_ref = 0;
40822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40824         return ret_ref;
40825 }
40826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40827         LDKChannelPublicKeys arg_conv;
40828         arg_conv.inner = untag_ptr(arg);
40829         arg_conv.is_owned = ptr_is_owned(arg);
40830         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40831         arg_conv.is_owned = false;
40832         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
40833         return ret_conv;
40834 }
40835
40836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40837         LDKChannelPublicKeys orig_conv;
40838         orig_conv.inner = untag_ptr(orig);
40839         orig_conv.is_owned = ptr_is_owned(orig);
40840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40841         orig_conv.is_owned = false;
40842         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
40843         int64_t ret_ref = 0;
40844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40846         return ret_ref;
40847 }
40848
40849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40850         LDKChannelPublicKeys a_conv;
40851         a_conv.inner = untag_ptr(a);
40852         a_conv.is_owned = ptr_is_owned(a);
40853         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40854         a_conv.is_owned = false;
40855         LDKChannelPublicKeys b_conv;
40856         b_conv.inner = untag_ptr(b);
40857         b_conv.is_owned = ptr_is_owned(b);
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40859         b_conv.is_owned = false;
40860         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
40861         return ret_conv;
40862 }
40863
40864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
40865         LDKChannelPublicKeys obj_conv;
40866         obj_conv.inner = untag_ptr(obj);
40867         obj_conv.is_owned = ptr_is_owned(obj);
40868         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40869         obj_conv.is_owned = false;
40870         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
40871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40873         CVec_u8Z_free(ret_var);
40874         return ret_arr;
40875 }
40876
40877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40878         LDKu8slice ser_ref;
40879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40881         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
40882         *ret_conv = ChannelPublicKeys_read(ser_ref);
40883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40884         return tag_ptr(ret_conv, true);
40885 }
40886
40887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1derive_1new(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray broadcaster_delayed_payment_base, int8_tArray broadcaster_htlc_base, int8_tArray countersignatory_revocation_base, int8_tArray countersignatory_htlc_base) {
40888         LDKPublicKey per_commitment_point_ref;
40889         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40890         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40891         LDKPublicKey broadcaster_delayed_payment_base_ref;
40892         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
40893         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
40894         LDKPublicKey broadcaster_htlc_base_ref;
40895         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
40896         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
40897         LDKPublicKey countersignatory_revocation_base_ref;
40898         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
40899         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
40900         LDKPublicKey countersignatory_htlc_base_ref;
40901         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
40902         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
40903         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
40904         *ret_conv = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
40905         return tag_ptr(ret_conv, true);
40906 }
40907
40908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1from_1channel_1static_1keys(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int64_t broadcaster_keys, int64_t countersignatory_keys) {
40909         LDKPublicKey per_commitment_point_ref;
40910         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40911         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40912         LDKChannelPublicKeys broadcaster_keys_conv;
40913         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
40914         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
40915         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40916         broadcaster_keys_conv.is_owned = false;
40917         LDKChannelPublicKeys countersignatory_keys_conv;
40918         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
40919         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
40920         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40921         countersignatory_keys_conv.is_owned = false;
40922         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
40923         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
40924         return tag_ptr(ret_conv, true);
40925 }
40926
40927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1revokeable_1redeemscript(JNIEnv *env, jclass clz, int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
40928         LDKPublicKey revocation_key_ref;
40929         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
40930         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
40931         LDKPublicKey broadcaster_delayed_payment_key_ref;
40932         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
40933         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
40934         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
40935         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40936         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40937         CVec_u8Z_free(ret_var);
40938         return ret_arr;
40939 }
40940
40941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40942         LDKHTLCOutputInCommitment this_obj_conv;
40943         this_obj_conv.inner = untag_ptr(this_obj);
40944         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40946         HTLCOutputInCommitment_free(this_obj_conv);
40947 }
40948
40949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
40950         LDKHTLCOutputInCommitment this_ptr_conv;
40951         this_ptr_conv.inner = untag_ptr(this_ptr);
40952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40954         this_ptr_conv.is_owned = false;
40955         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
40956         return ret_conv;
40957 }
40958
40959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40960         LDKHTLCOutputInCommitment this_ptr_conv;
40961         this_ptr_conv.inner = untag_ptr(this_ptr);
40962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40964         this_ptr_conv.is_owned = false;
40965         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
40966 }
40967
40968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40969         LDKHTLCOutputInCommitment this_ptr_conv;
40970         this_ptr_conv.inner = untag_ptr(this_ptr);
40971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40973         this_ptr_conv.is_owned = false;
40974         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
40975         return ret_conv;
40976 }
40977
40978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40979         LDKHTLCOutputInCommitment this_ptr_conv;
40980         this_ptr_conv.inner = untag_ptr(this_ptr);
40981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40983         this_ptr_conv.is_owned = false;
40984         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
40985 }
40986
40987 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
40988         LDKHTLCOutputInCommitment this_ptr_conv;
40989         this_ptr_conv.inner = untag_ptr(this_ptr);
40990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40992         this_ptr_conv.is_owned = false;
40993         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
40994         return ret_conv;
40995 }
40996
40997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40998         LDKHTLCOutputInCommitment this_ptr_conv;
40999         this_ptr_conv.inner = untag_ptr(this_ptr);
41000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41002         this_ptr_conv.is_owned = false;
41003         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
41004 }
41005
41006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
41007         LDKHTLCOutputInCommitment this_ptr_conv;
41008         this_ptr_conv.inner = untag_ptr(this_ptr);
41009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41011         this_ptr_conv.is_owned = false;
41012         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
41014         return ret_arr;
41015 }
41016
41017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41018         LDKHTLCOutputInCommitment this_ptr_conv;
41019         this_ptr_conv.inner = untag_ptr(this_ptr);
41020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41022         this_ptr_conv.is_owned = false;
41023         LDKThirtyTwoBytes val_ref;
41024         CHECK((*env)->GetArrayLength(env, val) == 32);
41025         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
41026         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
41027 }
41028
41029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
41030         LDKHTLCOutputInCommitment this_ptr_conv;
41031         this_ptr_conv.inner = untag_ptr(this_ptr);
41032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41034         this_ptr_conv.is_owned = false;
41035         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
41036         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
41037         int64_t ret_ref = tag_ptr(ret_copy, true);
41038         return ret_ref;
41039 }
41040
41041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41042         LDKHTLCOutputInCommitment this_ptr_conv;
41043         this_ptr_conv.inner = untag_ptr(this_ptr);
41044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41046         this_ptr_conv.is_owned = false;
41047         void* val_ptr = untag_ptr(val);
41048         CHECK_ACCESS(val_ptr);
41049         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
41050         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
41051         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
41052 }
41053
41054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new(JNIEnv *env, jclass clz, jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, int64_t transaction_output_index_arg) {
41055         LDKThirtyTwoBytes payment_hash_arg_ref;
41056         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
41057         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
41058         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
41059         CHECK_ACCESS(transaction_output_index_arg_ptr);
41060         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
41061         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
41062         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
41063         int64_t ret_ref = 0;
41064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41066         return ret_ref;
41067 }
41068
41069 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
41070         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
41071         int64_t ret_ref = 0;
41072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41074         return ret_ref;
41075 }
41076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41077         LDKHTLCOutputInCommitment arg_conv;
41078         arg_conv.inner = untag_ptr(arg);
41079         arg_conv.is_owned = ptr_is_owned(arg);
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41081         arg_conv.is_owned = false;
41082         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
41083         return ret_conv;
41084 }
41085
41086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41087         LDKHTLCOutputInCommitment orig_conv;
41088         orig_conv.inner = untag_ptr(orig);
41089         orig_conv.is_owned = ptr_is_owned(orig);
41090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41091         orig_conv.is_owned = false;
41092         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
41093         int64_t ret_ref = 0;
41094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41096         return ret_ref;
41097 }
41098
41099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41100         LDKHTLCOutputInCommitment a_conv;
41101         a_conv.inner = untag_ptr(a);
41102         a_conv.is_owned = ptr_is_owned(a);
41103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41104         a_conv.is_owned = false;
41105         LDKHTLCOutputInCommitment b_conv;
41106         b_conv.inner = untag_ptr(b);
41107         b_conv.is_owned = ptr_is_owned(b);
41108         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41109         b_conv.is_owned = false;
41110         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
41111         return ret_conv;
41112 }
41113
41114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
41115         LDKHTLCOutputInCommitment obj_conv;
41116         obj_conv.inner = untag_ptr(obj);
41117         obj_conv.is_owned = ptr_is_owned(obj);
41118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41119         obj_conv.is_owned = false;
41120         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
41121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41123         CVec_u8Z_free(ret_var);
41124         return ret_arr;
41125 }
41126
41127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41128         LDKu8slice ser_ref;
41129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41131         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
41132         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
41133         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41134         return tag_ptr(ret_conv, true);
41135 }
41136
41137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, jboolean opt_anchors, int64_t keys) {
41138         LDKHTLCOutputInCommitment htlc_conv;
41139         htlc_conv.inner = untag_ptr(htlc);
41140         htlc_conv.is_owned = ptr_is_owned(htlc);
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
41142         htlc_conv.is_owned = false;
41143         LDKTxCreationKeys keys_conv;
41144         keys_conv.inner = untag_ptr(keys);
41145         keys_conv.is_owned = ptr_is_owned(keys);
41146         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
41147         keys_conv.is_owned = false;
41148         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
41149         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41150         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41151         CVec_u8Z_free(ret_var);
41152         return ret_arr;
41153 }
41154
41155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
41156         LDKPublicKey broadcaster_ref;
41157         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
41158         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
41159         LDKPublicKey countersignatory_ref;
41160         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
41161         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
41162         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
41163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41165         CVec_u8Z_free(ret_var);
41166         return ret_arr;
41167 }
41168
41169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv *env, jclass clz, int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, int64_t htlc, jboolean opt_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
41170         unsigned char commitment_txid_arr[32];
41171         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
41172         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
41173         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
41174         LDKHTLCOutputInCommitment htlc_conv;
41175         htlc_conv.inner = untag_ptr(htlc);
41176         htlc_conv.is_owned = ptr_is_owned(htlc);
41177         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
41178         htlc_conv.is_owned = false;
41179         LDKPublicKey broadcaster_delayed_payment_key_ref;
41180         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
41181         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
41182         LDKPublicKey revocation_key_ref;
41183         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
41184         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
41185         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, opt_anchors, broadcaster_delayed_payment_key_ref, revocation_key_ref);
41186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41188         Transaction_free(ret_var);
41189         return ret_arr;
41190 }
41191
41192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
41193         LDKPublicKey funding_pubkey_ref;
41194         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
41195         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
41196         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
41197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41199         CVec_u8Z_free(ret_var);
41200         return ret_arr;
41201 }
41202
41203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41204         LDKChannelTransactionParameters this_obj_conv;
41205         this_obj_conv.inner = untag_ptr(this_obj);
41206         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41208         ChannelTransactionParameters_free(this_obj_conv);
41209 }
41210
41211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
41212         LDKChannelTransactionParameters this_ptr_conv;
41213         this_ptr_conv.inner = untag_ptr(this_ptr);
41214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41216         this_ptr_conv.is_owned = false;
41217         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
41218         int64_t ret_ref = 0;
41219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41220         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41221         return ret_ref;
41222 }
41223
41224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41225         LDKChannelTransactionParameters this_ptr_conv;
41226         this_ptr_conv.inner = untag_ptr(this_ptr);
41227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41229         this_ptr_conv.is_owned = false;
41230         LDKChannelPublicKeys val_conv;
41231         val_conv.inner = untag_ptr(val);
41232         val_conv.is_owned = ptr_is_owned(val);
41233         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41234         val_conv = ChannelPublicKeys_clone(&val_conv);
41235         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
41236 }
41237
41238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
41239         LDKChannelTransactionParameters this_ptr_conv;
41240         this_ptr_conv.inner = untag_ptr(this_ptr);
41241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41243         this_ptr_conv.is_owned = false;
41244         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
41245         return ret_conv;
41246 }
41247
41248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41249         LDKChannelTransactionParameters this_ptr_conv;
41250         this_ptr_conv.inner = untag_ptr(this_ptr);
41251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41253         this_ptr_conv.is_owned = false;
41254         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
41255 }
41256
41257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
41258         LDKChannelTransactionParameters this_ptr_conv;
41259         this_ptr_conv.inner = untag_ptr(this_ptr);
41260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41262         this_ptr_conv.is_owned = false;
41263         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
41264         return ret_conv;
41265 }
41266
41267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41268         LDKChannelTransactionParameters this_ptr_conv;
41269         this_ptr_conv.inner = untag_ptr(this_ptr);
41270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41272         this_ptr_conv.is_owned = false;
41273         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
41274 }
41275
41276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
41277         LDKChannelTransactionParameters this_ptr_conv;
41278         this_ptr_conv.inner = untag_ptr(this_ptr);
41279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41281         this_ptr_conv.is_owned = false;
41282         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
41283         int64_t ret_ref = 0;
41284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41286         return ret_ref;
41287 }
41288
41289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41290         LDKChannelTransactionParameters this_ptr_conv;
41291         this_ptr_conv.inner = untag_ptr(this_ptr);
41292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41294         this_ptr_conv.is_owned = false;
41295         LDKCounterpartyChannelTransactionParameters val_conv;
41296         val_conv.inner = untag_ptr(val);
41297         val_conv.is_owned = ptr_is_owned(val);
41298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41299         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
41300         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
41301 }
41302
41303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41304         LDKChannelTransactionParameters this_ptr_conv;
41305         this_ptr_conv.inner = untag_ptr(this_ptr);
41306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41308         this_ptr_conv.is_owned = false;
41309         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
41310         int64_t ret_ref = 0;
41311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41313         return ret_ref;
41314 }
41315
41316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41317         LDKChannelTransactionParameters this_ptr_conv;
41318         this_ptr_conv.inner = untag_ptr(this_ptr);
41319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41321         this_ptr_conv.is_owned = false;
41322         LDKOutPoint val_conv;
41323         val_conv.inner = untag_ptr(val);
41324         val_conv.is_owned = ptr_is_owned(val);
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41326         val_conv = OutPoint_clone(&val_conv);
41327         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
41328 }
41329
41330 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
41331         LDKChannelTransactionParameters this_ptr_conv;
41332         this_ptr_conv.inner = untag_ptr(this_ptr);
41333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41335         this_ptr_conv.is_owned = false;
41336         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
41337         return ret_conv;
41338 }
41339
41340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
41341         LDKChannelTransactionParameters this_ptr_conv;
41342         this_ptr_conv.inner = untag_ptr(this_ptr);
41343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41345         this_ptr_conv.is_owned = false;
41346         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
41347         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
41348 }
41349
41350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1new(JNIEnv *env, jclass clz, int64_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, int64_t counterparty_parameters_arg, int64_t funding_outpoint_arg, jclass opt_anchors_arg) {
41351         LDKChannelPublicKeys holder_pubkeys_arg_conv;
41352         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
41353         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
41354         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
41355         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
41356         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
41357         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
41358         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
41359         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
41360         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
41361         LDKOutPoint funding_outpoint_arg_conv;
41362         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
41363         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
41364         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
41365         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
41366         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
41367         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv, opt_anchors_arg_conv);
41368         int64_t ret_ref = 0;
41369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41371         return ret_ref;
41372 }
41373
41374 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
41375         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
41376         int64_t ret_ref = 0;
41377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41379         return ret_ref;
41380 }
41381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41382         LDKChannelTransactionParameters arg_conv;
41383         arg_conv.inner = untag_ptr(arg);
41384         arg_conv.is_owned = ptr_is_owned(arg);
41385         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41386         arg_conv.is_owned = false;
41387         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
41388         return ret_conv;
41389 }
41390
41391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41392         LDKChannelTransactionParameters orig_conv;
41393         orig_conv.inner = untag_ptr(orig);
41394         orig_conv.is_owned = ptr_is_owned(orig);
41395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41396         orig_conv.is_owned = false;
41397         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
41398         int64_t ret_ref = 0;
41399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41401         return ret_ref;
41402 }
41403
41404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41405         LDKCounterpartyChannelTransactionParameters this_obj_conv;
41406         this_obj_conv.inner = untag_ptr(this_obj);
41407         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41409         CounterpartyChannelTransactionParameters_free(this_obj_conv);
41410 }
41411
41412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
41413         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41414         this_ptr_conv.inner = untag_ptr(this_ptr);
41415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41417         this_ptr_conv.is_owned = false;
41418         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
41419         int64_t ret_ref = 0;
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41422         return ret_ref;
41423 }
41424
41425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41426         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41427         this_ptr_conv.inner = untag_ptr(this_ptr);
41428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41430         this_ptr_conv.is_owned = false;
41431         LDKChannelPublicKeys val_conv;
41432         val_conv.inner = untag_ptr(val);
41433         val_conv.is_owned = ptr_is_owned(val);
41434         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41435         val_conv = ChannelPublicKeys_clone(&val_conv);
41436         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
41437 }
41438
41439 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
41440         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41441         this_ptr_conv.inner = untag_ptr(this_ptr);
41442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41444         this_ptr_conv.is_owned = false;
41445         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
41446         return ret_conv;
41447 }
41448
41449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41450         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41451         this_ptr_conv.inner = untag_ptr(this_ptr);
41452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41454         this_ptr_conv.is_owned = false;
41455         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
41456 }
41457
41458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1new(JNIEnv *env, jclass clz, int64_t pubkeys_arg, int16_t selected_contest_delay_arg) {
41459         LDKChannelPublicKeys pubkeys_arg_conv;
41460         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
41461         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
41462         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
41463         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
41464         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
41465         int64_t ret_ref = 0;
41466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41467         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41468         return ret_ref;
41469 }
41470
41471 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
41472         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
41473         int64_t ret_ref = 0;
41474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41476         return ret_ref;
41477 }
41478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41479         LDKCounterpartyChannelTransactionParameters arg_conv;
41480         arg_conv.inner = untag_ptr(arg);
41481         arg_conv.is_owned = ptr_is_owned(arg);
41482         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41483         arg_conv.is_owned = false;
41484         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
41485         return ret_conv;
41486 }
41487
41488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41489         LDKCounterpartyChannelTransactionParameters orig_conv;
41490         orig_conv.inner = untag_ptr(orig);
41491         orig_conv.is_owned = ptr_is_owned(orig);
41492         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41493         orig_conv.is_owned = false;
41494         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
41495         int64_t ret_ref = 0;
41496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41498         return ret_ref;
41499 }
41500
41501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
41502         LDKChannelTransactionParameters this_arg_conv;
41503         this_arg_conv.inner = untag_ptr(this_arg);
41504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41506         this_arg_conv.is_owned = false;
41507         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
41508         return ret_conv;
41509 }
41510
41511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
41512         LDKChannelTransactionParameters this_arg_conv;
41513         this_arg_conv.inner = untag_ptr(this_arg);
41514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41516         this_arg_conv.is_owned = false;
41517         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
41518         int64_t ret_ref = 0;
41519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41521         return ret_ref;
41522 }
41523
41524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
41525         LDKChannelTransactionParameters this_arg_conv;
41526         this_arg_conv.inner = untag_ptr(this_arg);
41527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41529         this_arg_conv.is_owned = false;
41530         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
41531         int64_t ret_ref = 0;
41532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41534         return ret_ref;
41535 }
41536
41537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41538         LDKCounterpartyChannelTransactionParameters obj_conv;
41539         obj_conv.inner = untag_ptr(obj);
41540         obj_conv.is_owned = ptr_is_owned(obj);
41541         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41542         obj_conv.is_owned = false;
41543         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
41544         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41545         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41546         CVec_u8Z_free(ret_var);
41547         return ret_arr;
41548 }
41549
41550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41551         LDKu8slice ser_ref;
41552         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41553         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41554         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
41555         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
41556         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41557         return tag_ptr(ret_conv, true);
41558 }
41559
41560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41561         LDKChannelTransactionParameters obj_conv;
41562         obj_conv.inner = untag_ptr(obj);
41563         obj_conv.is_owned = ptr_is_owned(obj);
41564         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41565         obj_conv.is_owned = false;
41566         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
41567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41569         CVec_u8Z_free(ret_var);
41570         return ret_arr;
41571 }
41572
41573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41574         LDKu8slice ser_ref;
41575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41577         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
41578         *ret_conv = ChannelTransactionParameters_read(ser_ref);
41579         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41580         return tag_ptr(ret_conv, true);
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41584         LDKDirectedChannelTransactionParameters this_obj_conv;
41585         this_obj_conv.inner = untag_ptr(this_obj);
41586         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41588         DirectedChannelTransactionParameters_free(this_obj_conv);
41589 }
41590
41591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
41592         LDKDirectedChannelTransactionParameters this_arg_conv;
41593         this_arg_conv.inner = untag_ptr(this_arg);
41594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41596         this_arg_conv.is_owned = false;
41597         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
41598         int64_t ret_ref = 0;
41599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41601         return ret_ref;
41602 }
41603
41604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
41605         LDKDirectedChannelTransactionParameters this_arg_conv;
41606         this_arg_conv.inner = untag_ptr(this_arg);
41607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41609         this_arg_conv.is_owned = false;
41610         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
41611         int64_t ret_ref = 0;
41612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41614         return ret_ref;
41615 }
41616
41617 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
41618         LDKDirectedChannelTransactionParameters this_arg_conv;
41619         this_arg_conv.inner = untag_ptr(this_arg);
41620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41622         this_arg_conv.is_owned = false;
41623         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
41624         return ret_conv;
41625 }
41626
41627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
41628         LDKDirectedChannelTransactionParameters this_arg_conv;
41629         this_arg_conv.inner = untag_ptr(this_arg);
41630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41632         this_arg_conv.is_owned = false;
41633         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
41634         return ret_conv;
41635 }
41636
41637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
41638         LDKDirectedChannelTransactionParameters this_arg_conv;
41639         this_arg_conv.inner = untag_ptr(this_arg);
41640         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41642         this_arg_conv.is_owned = false;
41643         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
41644         int64_t ret_ref = 0;
41645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41647         return ret_ref;
41648 }
41649
41650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
41651         LDKDirectedChannelTransactionParameters this_arg_conv;
41652         this_arg_conv.inner = untag_ptr(this_arg);
41653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41655         this_arg_conv.is_owned = false;
41656         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
41657         return ret_conv;
41658 }
41659
41660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41661         LDKHolderCommitmentTransaction this_obj_conv;
41662         this_obj_conv.inner = untag_ptr(this_obj);
41663         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41665         HolderCommitmentTransaction_free(this_obj_conv);
41666 }
41667
41668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
41669         LDKHolderCommitmentTransaction this_ptr_conv;
41670         this_ptr_conv.inner = untag_ptr(this_ptr);
41671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41673         this_ptr_conv.is_owned = false;
41674         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
41675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
41676         return ret_arr;
41677 }
41678
41679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41680         LDKHolderCommitmentTransaction this_ptr_conv;
41681         this_ptr_conv.inner = untag_ptr(this_ptr);
41682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41684         this_ptr_conv.is_owned = false;
41685         LDKSignature val_ref;
41686         CHECK((*env)->GetArrayLength(env, val) == 64);
41687         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
41688         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
41689 }
41690
41691 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
41692         LDKHolderCommitmentTransaction this_ptr_conv;
41693         this_ptr_conv.inner = untag_ptr(this_ptr);
41694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41696         this_ptr_conv.is_owned = false;
41697         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
41698         jobjectArray ret_arr = NULL;
41699         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
41700         ;
41701         for (size_t i = 0; i < ret_var.datalen; i++) {
41702                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
41703                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
41704                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
41705         }
41706         
41707         FREE(ret_var.data);
41708         return ret_arr;
41709 }
41710
41711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41712         LDKHolderCommitmentTransaction this_ptr_conv;
41713         this_ptr_conv.inner = untag_ptr(this_ptr);
41714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41716         this_ptr_conv.is_owned = false;
41717         LDKCVec_SignatureZ val_constr;
41718         val_constr.datalen = (*env)->GetArrayLength(env, val);
41719         if (val_constr.datalen > 0)
41720                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
41721         else
41722                 val_constr.data = NULL;
41723         for (size_t i = 0; i < val_constr.datalen; i++) {
41724                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
41725                 LDKSignature val_conv_8_ref;
41726                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
41727                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
41728                 val_constr.data[i] = val_conv_8_ref;
41729         }
41730         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
41731 }
41732
41733 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
41734         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
41735         int64_t ret_ref = 0;
41736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41738         return ret_ref;
41739 }
41740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41741         LDKHolderCommitmentTransaction arg_conv;
41742         arg_conv.inner = untag_ptr(arg);
41743         arg_conv.is_owned = ptr_is_owned(arg);
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41745         arg_conv.is_owned = false;
41746         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
41747         return ret_conv;
41748 }
41749
41750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41751         LDKHolderCommitmentTransaction orig_conv;
41752         orig_conv.inner = untag_ptr(orig);
41753         orig_conv.is_owned = ptr_is_owned(orig);
41754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41755         orig_conv.is_owned = false;
41756         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
41757         int64_t ret_ref = 0;
41758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41760         return ret_ref;
41761 }
41762
41763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
41764         LDKHolderCommitmentTransaction obj_conv;
41765         obj_conv.inner = untag_ptr(obj);
41766         obj_conv.is_owned = ptr_is_owned(obj);
41767         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41768         obj_conv.is_owned = false;
41769         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
41770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41772         CVec_u8Z_free(ret_var);
41773         return ret_arr;
41774 }
41775
41776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41777         LDKu8slice ser_ref;
41778         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41779         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41780         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
41781         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
41782         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41783         return tag_ptr(ret_conv, true);
41784 }
41785
41786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new(JNIEnv *env, jclass clz, int64_t commitment_tx, int8_tArray counterparty_sig, jobjectArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
41787         LDKCommitmentTransaction commitment_tx_conv;
41788         commitment_tx_conv.inner = untag_ptr(commitment_tx);
41789         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
41790         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
41791         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
41792         LDKSignature counterparty_sig_ref;
41793         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
41794         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
41795         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
41796         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
41797         if (counterparty_htlc_sigs_constr.datalen > 0)
41798                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
41799         else
41800                 counterparty_htlc_sigs_constr.data = NULL;
41801         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
41802                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
41803                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
41804                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
41805                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
41806                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
41807         }
41808         LDKPublicKey holder_funding_key_ref;
41809         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
41810         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
41811         LDKPublicKey counterparty_funding_key_ref;
41812         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
41813         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
41814         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
41815         int64_t ret_ref = 0;
41816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41818         return ret_ref;
41819 }
41820
41821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41822         LDKBuiltCommitmentTransaction this_obj_conv;
41823         this_obj_conv.inner = untag_ptr(this_obj);
41824         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41826         BuiltCommitmentTransaction_free(this_obj_conv);
41827 }
41828
41829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
41830         LDKBuiltCommitmentTransaction this_ptr_conv;
41831         this_ptr_conv.inner = untag_ptr(this_ptr);
41832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41834         this_ptr_conv.is_owned = false;
41835         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
41836         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41837         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41838         Transaction_free(ret_var);
41839         return ret_arr;
41840 }
41841
41842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41843         LDKBuiltCommitmentTransaction this_ptr_conv;
41844         this_ptr_conv.inner = untag_ptr(this_ptr);
41845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41847         this_ptr_conv.is_owned = false;
41848         LDKTransaction val_ref;
41849         val_ref.datalen = (*env)->GetArrayLength(env, val);
41850         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
41851         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
41852         val_ref.data_is_owned = true;
41853         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
41854 }
41855
41856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
41857         LDKBuiltCommitmentTransaction this_ptr_conv;
41858         this_ptr_conv.inner = untag_ptr(this_ptr);
41859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41861         this_ptr_conv.is_owned = false;
41862         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41863         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
41864         return ret_arr;
41865 }
41866
41867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41868         LDKBuiltCommitmentTransaction this_ptr_conv;
41869         this_ptr_conv.inner = untag_ptr(this_ptr);
41870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41872         this_ptr_conv.is_owned = false;
41873         LDKThirtyTwoBytes val_ref;
41874         CHECK((*env)->GetArrayLength(env, val) == 32);
41875         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
41876         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
41877 }
41878
41879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
41880         LDKTransaction transaction_arg_ref;
41881         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
41882         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
41883         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
41884         transaction_arg_ref.data_is_owned = true;
41885         LDKThirtyTwoBytes txid_arg_ref;
41886         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
41887         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
41888         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
41889         int64_t ret_ref = 0;
41890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41892         return ret_ref;
41893 }
41894
41895 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
41896         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
41897         int64_t ret_ref = 0;
41898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41900         return ret_ref;
41901 }
41902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41903         LDKBuiltCommitmentTransaction arg_conv;
41904         arg_conv.inner = untag_ptr(arg);
41905         arg_conv.is_owned = ptr_is_owned(arg);
41906         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41907         arg_conv.is_owned = false;
41908         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
41909         return ret_conv;
41910 }
41911
41912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41913         LDKBuiltCommitmentTransaction orig_conv;
41914         orig_conv.inner = untag_ptr(orig);
41915         orig_conv.is_owned = ptr_is_owned(orig);
41916         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41917         orig_conv.is_owned = false;
41918         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
41919         int64_t ret_ref = 0;
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41922         return ret_ref;
41923 }
41924
41925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
41926         LDKBuiltCommitmentTransaction obj_conv;
41927         obj_conv.inner = untag_ptr(obj);
41928         obj_conv.is_owned = ptr_is_owned(obj);
41929         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41930         obj_conv.is_owned = false;
41931         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
41932         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41933         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41934         CVec_u8Z_free(ret_var);
41935         return ret_arr;
41936 }
41937
41938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41939         LDKu8slice ser_ref;
41940         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41941         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41942         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
41943         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
41944         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41945         return tag_ptr(ret_conv, true);
41946 }
41947
41948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
41949         LDKBuiltCommitmentTransaction this_arg_conv;
41950         this_arg_conv.inner = untag_ptr(this_arg);
41951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41953         this_arg_conv.is_owned = false;
41954         LDKu8slice funding_redeemscript_ref;
41955         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41956         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41957         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
41959         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41960         return ret_arr;
41961 }
41962
41963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
41964         LDKBuiltCommitmentTransaction this_arg_conv;
41965         this_arg_conv.inner = untag_ptr(this_arg);
41966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41968         this_arg_conv.is_owned = false;
41969         unsigned char funding_key_arr[32];
41970         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
41971         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
41972         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
41973         LDKu8slice funding_redeemscript_ref;
41974         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41975         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41976         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
41977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
41978         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41979         return ret_arr;
41980 }
41981
41982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41983         LDKClosingTransaction this_obj_conv;
41984         this_obj_conv.inner = untag_ptr(this_obj);
41985         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41987         ClosingTransaction_free(this_obj_conv);
41988 }
41989
41990 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
41991         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
41992         int64_t ret_ref = 0;
41993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41995         return ret_ref;
41996 }
41997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41998         LDKClosingTransaction arg_conv;
41999         arg_conv.inner = untag_ptr(arg);
42000         arg_conv.is_owned = ptr_is_owned(arg);
42001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42002         arg_conv.is_owned = false;
42003         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
42004         return ret_conv;
42005 }
42006
42007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42008         LDKClosingTransaction orig_conv;
42009         orig_conv.inner = untag_ptr(orig);
42010         orig_conv.is_owned = ptr_is_owned(orig);
42011         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42012         orig_conv.is_owned = false;
42013         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
42014         int64_t ret_ref = 0;
42015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42017         return ret_ref;
42018 }
42019
42020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
42021         LDKClosingTransaction o_conv;
42022         o_conv.inner = untag_ptr(o);
42023         o_conv.is_owned = ptr_is_owned(o);
42024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42025         o_conv.is_owned = false;
42026         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
42027         return ret_conv;
42028 }
42029
42030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42031         LDKClosingTransaction a_conv;
42032         a_conv.inner = untag_ptr(a);
42033         a_conv.is_owned = ptr_is_owned(a);
42034         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42035         a_conv.is_owned = false;
42036         LDKClosingTransaction b_conv;
42037         b_conv.inner = untag_ptr(b);
42038         b_conv.is_owned = ptr_is_owned(b);
42039         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42040         b_conv.is_owned = false;
42041         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
42042         return ret_conv;
42043 }
42044
42045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
42046         LDKCVec_u8Z to_holder_script_ref;
42047         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42048         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42049         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42050         LDKCVec_u8Z to_counterparty_script_ref;
42051         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42052         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42053         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42054         LDKOutPoint funding_outpoint_conv;
42055         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42056         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42057         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42058         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42059         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
42060         int64_t ret_ref = 0;
42061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42063         return ret_ref;
42064 }
42065
42066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
42067         LDKClosingTransaction this_arg_conv;
42068         this_arg_conv.inner = untag_ptr(this_arg);
42069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42071         this_arg_conv.is_owned = false;
42072         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
42073         int64_t ret_ref = 0;
42074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42076         return ret_ref;
42077 }
42078
42079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
42080         LDKClosingTransaction this_arg_conv;
42081         this_arg_conv.inner = untag_ptr(this_arg);
42082         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42084         this_arg_conv.is_owned = false;
42085         LDKOutPoint funding_outpoint_conv;
42086         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42087         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42089         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42090         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
42091         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
42092         return tag_ptr(ret_conv, true);
42093 }
42094
42095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42096         LDKClosingTransaction this_arg_conv;
42097         this_arg_conv.inner = untag_ptr(this_arg);
42098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42100         this_arg_conv.is_owned = false;
42101         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
42102         return ret_conv;
42103 }
42104
42105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42106         LDKClosingTransaction this_arg_conv;
42107         this_arg_conv.inner = untag_ptr(this_arg);
42108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42110         this_arg_conv.is_owned = false;
42111         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
42112         return ret_conv;
42113 }
42114
42115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
42116         LDKClosingTransaction this_arg_conv;
42117         this_arg_conv.inner = untag_ptr(this_arg);
42118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42120         this_arg_conv.is_owned = false;
42121         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
42122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42124         return ret_arr;
42125 }
42126
42127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
42128         LDKClosingTransaction this_arg_conv;
42129         this_arg_conv.inner = untag_ptr(this_arg);
42130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42132         this_arg_conv.is_owned = false;
42133         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
42134         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42135         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42136         return ret_arr;
42137 }
42138
42139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42140         LDKTrustedClosingTransaction this_obj_conv;
42141         this_obj_conv.inner = untag_ptr(this_obj);
42142         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42144         TrustedClosingTransaction_free(this_obj_conv);
42145 }
42146
42147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
42148         LDKTrustedClosingTransaction this_arg_conv;
42149         this_arg_conv.inner = untag_ptr(this_arg);
42150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42152         this_arg_conv.is_owned = false;
42153         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
42154         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42155         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42156         Transaction_free(ret_var);
42157         return ret_arr;
42158 }
42159
42160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
42161         LDKTrustedClosingTransaction this_arg_conv;
42162         this_arg_conv.inner = untag_ptr(this_arg);
42163         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42165         this_arg_conv.is_owned = false;
42166         LDKu8slice funding_redeemscript_ref;
42167         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
42168         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
42169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
42171         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
42172         return ret_arr;
42173 }
42174
42175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
42176         LDKTrustedClosingTransaction this_arg_conv;
42177         this_arg_conv.inner = untag_ptr(this_arg);
42178         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42180         this_arg_conv.is_owned = false;
42181         unsigned char funding_key_arr[32];
42182         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
42183         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
42184         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
42185         LDKu8slice funding_redeemscript_ref;
42186         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
42187         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
42188         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
42189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
42190         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
42191         return ret_arr;
42192 }
42193
42194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42195         LDKCommitmentTransaction this_obj_conv;
42196         this_obj_conv.inner = untag_ptr(this_obj);
42197         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42199         CommitmentTransaction_free(this_obj_conv);
42200 }
42201
42202 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
42203         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
42204         int64_t ret_ref = 0;
42205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42207         return ret_ref;
42208 }
42209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42210         LDKCommitmentTransaction arg_conv;
42211         arg_conv.inner = untag_ptr(arg);
42212         arg_conv.is_owned = ptr_is_owned(arg);
42213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42214         arg_conv.is_owned = false;
42215         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
42216         return ret_conv;
42217 }
42218
42219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42220         LDKCommitmentTransaction orig_conv;
42221         orig_conv.inner = untag_ptr(orig);
42222         orig_conv.is_owned = ptr_is_owned(orig);
42223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42224         orig_conv.is_owned = false;
42225         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
42226         int64_t ret_ref = 0;
42227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42229         return ret_ref;
42230 }
42231
42232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
42233         LDKCommitmentTransaction obj_conv;
42234         obj_conv.inner = untag_ptr(obj);
42235         obj_conv.is_owned = ptr_is_owned(obj);
42236         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42237         obj_conv.is_owned = false;
42238         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
42239         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42240         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42241         CVec_u8Z_free(ret_var);
42242         return ret_arr;
42243 }
42244
42245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42246         LDKu8slice ser_ref;
42247         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42248         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42249         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
42250         *ret_conv = CommitmentTransaction_read(ser_ref);
42251         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42252         return tag_ptr(ret_conv, true);
42253 }
42254
42255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
42256         LDKCommitmentTransaction this_arg_conv;
42257         this_arg_conv.inner = untag_ptr(this_arg);
42258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42260         this_arg_conv.is_owned = false;
42261         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
42262         return ret_conv;
42263 }
42264
42265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42266         LDKCommitmentTransaction this_arg_conv;
42267         this_arg_conv.inner = untag_ptr(this_arg);
42268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42270         this_arg_conv.is_owned = false;
42271         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
42272         return ret_conv;
42273 }
42274
42275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42276         LDKCommitmentTransaction this_arg_conv;
42277         this_arg_conv.inner = untag_ptr(this_arg);
42278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42280         this_arg_conv.is_owned = false;
42281         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
42282         return ret_conv;
42283 }
42284
42285 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
42286         LDKCommitmentTransaction this_arg_conv;
42287         this_arg_conv.inner = untag_ptr(this_arg);
42288         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42290         this_arg_conv.is_owned = false;
42291         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
42292         return ret_conv;
42293 }
42294
42295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
42296         LDKCommitmentTransaction this_arg_conv;
42297         this_arg_conv.inner = untag_ptr(this_arg);
42298         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42300         this_arg_conv.is_owned = false;
42301         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
42302         int64_t ret_ref = 0;
42303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42305         return ret_ref;
42306 }
42307
42308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters, int64_t broadcaster_keys, int64_t countersignatory_keys) {
42309         LDKCommitmentTransaction this_arg_conv;
42310         this_arg_conv.inner = untag_ptr(this_arg);
42311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42313         this_arg_conv.is_owned = false;
42314         LDKDirectedChannelTransactionParameters channel_parameters_conv;
42315         channel_parameters_conv.inner = untag_ptr(channel_parameters);
42316         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
42317         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
42318         channel_parameters_conv.is_owned = false;
42319         LDKChannelPublicKeys broadcaster_keys_conv;
42320         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42321         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42322         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42323         broadcaster_keys_conv.is_owned = false;
42324         LDKChannelPublicKeys countersignatory_keys_conv;
42325         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42326         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42327         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42328         countersignatory_keys_conv.is_owned = false;
42329         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
42330         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
42331         return tag_ptr(ret_conv, true);
42332 }
42333
42334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42335         LDKTrustedCommitmentTransaction this_obj_conv;
42336         this_obj_conv.inner = untag_ptr(this_obj);
42337         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42339         TrustedCommitmentTransaction_free(this_obj_conv);
42340 }
42341
42342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
42343         LDKTrustedCommitmentTransaction this_arg_conv;
42344         this_arg_conv.inner = untag_ptr(this_arg);
42345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42347         this_arg_conv.is_owned = false;
42348         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
42350         return ret_arr;
42351 }
42352
42353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
42354         LDKTrustedCommitmentTransaction this_arg_conv;
42355         this_arg_conv.inner = untag_ptr(this_arg);
42356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42358         this_arg_conv.is_owned = false;
42359         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
42360         int64_t ret_ref = 0;
42361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42363         return ret_ref;
42364 }
42365
42366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
42367         LDKTrustedCommitmentTransaction this_arg_conv;
42368         this_arg_conv.inner = untag_ptr(this_arg);
42369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42371         this_arg_conv.is_owned = false;
42372         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
42373         int64_t ret_ref = 0;
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42376         return ret_ref;
42377 }
42378
42379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
42380         LDKTrustedCommitmentTransaction this_arg_conv;
42381         this_arg_conv.inner = untag_ptr(this_arg);
42382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42384         this_arg_conv.is_owned = false;
42385         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
42386         return ret_conv;
42387 }
42388
42389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1get_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_base_key, int64_t channel_parameters) {
42390         LDKTrustedCommitmentTransaction this_arg_conv;
42391         this_arg_conv.inner = untag_ptr(this_arg);
42392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42394         this_arg_conv.is_owned = false;
42395         unsigned char htlc_base_key_arr[32];
42396         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
42397         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
42398         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
42399         LDKDirectedChannelTransactionParameters channel_parameters_conv;
42400         channel_parameters_conv.inner = untag_ptr(channel_parameters);
42401         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
42402         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
42403         channel_parameters_conv.is_owned = false;
42404         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
42405         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
42406         return tag_ptr(ret_conv, true);
42407 }
42408
42409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1commitment_1transaction_1number_1obscure_1factor(JNIEnv *env, jclass clz, int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
42410         LDKPublicKey broadcaster_payment_basepoint_ref;
42411         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
42412         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
42413         LDKPublicKey countersignatory_payment_basepoint_ref;
42414         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
42415         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
42416         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
42417         return ret_conv;
42418 }
42419
42420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42421         LDKInitFeatures a_conv;
42422         a_conv.inner = untag_ptr(a);
42423         a_conv.is_owned = ptr_is_owned(a);
42424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42425         a_conv.is_owned = false;
42426         LDKInitFeatures b_conv;
42427         b_conv.inner = untag_ptr(b);
42428         b_conv.is_owned = ptr_is_owned(b);
42429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42430         b_conv.is_owned = false;
42431         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
42432         return ret_conv;
42433 }
42434
42435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42436         LDKNodeFeatures a_conv;
42437         a_conv.inner = untag_ptr(a);
42438         a_conv.is_owned = ptr_is_owned(a);
42439         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42440         a_conv.is_owned = false;
42441         LDKNodeFeatures b_conv;
42442         b_conv.inner = untag_ptr(b);
42443         b_conv.is_owned = ptr_is_owned(b);
42444         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42445         b_conv.is_owned = false;
42446         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
42447         return ret_conv;
42448 }
42449
42450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42451         LDKChannelFeatures a_conv;
42452         a_conv.inner = untag_ptr(a);
42453         a_conv.is_owned = ptr_is_owned(a);
42454         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42455         a_conv.is_owned = false;
42456         LDKChannelFeatures b_conv;
42457         b_conv.inner = untag_ptr(b);
42458         b_conv.is_owned = ptr_is_owned(b);
42459         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42460         b_conv.is_owned = false;
42461         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
42462         return ret_conv;
42463 }
42464
42465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42466         LDKInvoiceFeatures a_conv;
42467         a_conv.inner = untag_ptr(a);
42468         a_conv.is_owned = ptr_is_owned(a);
42469         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42470         a_conv.is_owned = false;
42471         LDKInvoiceFeatures b_conv;
42472         b_conv.inner = untag_ptr(b);
42473         b_conv.is_owned = ptr_is_owned(b);
42474         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42475         b_conv.is_owned = false;
42476         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
42477         return ret_conv;
42478 }
42479
42480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42481         LDKChannelTypeFeatures a_conv;
42482         a_conv.inner = untag_ptr(a);
42483         a_conv.is_owned = ptr_is_owned(a);
42484         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42485         a_conv.is_owned = false;
42486         LDKChannelTypeFeatures b_conv;
42487         b_conv.inner = untag_ptr(b);
42488         b_conv.is_owned = ptr_is_owned(b);
42489         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42490         b_conv.is_owned = false;
42491         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
42492         return ret_conv;
42493 }
42494
42495 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
42496         LDKInitFeatures ret_var = InitFeatures_clone(arg);
42497         int64_t ret_ref = 0;
42498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42500         return ret_ref;
42501 }
42502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42503         LDKInitFeatures arg_conv;
42504         arg_conv.inner = untag_ptr(arg);
42505         arg_conv.is_owned = ptr_is_owned(arg);
42506         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42507         arg_conv.is_owned = false;
42508         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
42509         return ret_conv;
42510 }
42511
42512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42513         LDKInitFeatures orig_conv;
42514         orig_conv.inner = untag_ptr(orig);
42515         orig_conv.is_owned = ptr_is_owned(orig);
42516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42517         orig_conv.is_owned = false;
42518         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
42519         int64_t ret_ref = 0;
42520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42522         return ret_ref;
42523 }
42524
42525 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
42526         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
42527         int64_t ret_ref = 0;
42528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42530         return ret_ref;
42531 }
42532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42533         LDKNodeFeatures arg_conv;
42534         arg_conv.inner = untag_ptr(arg);
42535         arg_conv.is_owned = ptr_is_owned(arg);
42536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42537         arg_conv.is_owned = false;
42538         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
42539         return ret_conv;
42540 }
42541
42542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42543         LDKNodeFeatures orig_conv;
42544         orig_conv.inner = untag_ptr(orig);
42545         orig_conv.is_owned = ptr_is_owned(orig);
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42547         orig_conv.is_owned = false;
42548         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
42549         int64_t ret_ref = 0;
42550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42552         return ret_ref;
42553 }
42554
42555 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
42556         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
42557         int64_t ret_ref = 0;
42558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42560         return ret_ref;
42561 }
42562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42563         LDKChannelFeatures arg_conv;
42564         arg_conv.inner = untag_ptr(arg);
42565         arg_conv.is_owned = ptr_is_owned(arg);
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42567         arg_conv.is_owned = false;
42568         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
42569         return ret_conv;
42570 }
42571
42572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42573         LDKChannelFeatures orig_conv;
42574         orig_conv.inner = untag_ptr(orig);
42575         orig_conv.is_owned = ptr_is_owned(orig);
42576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42577         orig_conv.is_owned = false;
42578         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
42579         int64_t ret_ref = 0;
42580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42582         return ret_ref;
42583 }
42584
42585 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
42586         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
42587         int64_t ret_ref = 0;
42588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42590         return ret_ref;
42591 }
42592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42593         LDKInvoiceFeatures arg_conv;
42594         arg_conv.inner = untag_ptr(arg);
42595         arg_conv.is_owned = ptr_is_owned(arg);
42596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42597         arg_conv.is_owned = false;
42598         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
42599         return ret_conv;
42600 }
42601
42602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42603         LDKInvoiceFeatures orig_conv;
42604         orig_conv.inner = untag_ptr(orig);
42605         orig_conv.is_owned = ptr_is_owned(orig);
42606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42607         orig_conv.is_owned = false;
42608         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
42609         int64_t ret_ref = 0;
42610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42612         return ret_ref;
42613 }
42614
42615 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
42616         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
42617         int64_t ret_ref = 0;
42618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42620         return ret_ref;
42621 }
42622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42623         LDKChannelTypeFeatures arg_conv;
42624         arg_conv.inner = untag_ptr(arg);
42625         arg_conv.is_owned = ptr_is_owned(arg);
42626         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42627         arg_conv.is_owned = false;
42628         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
42629         return ret_conv;
42630 }
42631
42632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42633         LDKChannelTypeFeatures orig_conv;
42634         orig_conv.inner = untag_ptr(orig);
42635         orig_conv.is_owned = ptr_is_owned(orig);
42636         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42637         orig_conv.is_owned = false;
42638         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
42639         int64_t ret_ref = 0;
42640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42642         return ret_ref;
42643 }
42644
42645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42646         LDKInitFeatures this_obj_conv;
42647         this_obj_conv.inner = untag_ptr(this_obj);
42648         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42650         InitFeatures_free(this_obj_conv);
42651 }
42652
42653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42654         LDKNodeFeatures this_obj_conv;
42655         this_obj_conv.inner = untag_ptr(this_obj);
42656         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42658         NodeFeatures_free(this_obj_conv);
42659 }
42660
42661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42662         LDKChannelFeatures this_obj_conv;
42663         this_obj_conv.inner = untag_ptr(this_obj);
42664         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42666         ChannelFeatures_free(this_obj_conv);
42667 }
42668
42669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42670         LDKInvoiceFeatures this_obj_conv;
42671         this_obj_conv.inner = untag_ptr(this_obj);
42672         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42674         InvoiceFeatures_free(this_obj_conv);
42675 }
42676
42677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42678         LDKChannelTypeFeatures this_obj_conv;
42679         this_obj_conv.inner = untag_ptr(this_obj);
42680         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42682         ChannelTypeFeatures_free(this_obj_conv);
42683 }
42684
42685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
42686         LDKInitFeatures ret_var = InitFeatures_empty();
42687         int64_t ret_ref = 0;
42688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42690         return ret_ref;
42691 }
42692
42693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42694         LDKInitFeatures this_arg_conv;
42695         this_arg_conv.inner = untag_ptr(this_arg);
42696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42698         this_arg_conv.is_owned = false;
42699         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
42700         return ret_conv;
42701 }
42702
42703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
42704         LDKNodeFeatures ret_var = NodeFeatures_empty();
42705         int64_t ret_ref = 0;
42706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42708         return ret_ref;
42709 }
42710
42711 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42712         LDKNodeFeatures this_arg_conv;
42713         this_arg_conv.inner = untag_ptr(this_arg);
42714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42716         this_arg_conv.is_owned = false;
42717         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
42718         return ret_conv;
42719 }
42720
42721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
42722         LDKChannelFeatures ret_var = ChannelFeatures_empty();
42723         int64_t ret_ref = 0;
42724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42726         return ret_ref;
42727 }
42728
42729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42730         LDKChannelFeatures this_arg_conv;
42731         this_arg_conv.inner = untag_ptr(this_arg);
42732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42734         this_arg_conv.is_owned = false;
42735         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
42736         return ret_conv;
42737 }
42738
42739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
42740         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
42741         int64_t ret_ref = 0;
42742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42744         return ret_ref;
42745 }
42746
42747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42748         LDKInvoiceFeatures this_arg_conv;
42749         this_arg_conv.inner = untag_ptr(this_arg);
42750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42752         this_arg_conv.is_owned = false;
42753         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
42754         return ret_conv;
42755 }
42756
42757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
42758         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
42759         int64_t ret_ref = 0;
42760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42762         return ret_ref;
42763 }
42764
42765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42766         LDKChannelTypeFeatures this_arg_conv;
42767         this_arg_conv.inner = untag_ptr(this_arg);
42768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42770         this_arg_conv.is_owned = false;
42771         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
42772         return ret_conv;
42773 }
42774
42775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42776         LDKInitFeatures obj_conv;
42777         obj_conv.inner = untag_ptr(obj);
42778         obj_conv.is_owned = ptr_is_owned(obj);
42779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42780         obj_conv.is_owned = false;
42781         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
42782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42784         CVec_u8Z_free(ret_var);
42785         return ret_arr;
42786 }
42787
42788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42789         LDKu8slice ser_ref;
42790         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42791         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42792         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
42793         *ret_conv = InitFeatures_read(ser_ref);
42794         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42795         return tag_ptr(ret_conv, true);
42796 }
42797
42798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42799         LDKChannelFeatures obj_conv;
42800         obj_conv.inner = untag_ptr(obj);
42801         obj_conv.is_owned = ptr_is_owned(obj);
42802         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42803         obj_conv.is_owned = false;
42804         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
42805         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42806         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42807         CVec_u8Z_free(ret_var);
42808         return ret_arr;
42809 }
42810
42811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42812         LDKu8slice ser_ref;
42813         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42814         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42815         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
42816         *ret_conv = ChannelFeatures_read(ser_ref);
42817         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42818         return tag_ptr(ret_conv, true);
42819 }
42820
42821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42822         LDKNodeFeatures obj_conv;
42823         obj_conv.inner = untag_ptr(obj);
42824         obj_conv.is_owned = ptr_is_owned(obj);
42825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42826         obj_conv.is_owned = false;
42827         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
42828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42830         CVec_u8Z_free(ret_var);
42831         return ret_arr;
42832 }
42833
42834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42835         LDKu8slice ser_ref;
42836         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42837         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42838         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
42839         *ret_conv = NodeFeatures_read(ser_ref);
42840         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42841         return tag_ptr(ret_conv, true);
42842 }
42843
42844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42845         LDKInvoiceFeatures obj_conv;
42846         obj_conv.inner = untag_ptr(obj);
42847         obj_conv.is_owned = ptr_is_owned(obj);
42848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42849         obj_conv.is_owned = false;
42850         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
42851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42853         CVec_u8Z_free(ret_var);
42854         return ret_arr;
42855 }
42856
42857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42858         LDKu8slice ser_ref;
42859         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42860         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42861         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
42862         *ret_conv = InvoiceFeatures_read(ser_ref);
42863         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42864         return tag_ptr(ret_conv, true);
42865 }
42866
42867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42868         LDKChannelTypeFeatures obj_conv;
42869         obj_conv.inner = untag_ptr(obj);
42870         obj_conv.is_owned = ptr_is_owned(obj);
42871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42872         obj_conv.is_owned = false;
42873         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
42874         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42875         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42876         CVec_u8Z_free(ret_var);
42877         return ret_arr;
42878 }
42879
42880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42881         LDKu8slice ser_ref;
42882         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42883         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42884         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
42885         *ret_conv = ChannelTypeFeatures_read(ser_ref);
42886         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42887         return tag_ptr(ret_conv, true);
42888 }
42889
42890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42891         LDKInitFeatures this_arg_conv;
42892         this_arg_conv.inner = untag_ptr(this_arg);
42893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42895         this_arg_conv.is_owned = false;
42896         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
42897 }
42898
42899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42900         LDKInitFeatures this_arg_conv;
42901         this_arg_conv.inner = untag_ptr(this_arg);
42902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42904         this_arg_conv.is_owned = false;
42905         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
42906 }
42907
42908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42909         LDKInitFeatures this_arg_conv;
42910         this_arg_conv.inner = untag_ptr(this_arg);
42911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42913         this_arg_conv.is_owned = false;
42914         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
42915         return ret_conv;
42916 }
42917
42918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42919         LDKNodeFeatures this_arg_conv;
42920         this_arg_conv.inner = untag_ptr(this_arg);
42921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42923         this_arg_conv.is_owned = false;
42924         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
42925 }
42926
42927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42928         LDKNodeFeatures this_arg_conv;
42929         this_arg_conv.inner = untag_ptr(this_arg);
42930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42932         this_arg_conv.is_owned = false;
42933         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
42934 }
42935
42936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42937         LDKNodeFeatures this_arg_conv;
42938         this_arg_conv.inner = untag_ptr(this_arg);
42939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42941         this_arg_conv.is_owned = false;
42942         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
42943         return ret_conv;
42944 }
42945
42946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42947         LDKInitFeatures this_arg_conv;
42948         this_arg_conv.inner = untag_ptr(this_arg);
42949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42951         this_arg_conv.is_owned = false;
42952         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
42953         return ret_conv;
42954 }
42955
42956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42957         LDKNodeFeatures this_arg_conv;
42958         this_arg_conv.inner = untag_ptr(this_arg);
42959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42961         this_arg_conv.is_owned = false;
42962         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
42963         return ret_conv;
42964 }
42965
42966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42967         LDKInitFeatures this_arg_conv;
42968         this_arg_conv.inner = untag_ptr(this_arg);
42969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42971         this_arg_conv.is_owned = false;
42972         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
42973 }
42974
42975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42976         LDKInitFeatures this_arg_conv;
42977         this_arg_conv.inner = untag_ptr(this_arg);
42978         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42980         this_arg_conv.is_owned = false;
42981         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
42982 }
42983
42984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
42985         LDKInitFeatures this_arg_conv;
42986         this_arg_conv.inner = untag_ptr(this_arg);
42987         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42989         this_arg_conv.is_owned = false;
42990         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
42991         return ret_conv;
42992 }
42993
42994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42995         LDKInitFeatures this_arg_conv;
42996         this_arg_conv.inner = untag_ptr(this_arg);
42997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42999         this_arg_conv.is_owned = false;
43000         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
43001 }
43002
43003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43004         LDKInitFeatures this_arg_conv;
43005         this_arg_conv.inner = untag_ptr(this_arg);
43006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43008         this_arg_conv.is_owned = false;
43009         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
43010 }
43011
43012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43013         LDKInitFeatures this_arg_conv;
43014         this_arg_conv.inner = untag_ptr(this_arg);
43015         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43017         this_arg_conv.is_owned = false;
43018         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
43019         return ret_conv;
43020 }
43021
43022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43023         LDKNodeFeatures this_arg_conv;
43024         this_arg_conv.inner = untag_ptr(this_arg);
43025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43027         this_arg_conv.is_owned = false;
43028         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
43029 }
43030
43031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43032         LDKNodeFeatures this_arg_conv;
43033         this_arg_conv.inner = untag_ptr(this_arg);
43034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43036         this_arg_conv.is_owned = false;
43037         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
43038 }
43039
43040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43041         LDKNodeFeatures this_arg_conv;
43042         this_arg_conv.inner = untag_ptr(this_arg);
43043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43045         this_arg_conv.is_owned = false;
43046         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
43047         return ret_conv;
43048 }
43049
43050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43051         LDKInitFeatures this_arg_conv;
43052         this_arg_conv.inner = untag_ptr(this_arg);
43053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43055         this_arg_conv.is_owned = false;
43056         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
43057         return ret_conv;
43058 }
43059
43060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43061         LDKNodeFeatures this_arg_conv;
43062         this_arg_conv.inner = untag_ptr(this_arg);
43063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43065         this_arg_conv.is_owned = false;
43066         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
43067         return ret_conv;
43068 }
43069
43070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43071         LDKInitFeatures this_arg_conv;
43072         this_arg_conv.inner = untag_ptr(this_arg);
43073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43075         this_arg_conv.is_owned = false;
43076         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
43077 }
43078
43079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43080         LDKInitFeatures this_arg_conv;
43081         this_arg_conv.inner = untag_ptr(this_arg);
43082         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43084         this_arg_conv.is_owned = false;
43085         InitFeatures_set_gossip_queries_required(&this_arg_conv);
43086 }
43087
43088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43089         LDKInitFeatures this_arg_conv;
43090         this_arg_conv.inner = untag_ptr(this_arg);
43091         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43093         this_arg_conv.is_owned = false;
43094         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
43095         return ret_conv;
43096 }
43097
43098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43099         LDKNodeFeatures this_arg_conv;
43100         this_arg_conv.inner = untag_ptr(this_arg);
43101         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43103         this_arg_conv.is_owned = false;
43104         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
43105 }
43106
43107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43108         LDKNodeFeatures this_arg_conv;
43109         this_arg_conv.inner = untag_ptr(this_arg);
43110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43112         this_arg_conv.is_owned = false;
43113         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
43114 }
43115
43116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43117         LDKNodeFeatures this_arg_conv;
43118         this_arg_conv.inner = untag_ptr(this_arg);
43119         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43121         this_arg_conv.is_owned = false;
43122         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
43123         return ret_conv;
43124 }
43125
43126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43127         LDKInitFeatures this_arg_conv;
43128         this_arg_conv.inner = untag_ptr(this_arg);
43129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43131         this_arg_conv.is_owned = false;
43132         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
43133         return ret_conv;
43134 }
43135
43136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43137         LDKNodeFeatures this_arg_conv;
43138         this_arg_conv.inner = untag_ptr(this_arg);
43139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43141         this_arg_conv.is_owned = false;
43142         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
43143         return ret_conv;
43144 }
43145
43146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43147         LDKInitFeatures this_arg_conv;
43148         this_arg_conv.inner = untag_ptr(this_arg);
43149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43151         this_arg_conv.is_owned = false;
43152         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
43153 }
43154
43155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43156         LDKInitFeatures this_arg_conv;
43157         this_arg_conv.inner = untag_ptr(this_arg);
43158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43160         this_arg_conv.is_owned = false;
43161         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
43162 }
43163
43164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43165         LDKInitFeatures this_arg_conv;
43166         this_arg_conv.inner = untag_ptr(this_arg);
43167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43169         this_arg_conv.is_owned = false;
43170         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
43171         return ret_conv;
43172 }
43173
43174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43175         LDKNodeFeatures this_arg_conv;
43176         this_arg_conv.inner = untag_ptr(this_arg);
43177         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43179         this_arg_conv.is_owned = false;
43180         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
43181 }
43182
43183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43184         LDKNodeFeatures this_arg_conv;
43185         this_arg_conv.inner = untag_ptr(this_arg);
43186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43188         this_arg_conv.is_owned = false;
43189         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
43190 }
43191
43192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43193         LDKNodeFeatures this_arg_conv;
43194         this_arg_conv.inner = untag_ptr(this_arg);
43195         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43197         this_arg_conv.is_owned = false;
43198         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
43199         return ret_conv;
43200 }
43201
43202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43203         LDKInvoiceFeatures this_arg_conv;
43204         this_arg_conv.inner = untag_ptr(this_arg);
43205         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43207         this_arg_conv.is_owned = false;
43208         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
43209 }
43210
43211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43212         LDKInvoiceFeatures this_arg_conv;
43213         this_arg_conv.inner = untag_ptr(this_arg);
43214         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43216         this_arg_conv.is_owned = false;
43217         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
43218 }
43219
43220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43221         LDKInvoiceFeatures this_arg_conv;
43222         this_arg_conv.inner = untag_ptr(this_arg);
43223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43225         this_arg_conv.is_owned = false;
43226         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
43227         return ret_conv;
43228 }
43229
43230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43231         LDKInitFeatures this_arg_conv;
43232         this_arg_conv.inner = untag_ptr(this_arg);
43233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43235         this_arg_conv.is_owned = false;
43236         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
43237         return ret_conv;
43238 }
43239
43240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43241         LDKNodeFeatures this_arg_conv;
43242         this_arg_conv.inner = untag_ptr(this_arg);
43243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43245         this_arg_conv.is_owned = false;
43246         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
43247         return ret_conv;
43248 }
43249
43250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43251         LDKInvoiceFeatures this_arg_conv;
43252         this_arg_conv.inner = untag_ptr(this_arg);
43253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43255         this_arg_conv.is_owned = false;
43256         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
43257         return ret_conv;
43258 }
43259
43260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43261         LDKInitFeatures this_arg_conv;
43262         this_arg_conv.inner = untag_ptr(this_arg);
43263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43265         this_arg_conv.is_owned = false;
43266         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
43267 }
43268
43269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43270         LDKInitFeatures this_arg_conv;
43271         this_arg_conv.inner = untag_ptr(this_arg);
43272         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43274         this_arg_conv.is_owned = false;
43275         InitFeatures_set_static_remote_key_required(&this_arg_conv);
43276 }
43277
43278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43279         LDKInitFeatures this_arg_conv;
43280         this_arg_conv.inner = untag_ptr(this_arg);
43281         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43283         this_arg_conv.is_owned = false;
43284         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
43285         return ret_conv;
43286 }
43287
43288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43289         LDKNodeFeatures this_arg_conv;
43290         this_arg_conv.inner = untag_ptr(this_arg);
43291         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43293         this_arg_conv.is_owned = false;
43294         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
43295 }
43296
43297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43298         LDKNodeFeatures this_arg_conv;
43299         this_arg_conv.inner = untag_ptr(this_arg);
43300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43302         this_arg_conv.is_owned = false;
43303         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
43304 }
43305
43306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43307         LDKNodeFeatures this_arg_conv;
43308         this_arg_conv.inner = untag_ptr(this_arg);
43309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43311         this_arg_conv.is_owned = false;
43312         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
43313         return ret_conv;
43314 }
43315
43316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43317         LDKChannelTypeFeatures this_arg_conv;
43318         this_arg_conv.inner = untag_ptr(this_arg);
43319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43321         this_arg_conv.is_owned = false;
43322         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
43323 }
43324
43325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43326         LDKChannelTypeFeatures this_arg_conv;
43327         this_arg_conv.inner = untag_ptr(this_arg);
43328         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43330         this_arg_conv.is_owned = false;
43331         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
43332 }
43333
43334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43335         LDKChannelTypeFeatures this_arg_conv;
43336         this_arg_conv.inner = untag_ptr(this_arg);
43337         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43339         this_arg_conv.is_owned = false;
43340         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
43341         return ret_conv;
43342 }
43343
43344 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43345         LDKInitFeatures this_arg_conv;
43346         this_arg_conv.inner = untag_ptr(this_arg);
43347         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43349         this_arg_conv.is_owned = false;
43350         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
43351         return ret_conv;
43352 }
43353
43354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43355         LDKNodeFeatures this_arg_conv;
43356         this_arg_conv.inner = untag_ptr(this_arg);
43357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43359         this_arg_conv.is_owned = false;
43360         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
43361         return ret_conv;
43362 }
43363
43364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43365         LDKChannelTypeFeatures this_arg_conv;
43366         this_arg_conv.inner = untag_ptr(this_arg);
43367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43369         this_arg_conv.is_owned = false;
43370         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
43371         return ret_conv;
43372 }
43373
43374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43375         LDKInitFeatures this_arg_conv;
43376         this_arg_conv.inner = untag_ptr(this_arg);
43377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43379         this_arg_conv.is_owned = false;
43380         InitFeatures_set_payment_secret_optional(&this_arg_conv);
43381 }
43382
43383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43384         LDKInitFeatures this_arg_conv;
43385         this_arg_conv.inner = untag_ptr(this_arg);
43386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43388         this_arg_conv.is_owned = false;
43389         InitFeatures_set_payment_secret_required(&this_arg_conv);
43390 }
43391
43392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43393         LDKInitFeatures this_arg_conv;
43394         this_arg_conv.inner = untag_ptr(this_arg);
43395         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43397         this_arg_conv.is_owned = false;
43398         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
43399         return ret_conv;
43400 }
43401
43402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43403         LDKNodeFeatures this_arg_conv;
43404         this_arg_conv.inner = untag_ptr(this_arg);
43405         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43407         this_arg_conv.is_owned = false;
43408         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
43409 }
43410
43411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43412         LDKNodeFeatures this_arg_conv;
43413         this_arg_conv.inner = untag_ptr(this_arg);
43414         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43416         this_arg_conv.is_owned = false;
43417         NodeFeatures_set_payment_secret_required(&this_arg_conv);
43418 }
43419
43420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43421         LDKNodeFeatures this_arg_conv;
43422         this_arg_conv.inner = untag_ptr(this_arg);
43423         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43425         this_arg_conv.is_owned = false;
43426         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
43427         return ret_conv;
43428 }
43429
43430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43431         LDKInvoiceFeatures this_arg_conv;
43432         this_arg_conv.inner = untag_ptr(this_arg);
43433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43435         this_arg_conv.is_owned = false;
43436         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
43437 }
43438
43439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43440         LDKInvoiceFeatures this_arg_conv;
43441         this_arg_conv.inner = untag_ptr(this_arg);
43442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43444         this_arg_conv.is_owned = false;
43445         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
43446 }
43447
43448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43449         LDKInvoiceFeatures this_arg_conv;
43450         this_arg_conv.inner = untag_ptr(this_arg);
43451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43453         this_arg_conv.is_owned = false;
43454         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
43455         return ret_conv;
43456 }
43457
43458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43459         LDKInitFeatures this_arg_conv;
43460         this_arg_conv.inner = untag_ptr(this_arg);
43461         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43463         this_arg_conv.is_owned = false;
43464         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
43465         return ret_conv;
43466 }
43467
43468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43469         LDKNodeFeatures this_arg_conv;
43470         this_arg_conv.inner = untag_ptr(this_arg);
43471         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43473         this_arg_conv.is_owned = false;
43474         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
43475         return ret_conv;
43476 }
43477
43478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43479         LDKInvoiceFeatures this_arg_conv;
43480         this_arg_conv.inner = untag_ptr(this_arg);
43481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43483         this_arg_conv.is_owned = false;
43484         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
43485         return ret_conv;
43486 }
43487
43488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43489         LDKInitFeatures this_arg_conv;
43490         this_arg_conv.inner = untag_ptr(this_arg);
43491         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43493         this_arg_conv.is_owned = false;
43494         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
43495 }
43496
43497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43498         LDKInitFeatures this_arg_conv;
43499         this_arg_conv.inner = untag_ptr(this_arg);
43500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43502         this_arg_conv.is_owned = false;
43503         InitFeatures_set_basic_mpp_required(&this_arg_conv);
43504 }
43505
43506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43507         LDKInitFeatures this_arg_conv;
43508         this_arg_conv.inner = untag_ptr(this_arg);
43509         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43511         this_arg_conv.is_owned = false;
43512         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
43513         return ret_conv;
43514 }
43515
43516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43517         LDKNodeFeatures this_arg_conv;
43518         this_arg_conv.inner = untag_ptr(this_arg);
43519         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43521         this_arg_conv.is_owned = false;
43522         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
43523 }
43524
43525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43526         LDKNodeFeatures this_arg_conv;
43527         this_arg_conv.inner = untag_ptr(this_arg);
43528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43530         this_arg_conv.is_owned = false;
43531         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
43532 }
43533
43534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43535         LDKNodeFeatures this_arg_conv;
43536         this_arg_conv.inner = untag_ptr(this_arg);
43537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43539         this_arg_conv.is_owned = false;
43540         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
43541         return ret_conv;
43542 }
43543
43544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43545         LDKInvoiceFeatures this_arg_conv;
43546         this_arg_conv.inner = untag_ptr(this_arg);
43547         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43549         this_arg_conv.is_owned = false;
43550         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
43551 }
43552
43553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43554         LDKInvoiceFeatures this_arg_conv;
43555         this_arg_conv.inner = untag_ptr(this_arg);
43556         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43558         this_arg_conv.is_owned = false;
43559         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
43560 }
43561
43562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43563         LDKInvoiceFeatures this_arg_conv;
43564         this_arg_conv.inner = untag_ptr(this_arg);
43565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43567         this_arg_conv.is_owned = false;
43568         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
43569         return ret_conv;
43570 }
43571
43572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43573         LDKInitFeatures this_arg_conv;
43574         this_arg_conv.inner = untag_ptr(this_arg);
43575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43577         this_arg_conv.is_owned = false;
43578         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
43579         return ret_conv;
43580 }
43581
43582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43583         LDKNodeFeatures this_arg_conv;
43584         this_arg_conv.inner = untag_ptr(this_arg);
43585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43587         this_arg_conv.is_owned = false;
43588         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
43589         return ret_conv;
43590 }
43591
43592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43593         LDKInvoiceFeatures this_arg_conv;
43594         this_arg_conv.inner = untag_ptr(this_arg);
43595         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43597         this_arg_conv.is_owned = false;
43598         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
43599         return ret_conv;
43600 }
43601
43602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43603         LDKInitFeatures this_arg_conv;
43604         this_arg_conv.inner = untag_ptr(this_arg);
43605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43607         this_arg_conv.is_owned = false;
43608         InitFeatures_set_wumbo_optional(&this_arg_conv);
43609 }
43610
43611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43612         LDKInitFeatures this_arg_conv;
43613         this_arg_conv.inner = untag_ptr(this_arg);
43614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43616         this_arg_conv.is_owned = false;
43617         InitFeatures_set_wumbo_required(&this_arg_conv);
43618 }
43619
43620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43621         LDKInitFeatures this_arg_conv;
43622         this_arg_conv.inner = untag_ptr(this_arg);
43623         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43625         this_arg_conv.is_owned = false;
43626         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
43627         return ret_conv;
43628 }
43629
43630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43631         LDKNodeFeatures this_arg_conv;
43632         this_arg_conv.inner = untag_ptr(this_arg);
43633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43635         this_arg_conv.is_owned = false;
43636         NodeFeatures_set_wumbo_optional(&this_arg_conv);
43637 }
43638
43639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43640         LDKNodeFeatures this_arg_conv;
43641         this_arg_conv.inner = untag_ptr(this_arg);
43642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43644         this_arg_conv.is_owned = false;
43645         NodeFeatures_set_wumbo_required(&this_arg_conv);
43646 }
43647
43648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43649         LDKNodeFeatures this_arg_conv;
43650         this_arg_conv.inner = untag_ptr(this_arg);
43651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43653         this_arg_conv.is_owned = false;
43654         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
43655         return ret_conv;
43656 }
43657
43658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43659         LDKInitFeatures this_arg_conv;
43660         this_arg_conv.inner = untag_ptr(this_arg);
43661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43663         this_arg_conv.is_owned = false;
43664         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
43665         return ret_conv;
43666 }
43667
43668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43669         LDKNodeFeatures this_arg_conv;
43670         this_arg_conv.inner = untag_ptr(this_arg);
43671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43673         this_arg_conv.is_owned = false;
43674         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
43675         return ret_conv;
43676 }
43677
43678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43679         LDKInitFeatures this_arg_conv;
43680         this_arg_conv.inner = untag_ptr(this_arg);
43681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43683         this_arg_conv.is_owned = false;
43684         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
43685 }
43686
43687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43688         LDKInitFeatures this_arg_conv;
43689         this_arg_conv.inner = untag_ptr(this_arg);
43690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43692         this_arg_conv.is_owned = false;
43693         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
43694 }
43695
43696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43697         LDKInitFeatures this_arg_conv;
43698         this_arg_conv.inner = untag_ptr(this_arg);
43699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43701         this_arg_conv.is_owned = false;
43702         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
43703         return ret_conv;
43704 }
43705
43706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43707         LDKNodeFeatures this_arg_conv;
43708         this_arg_conv.inner = untag_ptr(this_arg);
43709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43711         this_arg_conv.is_owned = false;
43712         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
43713 }
43714
43715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43716         LDKNodeFeatures this_arg_conv;
43717         this_arg_conv.inner = untag_ptr(this_arg);
43718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43720         this_arg_conv.is_owned = false;
43721         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
43722 }
43723
43724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43725         LDKNodeFeatures this_arg_conv;
43726         this_arg_conv.inner = untag_ptr(this_arg);
43727         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43729         this_arg_conv.is_owned = false;
43730         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
43731         return ret_conv;
43732 }
43733
43734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43735         LDKInitFeatures this_arg_conv;
43736         this_arg_conv.inner = untag_ptr(this_arg);
43737         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43739         this_arg_conv.is_owned = false;
43740         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
43741         return ret_conv;
43742 }
43743
43744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43745         LDKNodeFeatures this_arg_conv;
43746         this_arg_conv.inner = untag_ptr(this_arg);
43747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43749         this_arg_conv.is_owned = false;
43750         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
43751         return ret_conv;
43752 }
43753
43754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43755         LDKInitFeatures this_arg_conv;
43756         this_arg_conv.inner = untag_ptr(this_arg);
43757         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43759         this_arg_conv.is_owned = false;
43760         InitFeatures_set_onion_messages_optional(&this_arg_conv);
43761 }
43762
43763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43764         LDKInitFeatures this_arg_conv;
43765         this_arg_conv.inner = untag_ptr(this_arg);
43766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43768         this_arg_conv.is_owned = false;
43769         InitFeatures_set_onion_messages_required(&this_arg_conv);
43770 }
43771
43772 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43773         LDKInitFeatures this_arg_conv;
43774         this_arg_conv.inner = untag_ptr(this_arg);
43775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43777         this_arg_conv.is_owned = false;
43778         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
43779         return ret_conv;
43780 }
43781
43782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43783         LDKNodeFeatures this_arg_conv;
43784         this_arg_conv.inner = untag_ptr(this_arg);
43785         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43787         this_arg_conv.is_owned = false;
43788         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
43789 }
43790
43791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43792         LDKNodeFeatures this_arg_conv;
43793         this_arg_conv.inner = untag_ptr(this_arg);
43794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43796         this_arg_conv.is_owned = false;
43797         NodeFeatures_set_onion_messages_required(&this_arg_conv);
43798 }
43799
43800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43801         LDKNodeFeatures this_arg_conv;
43802         this_arg_conv.inner = untag_ptr(this_arg);
43803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43805         this_arg_conv.is_owned = false;
43806         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
43807         return ret_conv;
43808 }
43809
43810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43811         LDKInitFeatures this_arg_conv;
43812         this_arg_conv.inner = untag_ptr(this_arg);
43813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43815         this_arg_conv.is_owned = false;
43816         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
43817         return ret_conv;
43818 }
43819
43820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43821         LDKNodeFeatures this_arg_conv;
43822         this_arg_conv.inner = untag_ptr(this_arg);
43823         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43825         this_arg_conv.is_owned = false;
43826         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
43827         return ret_conv;
43828 }
43829
43830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43831         LDKInitFeatures this_arg_conv;
43832         this_arg_conv.inner = untag_ptr(this_arg);
43833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43835         this_arg_conv.is_owned = false;
43836         InitFeatures_set_channel_type_optional(&this_arg_conv);
43837 }
43838
43839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43840         LDKInitFeatures this_arg_conv;
43841         this_arg_conv.inner = untag_ptr(this_arg);
43842         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43844         this_arg_conv.is_owned = false;
43845         InitFeatures_set_channel_type_required(&this_arg_conv);
43846 }
43847
43848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43849         LDKInitFeatures this_arg_conv;
43850         this_arg_conv.inner = untag_ptr(this_arg);
43851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43853         this_arg_conv.is_owned = false;
43854         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
43855         return ret_conv;
43856 }
43857
43858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43859         LDKNodeFeatures this_arg_conv;
43860         this_arg_conv.inner = untag_ptr(this_arg);
43861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43863         this_arg_conv.is_owned = false;
43864         NodeFeatures_set_channel_type_optional(&this_arg_conv);
43865 }
43866
43867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43868         LDKNodeFeatures this_arg_conv;
43869         this_arg_conv.inner = untag_ptr(this_arg);
43870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43872         this_arg_conv.is_owned = false;
43873         NodeFeatures_set_channel_type_required(&this_arg_conv);
43874 }
43875
43876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43877         LDKNodeFeatures this_arg_conv;
43878         this_arg_conv.inner = untag_ptr(this_arg);
43879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43881         this_arg_conv.is_owned = false;
43882         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
43883         return ret_conv;
43884 }
43885
43886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43887         LDKInitFeatures this_arg_conv;
43888         this_arg_conv.inner = untag_ptr(this_arg);
43889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43891         this_arg_conv.is_owned = false;
43892         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
43893         return ret_conv;
43894 }
43895
43896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43897         LDKNodeFeatures this_arg_conv;
43898         this_arg_conv.inner = untag_ptr(this_arg);
43899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43901         this_arg_conv.is_owned = false;
43902         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
43903         return ret_conv;
43904 }
43905
43906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43907         LDKInitFeatures this_arg_conv;
43908         this_arg_conv.inner = untag_ptr(this_arg);
43909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43911         this_arg_conv.is_owned = false;
43912         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
43913 }
43914
43915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43916         LDKInitFeatures this_arg_conv;
43917         this_arg_conv.inner = untag_ptr(this_arg);
43918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43920         this_arg_conv.is_owned = false;
43921         InitFeatures_set_scid_privacy_required(&this_arg_conv);
43922 }
43923
43924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43925         LDKInitFeatures this_arg_conv;
43926         this_arg_conv.inner = untag_ptr(this_arg);
43927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43929         this_arg_conv.is_owned = false;
43930         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
43931         return ret_conv;
43932 }
43933
43934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43935         LDKNodeFeatures this_arg_conv;
43936         this_arg_conv.inner = untag_ptr(this_arg);
43937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43939         this_arg_conv.is_owned = false;
43940         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
43941 }
43942
43943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43944         LDKNodeFeatures this_arg_conv;
43945         this_arg_conv.inner = untag_ptr(this_arg);
43946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43948         this_arg_conv.is_owned = false;
43949         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
43950 }
43951
43952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43953         LDKNodeFeatures this_arg_conv;
43954         this_arg_conv.inner = untag_ptr(this_arg);
43955         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43957         this_arg_conv.is_owned = false;
43958         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
43959         return ret_conv;
43960 }
43961
43962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43963         LDKChannelTypeFeatures this_arg_conv;
43964         this_arg_conv.inner = untag_ptr(this_arg);
43965         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43967         this_arg_conv.is_owned = false;
43968         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
43969 }
43970
43971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43972         LDKChannelTypeFeatures this_arg_conv;
43973         this_arg_conv.inner = untag_ptr(this_arg);
43974         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43976         this_arg_conv.is_owned = false;
43977         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
43978 }
43979
43980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43981         LDKChannelTypeFeatures this_arg_conv;
43982         this_arg_conv.inner = untag_ptr(this_arg);
43983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43985         this_arg_conv.is_owned = false;
43986         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
43987         return ret_conv;
43988 }
43989
43990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43991         LDKInitFeatures this_arg_conv;
43992         this_arg_conv.inner = untag_ptr(this_arg);
43993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43995         this_arg_conv.is_owned = false;
43996         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
43997         return ret_conv;
43998 }
43999
44000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
44001         LDKNodeFeatures this_arg_conv;
44002         this_arg_conv.inner = untag_ptr(this_arg);
44003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44005         this_arg_conv.is_owned = false;
44006         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
44007         return ret_conv;
44008 }
44009
44010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
44011         LDKChannelTypeFeatures this_arg_conv;
44012         this_arg_conv.inner = untag_ptr(this_arg);
44013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44015         this_arg_conv.is_owned = false;
44016         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
44017         return ret_conv;
44018 }
44019
44020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44021         LDKInitFeatures this_arg_conv;
44022         this_arg_conv.inner = untag_ptr(this_arg);
44023         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44025         this_arg_conv.is_owned = false;
44026         InitFeatures_set_zero_conf_optional(&this_arg_conv);
44027 }
44028
44029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44030         LDKInitFeatures this_arg_conv;
44031         this_arg_conv.inner = untag_ptr(this_arg);
44032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44034         this_arg_conv.is_owned = false;
44035         InitFeatures_set_zero_conf_required(&this_arg_conv);
44036 }
44037
44038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44039         LDKInitFeatures this_arg_conv;
44040         this_arg_conv.inner = untag_ptr(this_arg);
44041         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44043         this_arg_conv.is_owned = false;
44044         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
44045         return ret_conv;
44046 }
44047
44048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44049         LDKNodeFeatures this_arg_conv;
44050         this_arg_conv.inner = untag_ptr(this_arg);
44051         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44053         this_arg_conv.is_owned = false;
44054         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
44055 }
44056
44057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44058         LDKNodeFeatures this_arg_conv;
44059         this_arg_conv.inner = untag_ptr(this_arg);
44060         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44062         this_arg_conv.is_owned = false;
44063         NodeFeatures_set_zero_conf_required(&this_arg_conv);
44064 }
44065
44066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44067         LDKNodeFeatures this_arg_conv;
44068         this_arg_conv.inner = untag_ptr(this_arg);
44069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44071         this_arg_conv.is_owned = false;
44072         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
44073         return ret_conv;
44074 }
44075
44076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44077         LDKChannelTypeFeatures this_arg_conv;
44078         this_arg_conv.inner = untag_ptr(this_arg);
44079         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44081         this_arg_conv.is_owned = false;
44082         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
44083 }
44084
44085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44086         LDKChannelTypeFeatures this_arg_conv;
44087         this_arg_conv.inner = untag_ptr(this_arg);
44088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44090         this_arg_conv.is_owned = false;
44091         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
44092 }
44093
44094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44095         LDKChannelTypeFeatures this_arg_conv;
44096         this_arg_conv.inner = untag_ptr(this_arg);
44097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44099         this_arg_conv.is_owned = false;
44100         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
44101         return ret_conv;
44102 }
44103
44104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44105         LDKInitFeatures this_arg_conv;
44106         this_arg_conv.inner = untag_ptr(this_arg);
44107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44109         this_arg_conv.is_owned = false;
44110         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
44111         return ret_conv;
44112 }
44113
44114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44115         LDKNodeFeatures this_arg_conv;
44116         this_arg_conv.inner = untag_ptr(this_arg);
44117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44119         this_arg_conv.is_owned = false;
44120         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
44121         return ret_conv;
44122 }
44123
44124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44125         LDKChannelTypeFeatures this_arg_conv;
44126         this_arg_conv.inner = untag_ptr(this_arg);
44127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44129         this_arg_conv.is_owned = false;
44130         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
44131         return ret_conv;
44132 }
44133
44134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44135         LDKNodeFeatures this_arg_conv;
44136         this_arg_conv.inner = untag_ptr(this_arg);
44137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44139         this_arg_conv.is_owned = false;
44140         NodeFeatures_set_keysend_optional(&this_arg_conv);
44141 }
44142
44143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44144         LDKNodeFeatures this_arg_conv;
44145         this_arg_conv.inner = untag_ptr(this_arg);
44146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44148         this_arg_conv.is_owned = false;
44149         NodeFeatures_set_keysend_required(&this_arg_conv);
44150 }
44151
44152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
44153         LDKNodeFeatures this_arg_conv;
44154         this_arg_conv.inner = untag_ptr(this_arg);
44155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44157         this_arg_conv.is_owned = false;
44158         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
44159         return ret_conv;
44160 }
44161
44162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
44163         LDKNodeFeatures this_arg_conv;
44164         this_arg_conv.inner = untag_ptr(this_arg);
44165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44167         this_arg_conv.is_owned = false;
44168         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
44169         return ret_conv;
44170 }
44171
44172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44173         LDKShutdownScript this_obj_conv;
44174         this_obj_conv.inner = untag_ptr(this_obj);
44175         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44177         ShutdownScript_free(this_obj_conv);
44178 }
44179
44180 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
44181         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
44182         int64_t ret_ref = 0;
44183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44185         return ret_ref;
44186 }
44187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44188         LDKShutdownScript arg_conv;
44189         arg_conv.inner = untag_ptr(arg);
44190         arg_conv.is_owned = ptr_is_owned(arg);
44191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44192         arg_conv.is_owned = false;
44193         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
44194         return ret_conv;
44195 }
44196
44197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44198         LDKShutdownScript orig_conv;
44199         orig_conv.inner = untag_ptr(orig);
44200         orig_conv.is_owned = ptr_is_owned(orig);
44201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44202         orig_conv.is_owned = false;
44203         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
44204         int64_t ret_ref = 0;
44205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44207         return ret_ref;
44208 }
44209
44210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44211         LDKShutdownScript a_conv;
44212         a_conv.inner = untag_ptr(a);
44213         a_conv.is_owned = ptr_is_owned(a);
44214         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44215         a_conv.is_owned = false;
44216         LDKShutdownScript b_conv;
44217         b_conv.inner = untag_ptr(b);
44218         b_conv.is_owned = ptr_is_owned(b);
44219         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44220         b_conv.is_owned = false;
44221         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
44222         return ret_conv;
44223 }
44224
44225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44226         LDKInvalidShutdownScript this_obj_conv;
44227         this_obj_conv.inner = untag_ptr(this_obj);
44228         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44230         InvalidShutdownScript_free(this_obj_conv);
44231 }
44232
44233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
44234         LDKInvalidShutdownScript this_ptr_conv;
44235         this_ptr_conv.inner = untag_ptr(this_ptr);
44236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44238         this_ptr_conv.is_owned = false;
44239         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
44240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44242         return ret_arr;
44243 }
44244
44245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44246         LDKInvalidShutdownScript this_ptr_conv;
44247         this_ptr_conv.inner = untag_ptr(this_ptr);
44248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44250         this_ptr_conv.is_owned = false;
44251         LDKCVec_u8Z val_ref;
44252         val_ref.datalen = (*env)->GetArrayLength(env, val);
44253         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
44254         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
44255         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
44256 }
44257
44258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
44259         LDKCVec_u8Z script_arg_ref;
44260         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
44261         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44262         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
44263         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
44264         int64_t ret_ref = 0;
44265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44267         return ret_ref;
44268 }
44269
44270 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
44271         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
44272         int64_t ret_ref = 0;
44273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44275         return ret_ref;
44276 }
44277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44278         LDKInvalidShutdownScript arg_conv;
44279         arg_conv.inner = untag_ptr(arg);
44280         arg_conv.is_owned = ptr_is_owned(arg);
44281         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44282         arg_conv.is_owned = false;
44283         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
44284         return ret_conv;
44285 }
44286
44287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44288         LDKInvalidShutdownScript orig_conv;
44289         orig_conv.inner = untag_ptr(orig);
44290         orig_conv.is_owned = ptr_is_owned(orig);
44291         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44292         orig_conv.is_owned = false;
44293         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
44294         int64_t ret_ref = 0;
44295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44297         return ret_ref;
44298 }
44299
44300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
44301         LDKShutdownScript obj_conv;
44302         obj_conv.inner = untag_ptr(obj);
44303         obj_conv.is_owned = ptr_is_owned(obj);
44304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44305         obj_conv.is_owned = false;
44306         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
44307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44309         CVec_u8Z_free(ret_var);
44310         return ret_arr;
44311 }
44312
44313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44314         LDKu8slice ser_ref;
44315         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44316         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44317         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
44318         *ret_conv = ShutdownScript_read(ser_ref);
44319         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44320         return tag_ptr(ret_conv, true);
44321 }
44322
44323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
44324         unsigned char pubkey_hash_arr[20];
44325         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
44326         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
44327         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
44328         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
44329         int64_t ret_ref = 0;
44330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44332         return ret_ref;
44333 }
44334
44335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
44336         unsigned char script_hash_arr[32];
44337         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
44338         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
44339         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
44340         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
44341         int64_t ret_ref = 0;
44342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44344         return ret_ref;
44345 }
44346
44347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
44348         
44349         LDKu8slice program_ref;
44350         program_ref.datalen = (*env)->GetArrayLength(env, program);
44351         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
44352         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
44353         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
44354         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
44355         return tag_ptr(ret_conv, true);
44356 }
44357
44358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44359         LDKShutdownScript this_arg_conv;
44360         this_arg_conv.inner = untag_ptr(this_arg);
44361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44363         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
44364         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
44365         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44366         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44367         CVec_u8Z_free(ret_var);
44368         return ret_arr;
44369 }
44370
44371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
44372         LDKShutdownScript this_arg_conv;
44373         this_arg_conv.inner = untag_ptr(this_arg);
44374         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44376         this_arg_conv.is_owned = false;
44377         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
44379         return ret_arr;
44380 }
44381
44382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
44383         LDKShutdownScript this_arg_conv;
44384         this_arg_conv.inner = untag_ptr(this_arg);
44385         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44387         this_arg_conv.is_owned = false;
44388         LDKInitFeatures features_conv;
44389         features_conv.inner = untag_ptr(features);
44390         features_conv.is_owned = ptr_is_owned(features);
44391         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44392         features_conv.is_owned = false;
44393         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
44394         return ret_conv;
44395 }
44396
44397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44398         if (!ptr_is_owned(this_ptr)) return;
44399         void* this_ptr_ptr = untag_ptr(this_ptr);
44400         CHECK_ACCESS(this_ptr_ptr);
44401         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
44402         FREE(untag_ptr(this_ptr));
44403         CustomMessageReader_free(this_ptr_conv);
44404 }
44405
44406 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
44407         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
44408         *ret_ret = Type_clone(arg);
44409         return tag_ptr(ret_ret, true);
44410 }
44411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44412         void* arg_ptr = untag_ptr(arg);
44413         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
44414         LDKType* arg_conv = (LDKType*)arg_ptr;
44415         int64_t ret_conv = Type_clone_ptr(arg_conv);
44416         return ret_conv;
44417 }
44418
44419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44420         void* orig_ptr = untag_ptr(orig);
44421         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
44422         LDKType* orig_conv = (LDKType*)orig_ptr;
44423         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
44424         *ret_ret = Type_clone(orig_conv);
44425         return tag_ptr(ret_ret, true);
44426 }
44427
44428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44429         if (!ptr_is_owned(this_ptr)) return;
44430         void* this_ptr_ptr = untag_ptr(this_ptr);
44431         CHECK_ACCESS(this_ptr_ptr);
44432         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
44433         FREE(untag_ptr(this_ptr));
44434         Type_free(this_ptr_conv);
44435 }
44436
44437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44438         LDKNodeId this_obj_conv;
44439         this_obj_conv.inner = untag_ptr(this_obj);
44440         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44442         NodeId_free(this_obj_conv);
44443 }
44444
44445 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
44446         LDKNodeId ret_var = NodeId_clone(arg);
44447         int64_t ret_ref = 0;
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44450         return ret_ref;
44451 }
44452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44453         LDKNodeId arg_conv;
44454         arg_conv.inner = untag_ptr(arg);
44455         arg_conv.is_owned = ptr_is_owned(arg);
44456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44457         arg_conv.is_owned = false;
44458         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
44459         return ret_conv;
44460 }
44461
44462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44463         LDKNodeId orig_conv;
44464         orig_conv.inner = untag_ptr(orig);
44465         orig_conv.is_owned = ptr_is_owned(orig);
44466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44467         orig_conv.is_owned = false;
44468         LDKNodeId ret_var = NodeId_clone(&orig_conv);
44469         int64_t ret_ref = 0;
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44472         return ret_ref;
44473 }
44474
44475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
44476         LDKPublicKey pubkey_ref;
44477         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44478         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44479         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
44480         int64_t ret_ref = 0;
44481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44483         return ret_ref;
44484 }
44485
44486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
44487         LDKNodeId this_arg_conv;
44488         this_arg_conv.inner = untag_ptr(this_arg);
44489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44491         this_arg_conv.is_owned = false;
44492         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
44493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44495         return ret_arr;
44496 }
44497
44498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
44499         LDKNodeId o_conv;
44500         o_conv.inner = untag_ptr(o);
44501         o_conv.is_owned = ptr_is_owned(o);
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44503         o_conv.is_owned = false;
44504         int64_t ret_conv = NodeId_hash(&o_conv);
44505         return ret_conv;
44506 }
44507
44508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
44509         LDKNodeId obj_conv;
44510         obj_conv.inner = untag_ptr(obj);
44511         obj_conv.is_owned = ptr_is_owned(obj);
44512         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44513         obj_conv.is_owned = false;
44514         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
44515         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44516         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44517         CVec_u8Z_free(ret_var);
44518         return ret_arr;
44519 }
44520
44521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44522         LDKu8slice ser_ref;
44523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44525         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
44526         *ret_conv = NodeId_read(ser_ref);
44527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44528         return tag_ptr(ret_conv, true);
44529 }
44530
44531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44532         LDKNetworkGraph this_obj_conv;
44533         this_obj_conv.inner = untag_ptr(this_obj);
44534         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44536         NetworkGraph_free(this_obj_conv);
44537 }
44538
44539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44540         LDKReadOnlyNetworkGraph this_obj_conv;
44541         this_obj_conv.inner = untag_ptr(this_obj);
44542         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44544         ReadOnlyNetworkGraph_free(this_obj_conv);
44545 }
44546
44547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44548         if (!ptr_is_owned(this_ptr)) return;
44549         void* this_ptr_ptr = untag_ptr(this_ptr);
44550         CHECK_ACCESS(this_ptr_ptr);
44551         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
44552         FREE(untag_ptr(this_ptr));
44553         NetworkUpdate_free(this_ptr_conv);
44554 }
44555
44556 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
44557         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44558         *ret_copy = NetworkUpdate_clone(arg);
44559         int64_t ret_ref = tag_ptr(ret_copy, true);
44560         return ret_ref;
44561 }
44562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44563         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
44564         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
44565         return ret_conv;
44566 }
44567
44568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44569         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
44570         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44571         *ret_copy = NetworkUpdate_clone(orig_conv);
44572         int64_t ret_ref = tag_ptr(ret_copy, true);
44573         return ret_ref;
44574 }
44575
44576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
44577         LDKChannelUpdate msg_conv;
44578         msg_conv.inner = untag_ptr(msg);
44579         msg_conv.is_owned = ptr_is_owned(msg);
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44581         msg_conv = ChannelUpdate_clone(&msg_conv);
44582         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44583         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
44584         int64_t ret_ref = tag_ptr(ret_copy, true);
44585         return ret_ref;
44586 }
44587
44588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
44589         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44590         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
44591         int64_t ret_ref = tag_ptr(ret_copy, true);
44592         return ret_ref;
44593 }
44594
44595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
44596         LDKPublicKey node_id_ref;
44597         CHECK((*env)->GetArrayLength(env, node_id) == 33);
44598         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
44599         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44600         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
44601         int64_t ret_ref = tag_ptr(ret_copy, true);
44602         return ret_ref;
44603 }
44604
44605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44606         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
44607         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
44608         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
44609         return ret_conv;
44610 }
44611
44612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
44613         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
44614         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
44615         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44616         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44617         CVec_u8Z_free(ret_var);
44618         return ret_arr;
44619 }
44620
44621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44622         LDKu8slice ser_ref;
44623         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44624         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44625         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
44626         *ret_conv = NetworkUpdate_read(ser_ref);
44627         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44628         return tag_ptr(ret_conv, true);
44629 }
44630
44631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44632         LDKP2PGossipSync this_obj_conv;
44633         this_obj_conv.inner = untag_ptr(this_obj);
44634         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44636         P2PGossipSync_free(this_obj_conv);
44637 }
44638
44639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
44640         LDKNetworkGraph network_graph_conv;
44641         network_graph_conv.inner = untag_ptr(network_graph);
44642         network_graph_conv.is_owned = ptr_is_owned(network_graph);
44643         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44644         network_graph_conv.is_owned = false;
44645         void* chain_access_ptr = untag_ptr(chain_access);
44646         CHECK_ACCESS(chain_access_ptr);
44647         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44648         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44649         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44650                 // Manually implement clone for Java trait instances
44651                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44652                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44653                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44654                 }
44655         }
44656         void* logger_ptr = untag_ptr(logger);
44657         CHECK_ACCESS(logger_ptr);
44658         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44659         if (logger_conv.free == LDKLogger_JCalls_free) {
44660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44661                 LDKLogger_JCalls_cloned(&logger_conv);
44662         }
44663         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
44664         int64_t ret_ref = 0;
44665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44667         return ret_ref;
44668 }
44669
44670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
44671         LDKP2PGossipSync this_arg_conv;
44672         this_arg_conv.inner = untag_ptr(this_arg);
44673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44675         this_arg_conv.is_owned = false;
44676         void* chain_access_ptr = untag_ptr(chain_access);
44677         CHECK_ACCESS(chain_access_ptr);
44678         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44679         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44680         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44681                 // Manually implement clone for Java trait instances
44682                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44683                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44684                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44685                 }
44686         }
44687         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
44688 }
44689
44690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
44691         LDKNetworkGraph this_arg_conv;
44692         this_arg_conv.inner = untag_ptr(this_arg);
44693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44695         this_arg_conv.is_owned = false;
44696         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
44697         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
44698         return tag_ptr(ret_ret, true);
44699 }
44700
44701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
44702         LDKP2PGossipSync this_arg_conv;
44703         this_arg_conv.inner = untag_ptr(this_arg);
44704         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44706         this_arg_conv.is_owned = false;
44707         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
44708         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
44709         return tag_ptr(ret_ret, true);
44710 }
44711
44712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
44713         LDKP2PGossipSync this_arg_conv;
44714         this_arg_conv.inner = untag_ptr(this_arg);
44715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44717         this_arg_conv.is_owned = false;
44718         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
44719         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
44720         return tag_ptr(ret_ret, true);
44721 }
44722
44723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44724         LDKChannelUpdateInfo this_obj_conv;
44725         this_obj_conv.inner = untag_ptr(this_obj);
44726         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44728         ChannelUpdateInfo_free(this_obj_conv);
44729 }
44730
44731 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
44732         LDKChannelUpdateInfo this_ptr_conv;
44733         this_ptr_conv.inner = untag_ptr(this_ptr);
44734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44736         this_ptr_conv.is_owned = false;
44737         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
44738         return ret_conv;
44739 }
44740
44741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44742         LDKChannelUpdateInfo this_ptr_conv;
44743         this_ptr_conv.inner = untag_ptr(this_ptr);
44744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44746         this_ptr_conv.is_owned = false;
44747         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
44748 }
44749
44750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
44751         LDKChannelUpdateInfo this_ptr_conv;
44752         this_ptr_conv.inner = untag_ptr(this_ptr);
44753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44755         this_ptr_conv.is_owned = false;
44756         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
44757         return ret_conv;
44758 }
44759
44760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
44761         LDKChannelUpdateInfo this_ptr_conv;
44762         this_ptr_conv.inner = untag_ptr(this_ptr);
44763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44765         this_ptr_conv.is_owned = false;
44766         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
44767 }
44768
44769 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44770         LDKChannelUpdateInfo this_ptr_conv;
44771         this_ptr_conv.inner = untag_ptr(this_ptr);
44772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44774         this_ptr_conv.is_owned = false;
44775         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
44776         return ret_conv;
44777 }
44778
44779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
44780         LDKChannelUpdateInfo this_ptr_conv;
44781         this_ptr_conv.inner = untag_ptr(this_ptr);
44782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44784         this_ptr_conv.is_owned = false;
44785         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
44786 }
44787
44788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44789         LDKChannelUpdateInfo this_ptr_conv;
44790         this_ptr_conv.inner = untag_ptr(this_ptr);
44791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44793         this_ptr_conv.is_owned = false;
44794         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
44795         return ret_conv;
44796 }
44797
44798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44799         LDKChannelUpdateInfo this_ptr_conv;
44800         this_ptr_conv.inner = untag_ptr(this_ptr);
44801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44803         this_ptr_conv.is_owned = false;
44804         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
44805 }
44806
44807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44808         LDKChannelUpdateInfo this_ptr_conv;
44809         this_ptr_conv.inner = untag_ptr(this_ptr);
44810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44812         this_ptr_conv.is_owned = false;
44813         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
44814         return ret_conv;
44815 }
44816
44817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44818         LDKChannelUpdateInfo this_ptr_conv;
44819         this_ptr_conv.inner = untag_ptr(this_ptr);
44820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44822         this_ptr_conv.is_owned = false;
44823         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
44824 }
44825
44826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44827         LDKChannelUpdateInfo this_ptr_conv;
44828         this_ptr_conv.inner = untag_ptr(this_ptr);
44829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44831         this_ptr_conv.is_owned = false;
44832         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
44833         int64_t ret_ref = 0;
44834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44836         return ret_ref;
44837 }
44838
44839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44840         LDKChannelUpdateInfo this_ptr_conv;
44841         this_ptr_conv.inner = untag_ptr(this_ptr);
44842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44844         this_ptr_conv.is_owned = false;
44845         LDKRoutingFees val_conv;
44846         val_conv.inner = untag_ptr(val);
44847         val_conv.is_owned = ptr_is_owned(val);
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44849         val_conv = RoutingFees_clone(&val_conv);
44850         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
44851 }
44852
44853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
44854         LDKChannelUpdateInfo this_ptr_conv;
44855         this_ptr_conv.inner = untag_ptr(this_ptr);
44856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44858         this_ptr_conv.is_owned = false;
44859         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
44860         int64_t ret_ref = 0;
44861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44863         return ret_ref;
44864 }
44865
44866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44867         LDKChannelUpdateInfo this_ptr_conv;
44868         this_ptr_conv.inner = untag_ptr(this_ptr);
44869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44871         this_ptr_conv.is_owned = false;
44872         LDKChannelUpdate val_conv;
44873         val_conv.inner = untag_ptr(val);
44874         val_conv.is_owned = ptr_is_owned(val);
44875         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44876         val_conv = ChannelUpdate_clone(&val_conv);
44877         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
44878 }
44879
44880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) {
44881         LDKRoutingFees fees_arg_conv;
44882         fees_arg_conv.inner = untag_ptr(fees_arg);
44883         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
44885         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
44886         LDKChannelUpdate last_update_message_arg_conv;
44887         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
44888         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
44889         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
44890         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
44891         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
44892         int64_t ret_ref = 0;
44893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44895         return ret_ref;
44896 }
44897
44898 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
44899         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
44900         int64_t ret_ref = 0;
44901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44902         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44903         return ret_ref;
44904 }
44905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44906         LDKChannelUpdateInfo arg_conv;
44907         arg_conv.inner = untag_ptr(arg);
44908         arg_conv.is_owned = ptr_is_owned(arg);
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44910         arg_conv.is_owned = false;
44911         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
44912         return ret_conv;
44913 }
44914
44915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44916         LDKChannelUpdateInfo orig_conv;
44917         orig_conv.inner = untag_ptr(orig);
44918         orig_conv.is_owned = ptr_is_owned(orig);
44919         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44920         orig_conv.is_owned = false;
44921         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
44922         int64_t ret_ref = 0;
44923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44924         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44925         return ret_ref;
44926 }
44927
44928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44929         LDKChannelUpdateInfo a_conv;
44930         a_conv.inner = untag_ptr(a);
44931         a_conv.is_owned = ptr_is_owned(a);
44932         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44933         a_conv.is_owned = false;
44934         LDKChannelUpdateInfo b_conv;
44935         b_conv.inner = untag_ptr(b);
44936         b_conv.is_owned = ptr_is_owned(b);
44937         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44938         b_conv.is_owned = false;
44939         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
44940         return ret_conv;
44941 }
44942
44943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44944         LDKChannelUpdateInfo obj_conv;
44945         obj_conv.inner = untag_ptr(obj);
44946         obj_conv.is_owned = ptr_is_owned(obj);
44947         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44948         obj_conv.is_owned = false;
44949         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
44950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44952         CVec_u8Z_free(ret_var);
44953         return ret_arr;
44954 }
44955
44956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44957         LDKu8slice ser_ref;
44958         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44959         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44960         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
44961         *ret_conv = ChannelUpdateInfo_read(ser_ref);
44962         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44963         return tag_ptr(ret_conv, true);
44964 }
44965
44966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44967         LDKChannelInfo this_obj_conv;
44968         this_obj_conv.inner = untag_ptr(this_obj);
44969         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44971         ChannelInfo_free(this_obj_conv);
44972 }
44973
44974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44975         LDKChannelInfo this_ptr_conv;
44976         this_ptr_conv.inner = untag_ptr(this_ptr);
44977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44979         this_ptr_conv.is_owned = false;
44980         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
44981         int64_t ret_ref = 0;
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44984         return ret_ref;
44985 }
44986
44987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44988         LDKChannelInfo this_ptr_conv;
44989         this_ptr_conv.inner = untag_ptr(this_ptr);
44990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44992         this_ptr_conv.is_owned = false;
44993         LDKChannelFeatures val_conv;
44994         val_conv.inner = untag_ptr(val);
44995         val_conv.is_owned = ptr_is_owned(val);
44996         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44997         val_conv = ChannelFeatures_clone(&val_conv);
44998         ChannelInfo_set_features(&this_ptr_conv, val_conv);
44999 }
45000
45001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
45002         LDKChannelInfo this_ptr_conv;
45003         this_ptr_conv.inner = untag_ptr(this_ptr);
45004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45006         this_ptr_conv.is_owned = false;
45007         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
45008         int64_t ret_ref = 0;
45009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45011         return ret_ref;
45012 }
45013
45014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45015         LDKChannelInfo this_ptr_conv;
45016         this_ptr_conv.inner = untag_ptr(this_ptr);
45017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45019         this_ptr_conv.is_owned = false;
45020         LDKNodeId val_conv;
45021         val_conv.inner = untag_ptr(val);
45022         val_conv.is_owned = ptr_is_owned(val);
45023         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45024         val_conv = NodeId_clone(&val_conv);
45025         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
45026 }
45027
45028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
45029         LDKChannelInfo this_ptr_conv;
45030         this_ptr_conv.inner = untag_ptr(this_ptr);
45031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45033         this_ptr_conv.is_owned = false;
45034         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
45035         int64_t ret_ref = 0;
45036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45037         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45038         return ret_ref;
45039 }
45040
45041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45042         LDKChannelInfo this_ptr_conv;
45043         this_ptr_conv.inner = untag_ptr(this_ptr);
45044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45046         this_ptr_conv.is_owned = false;
45047         LDKChannelUpdateInfo val_conv;
45048         val_conv.inner = untag_ptr(val);
45049         val_conv.is_owned = ptr_is_owned(val);
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45051         val_conv = ChannelUpdateInfo_clone(&val_conv);
45052         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
45053 }
45054
45055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
45056         LDKChannelInfo this_ptr_conv;
45057         this_ptr_conv.inner = untag_ptr(this_ptr);
45058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45060         this_ptr_conv.is_owned = false;
45061         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
45062         int64_t ret_ref = 0;
45063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45065         return ret_ref;
45066 }
45067
45068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45069         LDKChannelInfo this_ptr_conv;
45070         this_ptr_conv.inner = untag_ptr(this_ptr);
45071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45073         this_ptr_conv.is_owned = false;
45074         LDKNodeId val_conv;
45075         val_conv.inner = untag_ptr(val);
45076         val_conv.is_owned = ptr_is_owned(val);
45077         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45078         val_conv = NodeId_clone(&val_conv);
45079         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
45080 }
45081
45082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
45083         LDKChannelInfo this_ptr_conv;
45084         this_ptr_conv.inner = untag_ptr(this_ptr);
45085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45087         this_ptr_conv.is_owned = false;
45088         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
45089         int64_t ret_ref = 0;
45090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45092         return ret_ref;
45093 }
45094
45095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45096         LDKChannelInfo this_ptr_conv;
45097         this_ptr_conv.inner = untag_ptr(this_ptr);
45098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45100         this_ptr_conv.is_owned = false;
45101         LDKChannelUpdateInfo val_conv;
45102         val_conv.inner = untag_ptr(val);
45103         val_conv.is_owned = ptr_is_owned(val);
45104         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45105         val_conv = ChannelUpdateInfo_clone(&val_conv);
45106         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
45107 }
45108
45109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
45110         LDKChannelInfo this_ptr_conv;
45111         this_ptr_conv.inner = untag_ptr(this_ptr);
45112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45114         this_ptr_conv.is_owned = false;
45115         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45116         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
45117         int64_t ret_ref = tag_ptr(ret_copy, true);
45118         return ret_ref;
45119 }
45120
45121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45122         LDKChannelInfo this_ptr_conv;
45123         this_ptr_conv.inner = untag_ptr(this_ptr);
45124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45126         this_ptr_conv.is_owned = false;
45127         void* val_ptr = untag_ptr(val);
45128         CHECK_ACCESS(val_ptr);
45129         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45130         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
45131         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
45132 }
45133
45134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
45135         LDKChannelInfo this_ptr_conv;
45136         this_ptr_conv.inner = untag_ptr(this_ptr);
45137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45139         this_ptr_conv.is_owned = false;
45140         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
45141         int64_t ret_ref = 0;
45142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45143         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45144         return ret_ref;
45145 }
45146
45147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45148         LDKChannelInfo this_ptr_conv;
45149         this_ptr_conv.inner = untag_ptr(this_ptr);
45150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45152         this_ptr_conv.is_owned = false;
45153         LDKChannelAnnouncement val_conv;
45154         val_conv.inner = untag_ptr(val);
45155         val_conv.is_owned = ptr_is_owned(val);
45156         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45157         val_conv = ChannelAnnouncement_clone(&val_conv);
45158         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
45159 }
45160
45161 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
45162         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
45163         int64_t ret_ref = 0;
45164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45166         return ret_ref;
45167 }
45168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45169         LDKChannelInfo arg_conv;
45170         arg_conv.inner = untag_ptr(arg);
45171         arg_conv.is_owned = ptr_is_owned(arg);
45172         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45173         arg_conv.is_owned = false;
45174         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
45175         return ret_conv;
45176 }
45177
45178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45179         LDKChannelInfo orig_conv;
45180         orig_conv.inner = untag_ptr(orig);
45181         orig_conv.is_owned = ptr_is_owned(orig);
45182         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45183         orig_conv.is_owned = false;
45184         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
45185         int64_t ret_ref = 0;
45186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45188         return ret_ref;
45189 }
45190
45191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45192         LDKChannelInfo a_conv;
45193         a_conv.inner = untag_ptr(a);
45194         a_conv.is_owned = ptr_is_owned(a);
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45196         a_conv.is_owned = false;
45197         LDKChannelInfo b_conv;
45198         b_conv.inner = untag_ptr(b);
45199         b_conv.is_owned = ptr_is_owned(b);
45200         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45201         b_conv.is_owned = false;
45202         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
45203         return ret_conv;
45204 }
45205
45206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
45207         LDKChannelInfo this_arg_conv;
45208         this_arg_conv.inner = untag_ptr(this_arg);
45209         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45211         this_arg_conv.is_owned = false;
45212         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
45213         int64_t ret_ref = 0;
45214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45216         return ret_ref;
45217 }
45218
45219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
45220         LDKChannelInfo obj_conv;
45221         obj_conv.inner = untag_ptr(obj);
45222         obj_conv.is_owned = ptr_is_owned(obj);
45223         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45224         obj_conv.is_owned = false;
45225         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
45226         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45227         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45228         CVec_u8Z_free(ret_var);
45229         return ret_arr;
45230 }
45231
45232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45233         LDKu8slice ser_ref;
45234         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45235         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45236         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
45237         *ret_conv = ChannelInfo_read(ser_ref);
45238         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45239         return tag_ptr(ret_conv, true);
45240 }
45241
45242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45243         LDKDirectedChannelInfo this_obj_conv;
45244         this_obj_conv.inner = untag_ptr(this_obj);
45245         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45247         DirectedChannelInfo_free(this_obj_conv);
45248 }
45249
45250 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
45251         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
45252         int64_t ret_ref = 0;
45253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45255         return ret_ref;
45256 }
45257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45258         LDKDirectedChannelInfo arg_conv;
45259         arg_conv.inner = untag_ptr(arg);
45260         arg_conv.is_owned = ptr_is_owned(arg);
45261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45262         arg_conv.is_owned = false;
45263         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
45264         return ret_conv;
45265 }
45266
45267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45268         LDKDirectedChannelInfo orig_conv;
45269         orig_conv.inner = untag_ptr(orig);
45270         orig_conv.is_owned = ptr_is_owned(orig);
45271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45272         orig_conv.is_owned = false;
45273         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
45274         int64_t ret_ref = 0;
45275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45277         return ret_ref;
45278 }
45279
45280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
45281         LDKDirectedChannelInfo this_arg_conv;
45282         this_arg_conv.inner = untag_ptr(this_arg);
45283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45285         this_arg_conv.is_owned = false;
45286         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
45287         int64_t ret_ref = 0;
45288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45290         return ret_ref;
45291 }
45292
45293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
45294         LDKDirectedChannelInfo this_arg_conv;
45295         this_arg_conv.inner = untag_ptr(this_arg);
45296         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45298         this_arg_conv.is_owned = false;
45299         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
45300         int64_t ret_ref = 0;
45301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45303         return ret_ref;
45304 }
45305
45306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
45307         LDKDirectedChannelInfo this_arg_conv;
45308         this_arg_conv.inner = untag_ptr(this_arg);
45309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45311         this_arg_conv.is_owned = false;
45312         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
45313         return ret_conv;
45314 }
45315
45316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
45317         LDKDirectedChannelInfo this_arg_conv;
45318         this_arg_conv.inner = untag_ptr(this_arg);
45319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45321         this_arg_conv.is_owned = false;
45322         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45323         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
45324         int64_t ret_ref = tag_ptr(ret_copy, true);
45325         return ret_ref;
45326 }
45327
45328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45329         if (!ptr_is_owned(this_ptr)) return;
45330         void* this_ptr_ptr = untag_ptr(this_ptr);
45331         CHECK_ACCESS(this_ptr_ptr);
45332         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
45333         FREE(untag_ptr(this_ptr));
45334         EffectiveCapacity_free(this_ptr_conv);
45335 }
45336
45337 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
45338         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45339         *ret_copy = EffectiveCapacity_clone(arg);
45340         int64_t ret_ref = tag_ptr(ret_copy, true);
45341         return ret_ref;
45342 }
45343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45344         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
45345         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
45346         return ret_conv;
45347 }
45348
45349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45350         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
45351         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45352         *ret_copy = EffectiveCapacity_clone(orig_conv);
45353         int64_t ret_ref = tag_ptr(ret_copy, true);
45354         return ret_ref;
45355 }
45356
45357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
45358         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45359         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
45360         int64_t ret_ref = tag_ptr(ret_copy, true);
45361         return ret_ref;
45362 }
45363
45364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
45365         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45366         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
45367         int64_t ret_ref = tag_ptr(ret_copy, true);
45368         return ret_ref;
45369 }
45370
45371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
45372         void* htlc_maximum_msat_ptr = untag_ptr(htlc_maximum_msat);
45373         CHECK_ACCESS(htlc_maximum_msat_ptr);
45374         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
45375         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat));
45376         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45377         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
45378         int64_t ret_ref = tag_ptr(ret_copy, true);
45379         return ret_ref;
45380 }
45381
45382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
45383         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45384         *ret_copy = EffectiveCapacity_infinite();
45385         int64_t ret_ref = tag_ptr(ret_copy, true);
45386         return ret_ref;
45387 }
45388
45389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
45390         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45391         *ret_copy = EffectiveCapacity_unknown();
45392         int64_t ret_ref = tag_ptr(ret_copy, true);
45393         return ret_ref;
45394 }
45395
45396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
45397         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
45398         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
45399         return ret_conv;
45400 }
45401
45402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45403         LDKRoutingFees this_obj_conv;
45404         this_obj_conv.inner = untag_ptr(this_obj);
45405         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45407         RoutingFees_free(this_obj_conv);
45408 }
45409
45410 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45411         LDKRoutingFees this_ptr_conv;
45412         this_ptr_conv.inner = untag_ptr(this_ptr);
45413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45415         this_ptr_conv.is_owned = false;
45416         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
45417         return ret_conv;
45418 }
45419
45420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45421         LDKRoutingFees this_ptr_conv;
45422         this_ptr_conv.inner = untag_ptr(this_ptr);
45423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45425         this_ptr_conv.is_owned = false;
45426         RoutingFees_set_base_msat(&this_ptr_conv, val);
45427 }
45428
45429 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
45430         LDKRoutingFees this_ptr_conv;
45431         this_ptr_conv.inner = untag_ptr(this_ptr);
45432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45434         this_ptr_conv.is_owned = false;
45435         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
45436         return ret_conv;
45437 }
45438
45439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45440         LDKRoutingFees this_ptr_conv;
45441         this_ptr_conv.inner = untag_ptr(this_ptr);
45442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45444         this_ptr_conv.is_owned = false;
45445         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
45446 }
45447
45448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv *env, jclass clz, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
45449         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
45450         int64_t ret_ref = 0;
45451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45453         return ret_ref;
45454 }
45455
45456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45457         LDKRoutingFees a_conv;
45458         a_conv.inner = untag_ptr(a);
45459         a_conv.is_owned = ptr_is_owned(a);
45460         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45461         a_conv.is_owned = false;
45462         LDKRoutingFees b_conv;
45463         b_conv.inner = untag_ptr(b);
45464         b_conv.is_owned = ptr_is_owned(b);
45465         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45466         b_conv.is_owned = false;
45467         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
45468         return ret_conv;
45469 }
45470
45471 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
45472         LDKRoutingFees ret_var = RoutingFees_clone(arg);
45473         int64_t ret_ref = 0;
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45476         return ret_ref;
45477 }
45478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45479         LDKRoutingFees arg_conv;
45480         arg_conv.inner = untag_ptr(arg);
45481         arg_conv.is_owned = ptr_is_owned(arg);
45482         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45483         arg_conv.is_owned = false;
45484         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
45485         return ret_conv;
45486 }
45487
45488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45489         LDKRoutingFees orig_conv;
45490         orig_conv.inner = untag_ptr(orig);
45491         orig_conv.is_owned = ptr_is_owned(orig);
45492         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45493         orig_conv.is_owned = false;
45494         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
45495         int64_t ret_ref = 0;
45496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45498         return ret_ref;
45499 }
45500
45501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
45502         LDKRoutingFees o_conv;
45503         o_conv.inner = untag_ptr(o);
45504         o_conv.is_owned = ptr_is_owned(o);
45505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45506         o_conv.is_owned = false;
45507         int64_t ret_conv = RoutingFees_hash(&o_conv);
45508         return ret_conv;
45509 }
45510
45511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
45512         LDKRoutingFees obj_conv;
45513         obj_conv.inner = untag_ptr(obj);
45514         obj_conv.is_owned = ptr_is_owned(obj);
45515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45516         obj_conv.is_owned = false;
45517         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
45518         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45519         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45520         CVec_u8Z_free(ret_var);
45521         return ret_arr;
45522 }
45523
45524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45525         LDKu8slice ser_ref;
45526         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45527         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45528         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
45529         *ret_conv = RoutingFees_read(ser_ref);
45530         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45531         return tag_ptr(ret_conv, true);
45532 }
45533
45534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45535         LDKNodeAnnouncementInfo this_obj_conv;
45536         this_obj_conv.inner = untag_ptr(this_obj);
45537         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45539         NodeAnnouncementInfo_free(this_obj_conv);
45540 }
45541
45542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45543         LDKNodeAnnouncementInfo this_ptr_conv;
45544         this_ptr_conv.inner = untag_ptr(this_ptr);
45545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45547         this_ptr_conv.is_owned = false;
45548         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
45549         int64_t ret_ref = 0;
45550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45552         return ret_ref;
45553 }
45554
45555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45556         LDKNodeAnnouncementInfo this_ptr_conv;
45557         this_ptr_conv.inner = untag_ptr(this_ptr);
45558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45560         this_ptr_conv.is_owned = false;
45561         LDKNodeFeatures val_conv;
45562         val_conv.inner = untag_ptr(val);
45563         val_conv.is_owned = ptr_is_owned(val);
45564         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45565         val_conv = NodeFeatures_clone(&val_conv);
45566         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
45567 }
45568
45569 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
45570         LDKNodeAnnouncementInfo this_ptr_conv;
45571         this_ptr_conv.inner = untag_ptr(this_ptr);
45572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45574         this_ptr_conv.is_owned = false;
45575         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
45576         return ret_conv;
45577 }
45578
45579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45580         LDKNodeAnnouncementInfo this_ptr_conv;
45581         this_ptr_conv.inner = untag_ptr(this_ptr);
45582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45584         this_ptr_conv.is_owned = false;
45585         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
45586 }
45587
45588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
45589         LDKNodeAnnouncementInfo this_ptr_conv;
45590         this_ptr_conv.inner = untag_ptr(this_ptr);
45591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45593         this_ptr_conv.is_owned = false;
45594         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
45595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
45596         return ret_arr;
45597 }
45598
45599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45600         LDKNodeAnnouncementInfo this_ptr_conv;
45601         this_ptr_conv.inner = untag_ptr(this_ptr);
45602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45604         this_ptr_conv.is_owned = false;
45605         LDKThreeBytes val_ref;
45606         CHECK((*env)->GetArrayLength(env, val) == 3);
45607         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
45608         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
45609 }
45610
45611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
45612         LDKNodeAnnouncementInfo this_ptr_conv;
45613         this_ptr_conv.inner = untag_ptr(this_ptr);
45614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45616         this_ptr_conv.is_owned = false;
45617         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
45618         int64_t ret_ref = 0;
45619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45620         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45621         return ret_ref;
45622 }
45623
45624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45625         LDKNodeAnnouncementInfo this_ptr_conv;
45626         this_ptr_conv.inner = untag_ptr(this_ptr);
45627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45629         this_ptr_conv.is_owned = false;
45630         LDKNodeAlias val_conv;
45631         val_conv.inner = untag_ptr(val);
45632         val_conv.is_owned = ptr_is_owned(val);
45633         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45634         val_conv = NodeAlias_clone(&val_conv);
45635         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
45636 }
45637
45638 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
45639         LDKNodeAnnouncementInfo this_ptr_conv;
45640         this_ptr_conv.inner = untag_ptr(this_ptr);
45641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45643         this_ptr_conv.is_owned = false;
45644         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
45645         int64_tArray ret_arr = NULL;
45646         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45647         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45648         for (size_t m = 0; m < ret_var.datalen; m++) {
45649                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
45650                 *ret_conv_12_copy = ret_var.data[m];
45651                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
45652                 ret_arr_ptr[m] = ret_conv_12_ref;
45653         }
45654         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45655         FREE(ret_var.data);
45656         return ret_arr;
45657 }
45658
45659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45660         LDKNodeAnnouncementInfo this_ptr_conv;
45661         this_ptr_conv.inner = untag_ptr(this_ptr);
45662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45664         this_ptr_conv.is_owned = false;
45665         LDKCVec_NetAddressZ val_constr;
45666         val_constr.datalen = (*env)->GetArrayLength(env, val);
45667         if (val_constr.datalen > 0)
45668                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
45669         else
45670                 val_constr.data = NULL;
45671         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45672         for (size_t m = 0; m < val_constr.datalen; m++) {
45673                 int64_t val_conv_12 = val_vals[m];
45674                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
45675                 CHECK_ACCESS(val_conv_12_ptr);
45676                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
45677                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
45678                 val_constr.data[m] = val_conv_12_conv;
45679         }
45680         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45681         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
45682 }
45683
45684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
45685         LDKNodeAnnouncementInfo this_ptr_conv;
45686         this_ptr_conv.inner = untag_ptr(this_ptr);
45687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45689         this_ptr_conv.is_owned = false;
45690         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
45691         int64_t ret_ref = 0;
45692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45694         return ret_ref;
45695 }
45696
45697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45698         LDKNodeAnnouncementInfo this_ptr_conv;
45699         this_ptr_conv.inner = untag_ptr(this_ptr);
45700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45702         this_ptr_conv.is_owned = false;
45703         LDKNodeAnnouncement val_conv;
45704         val_conv.inner = untag_ptr(val);
45705         val_conv.is_owned = ptr_is_owned(val);
45706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45707         val_conv = NodeAnnouncement_clone(&val_conv);
45708         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
45709 }
45710
45711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
45712         LDKNodeFeatures features_arg_conv;
45713         features_arg_conv.inner = untag_ptr(features_arg);
45714         features_arg_conv.is_owned = ptr_is_owned(features_arg);
45715         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45716         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
45717         LDKThreeBytes rgb_arg_ref;
45718         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
45719         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
45720         LDKNodeAlias alias_arg_conv;
45721         alias_arg_conv.inner = untag_ptr(alias_arg);
45722         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
45723         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
45724         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
45725         LDKCVec_NetAddressZ addresses_arg_constr;
45726         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
45727         if (addresses_arg_constr.datalen > 0)
45728                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
45729         else
45730                 addresses_arg_constr.data = NULL;
45731         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
45732         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
45733                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
45734                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
45735                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
45736                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
45737                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
45738         }
45739         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
45740         LDKNodeAnnouncement announcement_message_arg_conv;
45741         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
45742         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
45743         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
45744         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
45745         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
45746         int64_t ret_ref = 0;
45747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45749         return ret_ref;
45750 }
45751
45752 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
45753         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
45754         int64_t ret_ref = 0;
45755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45757         return ret_ref;
45758 }
45759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45760         LDKNodeAnnouncementInfo arg_conv;
45761         arg_conv.inner = untag_ptr(arg);
45762         arg_conv.is_owned = ptr_is_owned(arg);
45763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45764         arg_conv.is_owned = false;
45765         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
45766         return ret_conv;
45767 }
45768
45769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45770         LDKNodeAnnouncementInfo orig_conv;
45771         orig_conv.inner = untag_ptr(orig);
45772         orig_conv.is_owned = ptr_is_owned(orig);
45773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45774         orig_conv.is_owned = false;
45775         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
45776         int64_t ret_ref = 0;
45777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45779         return ret_ref;
45780 }
45781
45782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45783         LDKNodeAnnouncementInfo a_conv;
45784         a_conv.inner = untag_ptr(a);
45785         a_conv.is_owned = ptr_is_owned(a);
45786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45787         a_conv.is_owned = false;
45788         LDKNodeAnnouncementInfo b_conv;
45789         b_conv.inner = untag_ptr(b);
45790         b_conv.is_owned = ptr_is_owned(b);
45791         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45792         b_conv.is_owned = false;
45793         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
45794         return ret_conv;
45795 }
45796
45797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
45798         LDKNodeAnnouncementInfo obj_conv;
45799         obj_conv.inner = untag_ptr(obj);
45800         obj_conv.is_owned = ptr_is_owned(obj);
45801         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45802         obj_conv.is_owned = false;
45803         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
45804         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45805         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45806         CVec_u8Z_free(ret_var);
45807         return ret_arr;
45808 }
45809
45810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45811         LDKu8slice ser_ref;
45812         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45813         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45814         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
45815         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
45816         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45817         return tag_ptr(ret_conv, true);
45818 }
45819
45820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45821         LDKNodeAlias this_obj_conv;
45822         this_obj_conv.inner = untag_ptr(this_obj);
45823         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45825         NodeAlias_free(this_obj_conv);
45826 }
45827
45828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45829         LDKNodeAlias this_ptr_conv;
45830         this_ptr_conv.inner = untag_ptr(this_ptr);
45831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45833         this_ptr_conv.is_owned = false;
45834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
45836         return ret_arr;
45837 }
45838
45839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45840         LDKNodeAlias this_ptr_conv;
45841         this_ptr_conv.inner = untag_ptr(this_ptr);
45842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45844         this_ptr_conv.is_owned = false;
45845         LDKThirtyTwoBytes val_ref;
45846         CHECK((*env)->GetArrayLength(env, val) == 32);
45847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
45848         NodeAlias_set_a(&this_ptr_conv, val_ref);
45849 }
45850
45851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
45852         LDKThirtyTwoBytes a_arg_ref;
45853         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
45854         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
45855         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
45856         int64_t ret_ref = 0;
45857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45859         return ret_ref;
45860 }
45861
45862 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
45863         LDKNodeAlias ret_var = NodeAlias_clone(arg);
45864         int64_t ret_ref = 0;
45865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45867         return ret_ref;
45868 }
45869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45870         LDKNodeAlias arg_conv;
45871         arg_conv.inner = untag_ptr(arg);
45872         arg_conv.is_owned = ptr_is_owned(arg);
45873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45874         arg_conv.is_owned = false;
45875         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
45876         return ret_conv;
45877 }
45878
45879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45880         LDKNodeAlias orig_conv;
45881         orig_conv.inner = untag_ptr(orig);
45882         orig_conv.is_owned = ptr_is_owned(orig);
45883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45884         orig_conv.is_owned = false;
45885         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
45886         int64_t ret_ref = 0;
45887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45889         return ret_ref;
45890 }
45891
45892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45893         LDKNodeAlias a_conv;
45894         a_conv.inner = untag_ptr(a);
45895         a_conv.is_owned = ptr_is_owned(a);
45896         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45897         a_conv.is_owned = false;
45898         LDKNodeAlias b_conv;
45899         b_conv.inner = untag_ptr(b);
45900         b_conv.is_owned = ptr_is_owned(b);
45901         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45902         b_conv.is_owned = false;
45903         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
45904         return ret_conv;
45905 }
45906
45907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
45908         LDKNodeAlias obj_conv;
45909         obj_conv.inner = untag_ptr(obj);
45910         obj_conv.is_owned = ptr_is_owned(obj);
45911         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45912         obj_conv.is_owned = false;
45913         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
45914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45916         CVec_u8Z_free(ret_var);
45917         return ret_arr;
45918 }
45919
45920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45921         LDKu8slice ser_ref;
45922         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45923         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45924         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
45925         *ret_conv = NodeAlias_read(ser_ref);
45926         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45927         return tag_ptr(ret_conv, true);
45928 }
45929
45930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45931         LDKNodeInfo this_obj_conv;
45932         this_obj_conv.inner = untag_ptr(this_obj);
45933         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45935         NodeInfo_free(this_obj_conv);
45936 }
45937
45938 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
45939         LDKNodeInfo this_ptr_conv;
45940         this_ptr_conv.inner = untag_ptr(this_ptr);
45941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45943         this_ptr_conv.is_owned = false;
45944         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
45945         int64_tArray ret_arr = NULL;
45946         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45947         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45948         for (size_t g = 0; g < ret_var.datalen; g++) {
45949                 int64_t ret_conv_6_conv = ret_var.data[g];
45950                 ret_arr_ptr[g] = ret_conv_6_conv;
45951         }
45952         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45953         FREE(ret_var.data);
45954         return ret_arr;
45955 }
45956
45957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45958         LDKNodeInfo this_ptr_conv;
45959         this_ptr_conv.inner = untag_ptr(this_ptr);
45960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45962         this_ptr_conv.is_owned = false;
45963         LDKCVec_u64Z val_constr;
45964         val_constr.datalen = (*env)->GetArrayLength(env, val);
45965         if (val_constr.datalen > 0)
45966                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45967         else
45968                 val_constr.data = NULL;
45969         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45970         for (size_t g = 0; g < val_constr.datalen; g++) {
45971                 int64_t val_conv_6 = val_vals[g];
45972                 val_constr.data[g] = val_conv_6;
45973         }
45974         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45975         NodeInfo_set_channels(&this_ptr_conv, val_constr);
45976 }
45977
45978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45979         LDKNodeInfo this_ptr_conv;
45980         this_ptr_conv.inner = untag_ptr(this_ptr);
45981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45983         this_ptr_conv.is_owned = false;
45984         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
45985         int64_t ret_ref = 0;
45986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45988         return ret_ref;
45989 }
45990
45991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45992         LDKNodeInfo this_ptr_conv;
45993         this_ptr_conv.inner = untag_ptr(this_ptr);
45994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45996         this_ptr_conv.is_owned = false;
45997         LDKRoutingFees val_conv;
45998         val_conv.inner = untag_ptr(val);
45999         val_conv.is_owned = ptr_is_owned(val);
46000         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46001         val_conv = RoutingFees_clone(&val_conv);
46002         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
46003 }
46004
46005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
46006         LDKNodeInfo this_ptr_conv;
46007         this_ptr_conv.inner = untag_ptr(this_ptr);
46008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46010         this_ptr_conv.is_owned = false;
46011         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
46012         int64_t ret_ref = 0;
46013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46015         return ret_ref;
46016 }
46017
46018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46019         LDKNodeInfo this_ptr_conv;
46020         this_ptr_conv.inner = untag_ptr(this_ptr);
46021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46023         this_ptr_conv.is_owned = false;
46024         LDKNodeAnnouncementInfo val_conv;
46025         val_conv.inner = untag_ptr(val);
46026         val_conv.is_owned = ptr_is_owned(val);
46027         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46028         val_conv = NodeAnnouncementInfo_clone(&val_conv);
46029         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
46030 }
46031
46032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t lowest_inbound_channel_fees_arg, int64_t announcement_info_arg) {
46033         LDKCVec_u64Z channels_arg_constr;
46034         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
46035         if (channels_arg_constr.datalen > 0)
46036                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
46037         else
46038                 channels_arg_constr.data = NULL;
46039         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
46040         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
46041                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
46042                 channels_arg_constr.data[g] = channels_arg_conv_6;
46043         }
46044         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
46045         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
46046         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
46047         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
46048         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
46049         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
46050         LDKNodeAnnouncementInfo announcement_info_arg_conv;
46051         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
46052         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
46053         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
46054         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
46055         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
46056         int64_t ret_ref = 0;
46057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46058         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46059         return ret_ref;
46060 }
46061
46062 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
46063         LDKNodeInfo ret_var = NodeInfo_clone(arg);
46064         int64_t ret_ref = 0;
46065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46067         return ret_ref;
46068 }
46069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46070         LDKNodeInfo arg_conv;
46071         arg_conv.inner = untag_ptr(arg);
46072         arg_conv.is_owned = ptr_is_owned(arg);
46073         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46074         arg_conv.is_owned = false;
46075         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
46076         return ret_conv;
46077 }
46078
46079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46080         LDKNodeInfo orig_conv;
46081         orig_conv.inner = untag_ptr(orig);
46082         orig_conv.is_owned = ptr_is_owned(orig);
46083         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46084         orig_conv.is_owned = false;
46085         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
46086         int64_t ret_ref = 0;
46087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46088         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46089         return ret_ref;
46090 }
46091
46092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46093         LDKNodeInfo a_conv;
46094         a_conv.inner = untag_ptr(a);
46095         a_conv.is_owned = ptr_is_owned(a);
46096         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46097         a_conv.is_owned = false;
46098         LDKNodeInfo b_conv;
46099         b_conv.inner = untag_ptr(b);
46100         b_conv.is_owned = ptr_is_owned(b);
46101         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46102         b_conv.is_owned = false;
46103         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
46104         return ret_conv;
46105 }
46106
46107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46108         LDKNodeInfo obj_conv;
46109         obj_conv.inner = untag_ptr(obj);
46110         obj_conv.is_owned = ptr_is_owned(obj);
46111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46112         obj_conv.is_owned = false;
46113         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
46114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46116         CVec_u8Z_free(ret_var);
46117         return ret_arr;
46118 }
46119
46120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46121         LDKu8slice ser_ref;
46122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46124         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
46125         *ret_conv = NodeInfo_read(ser_ref);
46126         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46127         return tag_ptr(ret_conv, true);
46128 }
46129
46130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
46131         LDKNetworkGraph obj_conv;
46132         obj_conv.inner = untag_ptr(obj);
46133         obj_conv.is_owned = ptr_is_owned(obj);
46134         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46135         obj_conv.is_owned = false;
46136         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
46137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46139         CVec_u8Z_free(ret_var);
46140         return ret_arr;
46141 }
46142
46143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46144         LDKu8slice ser_ref;
46145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46147         void* arg_ptr = untag_ptr(arg);
46148         CHECK_ACCESS(arg_ptr);
46149         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
46150         if (arg_conv.free == LDKLogger_JCalls_free) {
46151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46152                 LDKLogger_JCalls_cloned(&arg_conv);
46153         }
46154         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
46155         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
46156         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46157         return tag_ptr(ret_conv, true);
46158 }
46159
46160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
46161         LDKThirtyTwoBytes genesis_hash_ref;
46162         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
46163         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
46164         void* logger_ptr = untag_ptr(logger);
46165         CHECK_ACCESS(logger_ptr);
46166         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46167         if (logger_conv.free == LDKLogger_JCalls_free) {
46168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46169                 LDKLogger_JCalls_cloned(&logger_conv);
46170         }
46171         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
46172         int64_t ret_ref = 0;
46173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46175         return ret_ref;
46176 }
46177
46178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
46179         LDKNetworkGraph this_arg_conv;
46180         this_arg_conv.inner = untag_ptr(this_arg);
46181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46183         this_arg_conv.is_owned = false;
46184         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
46185         int64_t ret_ref = 0;
46186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46188         return ret_ref;
46189 }
46190
46191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
46192         LDKNetworkGraph this_arg_conv;
46193         this_arg_conv.inner = untag_ptr(this_arg);
46194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46196         this_arg_conv.is_owned = false;
46197         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
46198         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
46199         int64_t ret_ref = tag_ptr(ret_copy, true);
46200         return ret_ref;
46201 }
46202
46203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
46204         LDKNetworkGraph this_arg_conv;
46205         this_arg_conv.inner = untag_ptr(this_arg);
46206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46208         this_arg_conv.is_owned = false;
46209         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
46210 }
46211
46212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46213         LDKNetworkGraph this_arg_conv;
46214         this_arg_conv.inner = untag_ptr(this_arg);
46215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46217         this_arg_conv.is_owned = false;
46218         LDKNodeAnnouncement msg_conv;
46219         msg_conv.inner = untag_ptr(msg);
46220         msg_conv.is_owned = ptr_is_owned(msg);
46221         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46222         msg_conv.is_owned = false;
46223         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46224         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
46225         return tag_ptr(ret_conv, true);
46226 }
46227
46228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1unsigned_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46229         LDKNetworkGraph this_arg_conv;
46230         this_arg_conv.inner = untag_ptr(this_arg);
46231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46233         this_arg_conv.is_owned = false;
46234         LDKUnsignedNodeAnnouncement msg_conv;
46235         msg_conv.inner = untag_ptr(msg);
46236         msg_conv.is_owned = ptr_is_owned(msg);
46237         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46238         msg_conv.is_owned = false;
46239         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46240         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
46241         return tag_ptr(ret_conv, true);
46242 }
46243
46244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int64_t chain_access) {
46245         LDKNetworkGraph this_arg_conv;
46246         this_arg_conv.inner = untag_ptr(this_arg);
46247         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46249         this_arg_conv.is_owned = false;
46250         LDKChannelAnnouncement msg_conv;
46251         msg_conv.inner = untag_ptr(msg);
46252         msg_conv.is_owned = ptr_is_owned(msg);
46253         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46254         msg_conv.is_owned = false;
46255         void* chain_access_ptr = untag_ptr(chain_access);
46256         CHECK_ACCESS(chain_access_ptr);
46257         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46258         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46259         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46260                 // Manually implement clone for Java trait instances
46261                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46262                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46263                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46264                 }
46265         }
46266         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46267         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
46268         return tag_ptr(ret_conv, true);
46269 }
46270
46271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1from_1unsigned_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int64_t chain_access) {
46272         LDKNetworkGraph this_arg_conv;
46273         this_arg_conv.inner = untag_ptr(this_arg);
46274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46276         this_arg_conv.is_owned = false;
46277         LDKUnsignedChannelAnnouncement msg_conv;
46278         msg_conv.inner = untag_ptr(msg);
46279         msg_conv.is_owned = ptr_is_owned(msg);
46280         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46281         msg_conv.is_owned = false;
46282         void* chain_access_ptr = untag_ptr(chain_access);
46283         CHECK_ACCESS(chain_access_ptr);
46284         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46285         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46286         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46287                 // Manually implement clone for Java trait instances
46288                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46289                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46290                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46291                 }
46292         }
46293         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46294         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
46295         return tag_ptr(ret_conv, true);
46296 }
46297
46298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
46299         LDKNetworkGraph this_arg_conv;
46300         this_arg_conv.inner = untag_ptr(this_arg);
46301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46303         this_arg_conv.is_owned = false;
46304         LDKChannelFeatures features_conv;
46305         features_conv.inner = untag_ptr(features);
46306         features_conv.is_owned = ptr_is_owned(features);
46307         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46308         features_conv = ChannelFeatures_clone(&features_conv);
46309         LDKPublicKey node_id_1_ref;
46310         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
46311         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
46312         LDKPublicKey node_id_2_ref;
46313         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
46314         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
46315         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46316         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
46317         return tag_ptr(ret_conv, true);
46318 }
46319
46320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
46321         LDKNetworkGraph this_arg_conv;
46322         this_arg_conv.inner = untag_ptr(this_arg);
46323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46325         this_arg_conv.is_owned = false;
46326         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
46327 }
46328
46329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
46330         LDKNetworkGraph this_arg_conv;
46331         this_arg_conv.inner = untag_ptr(this_arg);
46332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46334         this_arg_conv.is_owned = false;
46335         LDKPublicKey node_id_ref;
46336         CHECK((*env)->GetArrayLength(env, node_id) == 33);
46337         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
46338         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
46339 }
46340
46341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
46342         LDKNetworkGraph this_arg_conv;
46343         this_arg_conv.inner = untag_ptr(this_arg);
46344         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46346         this_arg_conv.is_owned = false;
46347         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
46348 }
46349
46350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking_1with_1time(JNIEnv *env, jclass clz, int64_t this_arg, int64_t current_time_unix) {
46351         LDKNetworkGraph this_arg_conv;
46352         this_arg_conv.inner = untag_ptr(this_arg);
46353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46355         this_arg_conv.is_owned = false;
46356         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
46357 }
46358
46359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46360         LDKNetworkGraph this_arg_conv;
46361         this_arg_conv.inner = untag_ptr(this_arg);
46362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46364         this_arg_conv.is_owned = false;
46365         LDKChannelUpdate msg_conv;
46366         msg_conv.inner = untag_ptr(msg);
46367         msg_conv.is_owned = ptr_is_owned(msg);
46368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46369         msg_conv.is_owned = false;
46370         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46371         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
46372         return tag_ptr(ret_conv, true);
46373 }
46374
46375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46376         LDKNetworkGraph this_arg_conv;
46377         this_arg_conv.inner = untag_ptr(this_arg);
46378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46380         this_arg_conv.is_owned = false;
46381         LDKUnsignedChannelUpdate msg_conv;
46382         msg_conv.inner = untag_ptr(msg);
46383         msg_conv.is_owned = ptr_is_owned(msg);
46384         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46385         msg_conv.is_owned = false;
46386         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46387         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
46388         return tag_ptr(ret_conv, true);
46389 }
46390
46391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
46392         LDKReadOnlyNetworkGraph this_arg_conv;
46393         this_arg_conv.inner = untag_ptr(this_arg);
46394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46396         this_arg_conv.is_owned = false;
46397         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
46398         int64_t ret_ref = 0;
46399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46401         return ret_ref;
46402 }
46403
46404 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
46405         LDKReadOnlyNetworkGraph this_arg_conv;
46406         this_arg_conv.inner = untag_ptr(this_arg);
46407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46409         this_arg_conv.is_owned = false;
46410         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
46411         int64_tArray ret_arr = NULL;
46412         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46413         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46414         for (size_t g = 0; g < ret_var.datalen; g++) {
46415                 int64_t ret_conv_6_conv = ret_var.data[g];
46416                 ret_arr_ptr[g] = ret_conv_6_conv;
46417         }
46418         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46419         FREE(ret_var.data);
46420         return ret_arr;
46421 }
46422
46423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46424         LDKReadOnlyNetworkGraph this_arg_conv;
46425         this_arg_conv.inner = untag_ptr(this_arg);
46426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46428         this_arg_conv.is_owned = false;
46429         LDKNodeId node_id_conv;
46430         node_id_conv.inner = untag_ptr(node_id);
46431         node_id_conv.is_owned = ptr_is_owned(node_id);
46432         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46433         node_id_conv.is_owned = false;
46434         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
46435         int64_t ret_ref = 0;
46436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46438         return ret_ref;
46439 }
46440
46441 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
46442         LDKReadOnlyNetworkGraph this_arg_conv;
46443         this_arg_conv.inner = untag_ptr(this_arg);
46444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46446         this_arg_conv.is_owned = false;
46447         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
46448         int64_tArray ret_arr = NULL;
46449         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46450         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46451         for (size_t i = 0; i < ret_var.datalen; i++) {
46452                 LDKNodeId ret_conv_8_var = ret_var.data[i];
46453                 int64_t ret_conv_8_ref = 0;
46454                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
46455                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
46456                 ret_arr_ptr[i] = ret_conv_8_ref;
46457         }
46458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46459         FREE(ret_var.data);
46460         return ret_arr;
46461 }
46462
46463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
46464         LDKReadOnlyNetworkGraph this_arg_conv;
46465         this_arg_conv.inner = untag_ptr(this_arg);
46466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46468         this_arg_conv.is_owned = false;
46469         LDKPublicKey pubkey_ref;
46470         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
46471         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
46472         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
46473         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
46474         int64_t ret_ref = tag_ptr(ret_copy, true);
46475         return ret_ref;
46476 }
46477
46478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46479         LDKRouteHop this_obj_conv;
46480         this_obj_conv.inner = untag_ptr(this_obj);
46481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46483         RouteHop_free(this_obj_conv);
46484 }
46485
46486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
46487         LDKRouteHop this_ptr_conv;
46488         this_ptr_conv.inner = untag_ptr(this_ptr);
46489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46491         this_ptr_conv.is_owned = false;
46492         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
46494         return ret_arr;
46495 }
46496
46497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46498         LDKRouteHop this_ptr_conv;
46499         this_ptr_conv.inner = untag_ptr(this_ptr);
46500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46502         this_ptr_conv.is_owned = false;
46503         LDKPublicKey val_ref;
46504         CHECK((*env)->GetArrayLength(env, val) == 33);
46505         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46506         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
46507 }
46508
46509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46510         LDKRouteHop this_ptr_conv;
46511         this_ptr_conv.inner = untag_ptr(this_ptr);
46512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46514         this_ptr_conv.is_owned = false;
46515         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
46516         int64_t ret_ref = 0;
46517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46519         return ret_ref;
46520 }
46521
46522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46523         LDKRouteHop this_ptr_conv;
46524         this_ptr_conv.inner = untag_ptr(this_ptr);
46525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46527         this_ptr_conv.is_owned = false;
46528         LDKNodeFeatures val_conv;
46529         val_conv.inner = untag_ptr(val);
46530         val_conv.is_owned = ptr_is_owned(val);
46531         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46532         val_conv = NodeFeatures_clone(&val_conv);
46533         RouteHop_set_node_features(&this_ptr_conv, val_conv);
46534 }
46535
46536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46537         LDKRouteHop this_ptr_conv;
46538         this_ptr_conv.inner = untag_ptr(this_ptr);
46539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46541         this_ptr_conv.is_owned = false;
46542         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
46543         return ret_conv;
46544 }
46545
46546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46547         LDKRouteHop this_ptr_conv;
46548         this_ptr_conv.inner = untag_ptr(this_ptr);
46549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46551         this_ptr_conv.is_owned = false;
46552         RouteHop_set_short_channel_id(&this_ptr_conv, val);
46553 }
46554
46555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46556         LDKRouteHop this_ptr_conv;
46557         this_ptr_conv.inner = untag_ptr(this_ptr);
46558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46560         this_ptr_conv.is_owned = false;
46561         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
46562         int64_t ret_ref = 0;
46563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46565         return ret_ref;
46566 }
46567
46568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46569         LDKRouteHop this_ptr_conv;
46570         this_ptr_conv.inner = untag_ptr(this_ptr);
46571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46573         this_ptr_conv.is_owned = false;
46574         LDKChannelFeatures val_conv;
46575         val_conv.inner = untag_ptr(val);
46576         val_conv.is_owned = ptr_is_owned(val);
46577         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46578         val_conv = ChannelFeatures_clone(&val_conv);
46579         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
46580 }
46581
46582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46583         LDKRouteHop this_ptr_conv;
46584         this_ptr_conv.inner = untag_ptr(this_ptr);
46585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46587         this_ptr_conv.is_owned = false;
46588         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
46589         return ret_conv;
46590 }
46591
46592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46593         LDKRouteHop this_ptr_conv;
46594         this_ptr_conv.inner = untag_ptr(this_ptr);
46595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46597         this_ptr_conv.is_owned = false;
46598         RouteHop_set_fee_msat(&this_ptr_conv, val);
46599 }
46600
46601 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46602         LDKRouteHop this_ptr_conv;
46603         this_ptr_conv.inner = untag_ptr(this_ptr);
46604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46606         this_ptr_conv.is_owned = false;
46607         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
46608         return ret_conv;
46609 }
46610
46611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46612         LDKRouteHop this_ptr_conv;
46613         this_ptr_conv.inner = untag_ptr(this_ptr);
46614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46616         this_ptr_conv.is_owned = false;
46617         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46618 }
46619
46620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t node_features_arg, int64_t short_channel_id_arg, int64_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
46621         LDKPublicKey pubkey_arg_ref;
46622         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
46623         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
46624         LDKNodeFeatures node_features_arg_conv;
46625         node_features_arg_conv.inner = untag_ptr(node_features_arg);
46626         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
46627         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
46628         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
46629         LDKChannelFeatures channel_features_arg_conv;
46630         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
46631         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
46632         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
46633         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
46634         LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
46635         int64_t ret_ref = 0;
46636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46638         return ret_ref;
46639 }
46640
46641 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
46642         LDKRouteHop ret_var = RouteHop_clone(arg);
46643         int64_t ret_ref = 0;
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46646         return ret_ref;
46647 }
46648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46649         LDKRouteHop arg_conv;
46650         arg_conv.inner = untag_ptr(arg);
46651         arg_conv.is_owned = ptr_is_owned(arg);
46652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46653         arg_conv.is_owned = false;
46654         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
46655         return ret_conv;
46656 }
46657
46658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46659         LDKRouteHop orig_conv;
46660         orig_conv.inner = untag_ptr(orig);
46661         orig_conv.is_owned = ptr_is_owned(orig);
46662         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46663         orig_conv.is_owned = false;
46664         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
46665         int64_t ret_ref = 0;
46666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46668         return ret_ref;
46669 }
46670
46671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46672         LDKRouteHop o_conv;
46673         o_conv.inner = untag_ptr(o);
46674         o_conv.is_owned = ptr_is_owned(o);
46675         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46676         o_conv.is_owned = false;
46677         int64_t ret_conv = RouteHop_hash(&o_conv);
46678         return ret_conv;
46679 }
46680
46681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46682         LDKRouteHop a_conv;
46683         a_conv.inner = untag_ptr(a);
46684         a_conv.is_owned = ptr_is_owned(a);
46685         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46686         a_conv.is_owned = false;
46687         LDKRouteHop b_conv;
46688         b_conv.inner = untag_ptr(b);
46689         b_conv.is_owned = ptr_is_owned(b);
46690         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46691         b_conv.is_owned = false;
46692         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
46693         return ret_conv;
46694 }
46695
46696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46697         LDKRouteHop obj_conv;
46698         obj_conv.inner = untag_ptr(obj);
46699         obj_conv.is_owned = ptr_is_owned(obj);
46700         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46701         obj_conv.is_owned = false;
46702         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
46703         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46704         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46705         CVec_u8Z_free(ret_var);
46706         return ret_arr;
46707 }
46708
46709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46710         LDKu8slice ser_ref;
46711         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46712         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46713         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
46714         *ret_conv = RouteHop_read(ser_ref);
46715         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46716         return tag_ptr(ret_conv, true);
46717 }
46718
46719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46720         LDKRoute this_obj_conv;
46721         this_obj_conv.inner = untag_ptr(this_obj);
46722         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46724         Route_free(this_obj_conv);
46725 }
46726
46727 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
46728         LDKRoute this_ptr_conv;
46729         this_ptr_conv.inner = untag_ptr(this_ptr);
46730         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46732         this_ptr_conv.is_owned = false;
46733         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
46734         jobjectArray ret_arr = NULL;
46735         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
46736         ;
46737         for (size_t m = 0; m < ret_var.datalen; m++) {
46738                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
46739                 int64_tArray ret_conv_12_arr = NULL;
46740                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
46741                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
46742                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
46743                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
46744                         int64_t ret_conv_12_conv_10_ref = 0;
46745                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
46746                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
46747                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
46748                 }
46749                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
46750                 FREE(ret_conv_12_var.data);
46751                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
46752         }
46753         
46754         FREE(ret_var.data);
46755         return ret_arr;
46756 }
46757
46758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
46759         LDKRoute this_ptr_conv;
46760         this_ptr_conv.inner = untag_ptr(this_ptr);
46761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46763         this_ptr_conv.is_owned = false;
46764         LDKCVec_CVec_RouteHopZZ val_constr;
46765         val_constr.datalen = (*env)->GetArrayLength(env, val);
46766         if (val_constr.datalen > 0)
46767                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
46768         else
46769                 val_constr.data = NULL;
46770         for (size_t m = 0; m < val_constr.datalen; m++) {
46771                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
46772                 LDKCVec_RouteHopZ val_conv_12_constr;
46773                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
46774                 if (val_conv_12_constr.datalen > 0)
46775                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
46776                 else
46777                         val_conv_12_constr.data = NULL;
46778                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
46779                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
46780                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
46781                         LDKRouteHop val_conv_12_conv_10_conv;
46782                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
46783                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
46784                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
46785                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
46786                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
46787                 }
46788                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
46789                 val_constr.data[m] = val_conv_12_constr;
46790         }
46791         Route_set_paths(&this_ptr_conv, val_constr);
46792 }
46793
46794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
46795         LDKRoute this_ptr_conv;
46796         this_ptr_conv.inner = untag_ptr(this_ptr);
46797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46799         this_ptr_conv.is_owned = false;
46800         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
46801         int64_t ret_ref = 0;
46802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46803         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46804         return ret_ref;
46805 }
46806
46807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46808         LDKRoute this_ptr_conv;
46809         this_ptr_conv.inner = untag_ptr(this_ptr);
46810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46812         this_ptr_conv.is_owned = false;
46813         LDKPaymentParameters val_conv;
46814         val_conv.inner = untag_ptr(val);
46815         val_conv.is_owned = ptr_is_owned(val);
46816         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46817         val_conv = PaymentParameters_clone(&val_conv);
46818         Route_set_payment_params(&this_ptr_conv, val_conv);
46819 }
46820
46821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
46822         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
46823         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
46824         if (paths_arg_constr.datalen > 0)
46825                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
46826         else
46827                 paths_arg_constr.data = NULL;
46828         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
46829                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
46830                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
46831                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
46832                 if (paths_arg_conv_12_constr.datalen > 0)
46833                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
46834                 else
46835                         paths_arg_conv_12_constr.data = NULL;
46836                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
46837                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
46838                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
46839                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
46840                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
46841                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
46842                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
46843                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
46844                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
46845                 }
46846                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
46847                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
46848         }
46849         LDKPaymentParameters payment_params_arg_conv;
46850         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
46851         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
46852         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
46853         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
46854         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
46855         int64_t ret_ref = 0;
46856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46858         return ret_ref;
46859 }
46860
46861 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
46862         LDKRoute ret_var = Route_clone(arg);
46863         int64_t ret_ref = 0;
46864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46866         return ret_ref;
46867 }
46868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46869         LDKRoute arg_conv;
46870         arg_conv.inner = untag_ptr(arg);
46871         arg_conv.is_owned = ptr_is_owned(arg);
46872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46873         arg_conv.is_owned = false;
46874         int64_t ret_conv = Route_clone_ptr(&arg_conv);
46875         return ret_conv;
46876 }
46877
46878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46879         LDKRoute orig_conv;
46880         orig_conv.inner = untag_ptr(orig);
46881         orig_conv.is_owned = ptr_is_owned(orig);
46882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46883         orig_conv.is_owned = false;
46884         LDKRoute ret_var = Route_clone(&orig_conv);
46885         int64_t ret_ref = 0;
46886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46888         return ret_ref;
46889 }
46890
46891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
46892         LDKRoute o_conv;
46893         o_conv.inner = untag_ptr(o);
46894         o_conv.is_owned = ptr_is_owned(o);
46895         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46896         o_conv.is_owned = false;
46897         int64_t ret_conv = Route_hash(&o_conv);
46898         return ret_conv;
46899 }
46900
46901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46902         LDKRoute a_conv;
46903         a_conv.inner = untag_ptr(a);
46904         a_conv.is_owned = ptr_is_owned(a);
46905         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46906         a_conv.is_owned = false;
46907         LDKRoute b_conv;
46908         b_conv.inner = untag_ptr(b);
46909         b_conv.is_owned = ptr_is_owned(b);
46910         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46911         b_conv.is_owned = false;
46912         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
46913         return ret_conv;
46914 }
46915
46916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
46917         LDKRoute this_arg_conv;
46918         this_arg_conv.inner = untag_ptr(this_arg);
46919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46921         this_arg_conv.is_owned = false;
46922         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
46923         return ret_conv;
46924 }
46925
46926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
46927         LDKRoute this_arg_conv;
46928         this_arg_conv.inner = untag_ptr(this_arg);
46929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46931         this_arg_conv.is_owned = false;
46932         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
46933         return ret_conv;
46934 }
46935
46936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
46937         LDKRoute obj_conv;
46938         obj_conv.inner = untag_ptr(obj);
46939         obj_conv.is_owned = ptr_is_owned(obj);
46940         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46941         obj_conv.is_owned = false;
46942         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
46943         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46944         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46945         CVec_u8Z_free(ret_var);
46946         return ret_arr;
46947 }
46948
46949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46950         LDKu8slice ser_ref;
46951         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46952         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46953         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
46954         *ret_conv = Route_read(ser_ref);
46955         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46956         return tag_ptr(ret_conv, true);
46957 }
46958
46959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46960         LDKRouteParameters this_obj_conv;
46961         this_obj_conv.inner = untag_ptr(this_obj);
46962         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46964         RouteParameters_free(this_obj_conv);
46965 }
46966
46967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
46968         LDKRouteParameters this_ptr_conv;
46969         this_ptr_conv.inner = untag_ptr(this_ptr);
46970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46972         this_ptr_conv.is_owned = false;
46973         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
46974         int64_t ret_ref = 0;
46975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46977         return ret_ref;
46978 }
46979
46980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46981         LDKRouteParameters this_ptr_conv;
46982         this_ptr_conv.inner = untag_ptr(this_ptr);
46983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46985         this_ptr_conv.is_owned = false;
46986         LDKPaymentParameters val_conv;
46987         val_conv.inner = untag_ptr(val);
46988         val_conv.is_owned = ptr_is_owned(val);
46989         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46990         val_conv = PaymentParameters_clone(&val_conv);
46991         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
46992 }
46993
46994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46995         LDKRouteParameters this_ptr_conv;
46996         this_ptr_conv.inner = untag_ptr(this_ptr);
46997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46999         this_ptr_conv.is_owned = false;
47000         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
47001         return ret_conv;
47002 }
47003
47004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47005         LDKRouteParameters this_ptr_conv;
47006         this_ptr_conv.inner = untag_ptr(this_ptr);
47007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47009         this_ptr_conv.is_owned = false;
47010         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
47011 }
47012
47013 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47014         LDKRouteParameters this_ptr_conv;
47015         this_ptr_conv.inner = untag_ptr(this_ptr);
47016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47018         this_ptr_conv.is_owned = false;
47019         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
47020         return ret_conv;
47021 }
47022
47023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47024         LDKRouteParameters this_ptr_conv;
47025         this_ptr_conv.inner = untag_ptr(this_ptr);
47026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47028         this_ptr_conv.is_owned = false;
47029         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
47030 }
47031
47032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
47033         LDKPaymentParameters payment_params_arg_conv;
47034         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
47035         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
47036         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
47037         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
47038         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
47039         int64_t ret_ref = 0;
47040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47042         return ret_ref;
47043 }
47044
47045 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
47046         LDKRouteParameters ret_var = RouteParameters_clone(arg);
47047         int64_t ret_ref = 0;
47048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47050         return ret_ref;
47051 }
47052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47053         LDKRouteParameters arg_conv;
47054         arg_conv.inner = untag_ptr(arg);
47055         arg_conv.is_owned = ptr_is_owned(arg);
47056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47057         arg_conv.is_owned = false;
47058         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
47059         return ret_conv;
47060 }
47061
47062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47063         LDKRouteParameters orig_conv;
47064         orig_conv.inner = untag_ptr(orig);
47065         orig_conv.is_owned = ptr_is_owned(orig);
47066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47067         orig_conv.is_owned = false;
47068         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
47069         int64_t ret_ref = 0;
47070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47072         return ret_ref;
47073 }
47074
47075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
47076         LDKRouteParameters obj_conv;
47077         obj_conv.inner = untag_ptr(obj);
47078         obj_conv.is_owned = ptr_is_owned(obj);
47079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47080         obj_conv.is_owned = false;
47081         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
47082         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47083         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47084         CVec_u8Z_free(ret_var);
47085         return ret_arr;
47086 }
47087
47088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47089         LDKu8slice ser_ref;
47090         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47091         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47092         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
47093         *ret_conv = RouteParameters_read(ser_ref);
47094         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47095         return tag_ptr(ret_conv, true);
47096 }
47097
47098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47099         LDKPaymentParameters this_obj_conv;
47100         this_obj_conv.inner = untag_ptr(this_obj);
47101         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47103         PaymentParameters_free(this_obj_conv);
47104 }
47105
47106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
47107         LDKPaymentParameters this_ptr_conv;
47108         this_ptr_conv.inner = untag_ptr(this_ptr);
47109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47111         this_ptr_conv.is_owned = false;
47112         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
47114         return ret_arr;
47115 }
47116
47117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47118         LDKPaymentParameters this_ptr_conv;
47119         this_ptr_conv.inner = untag_ptr(this_ptr);
47120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47122         this_ptr_conv.is_owned = false;
47123         LDKPublicKey val_ref;
47124         CHECK((*env)->GetArrayLength(env, val) == 33);
47125         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47126         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
47127 }
47128
47129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47130         LDKPaymentParameters this_ptr_conv;
47131         this_ptr_conv.inner = untag_ptr(this_ptr);
47132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47134         this_ptr_conv.is_owned = false;
47135         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
47136         int64_t ret_ref = 0;
47137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47139         return ret_ref;
47140 }
47141
47142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47143         LDKPaymentParameters this_ptr_conv;
47144         this_ptr_conv.inner = untag_ptr(this_ptr);
47145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47147         this_ptr_conv.is_owned = false;
47148         LDKInvoiceFeatures val_conv;
47149         val_conv.inner = untag_ptr(val);
47150         val_conv.is_owned = ptr_is_owned(val);
47151         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47152         val_conv = InvoiceFeatures_clone(&val_conv);
47153         PaymentParameters_set_features(&this_ptr_conv, val_conv);
47154 }
47155
47156 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
47157         LDKPaymentParameters this_ptr_conv;
47158         this_ptr_conv.inner = untag_ptr(this_ptr);
47159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47161         this_ptr_conv.is_owned = false;
47162         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
47163         int64_tArray ret_arr = NULL;
47164         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47165         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47166         for (size_t l = 0; l < ret_var.datalen; l++) {
47167                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47168                 int64_t ret_conv_11_ref = 0;
47169                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47170                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
47171                 ret_arr_ptr[l] = ret_conv_11_ref;
47172         }
47173         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47174         FREE(ret_var.data);
47175         return ret_arr;
47176 }
47177
47178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47179         LDKPaymentParameters this_ptr_conv;
47180         this_ptr_conv.inner = untag_ptr(this_ptr);
47181         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47183         this_ptr_conv.is_owned = false;
47184         LDKCVec_RouteHintZ val_constr;
47185         val_constr.datalen = (*env)->GetArrayLength(env, val);
47186         if (val_constr.datalen > 0)
47187                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
47188         else
47189                 val_constr.data = NULL;
47190         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47191         for (size_t l = 0; l < val_constr.datalen; l++) {
47192                 int64_t val_conv_11 = val_vals[l];
47193                 LDKRouteHint val_conv_11_conv;
47194                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
47195                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
47196                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
47197                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
47198                 val_constr.data[l] = val_conv_11_conv;
47199         }
47200         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47201         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
47202 }
47203
47204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
47205         LDKPaymentParameters this_ptr_conv;
47206         this_ptr_conv.inner = untag_ptr(this_ptr);
47207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47209         this_ptr_conv.is_owned = false;
47210         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47211         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
47212         int64_t ret_ref = tag_ptr(ret_copy, true);
47213         return ret_ref;
47214 }
47215
47216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47217         LDKPaymentParameters this_ptr_conv;
47218         this_ptr_conv.inner = untag_ptr(this_ptr);
47219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47221         this_ptr_conv.is_owned = false;
47222         void* val_ptr = untag_ptr(val);
47223         CHECK_ACCESS(val_ptr);
47224         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47225         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47226         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
47227 }
47228
47229 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47230         LDKPaymentParameters this_ptr_conv;
47231         this_ptr_conv.inner = untag_ptr(this_ptr);
47232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47234         this_ptr_conv.is_owned = false;
47235         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
47236         return ret_conv;
47237 }
47238
47239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47240         LDKPaymentParameters this_ptr_conv;
47241         this_ptr_conv.inner = untag_ptr(this_ptr);
47242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47244         this_ptr_conv.is_owned = false;
47245         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
47246 }
47247
47248 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
47249         LDKPaymentParameters this_ptr_conv;
47250         this_ptr_conv.inner = untag_ptr(this_ptr);
47251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47253         this_ptr_conv.is_owned = false;
47254         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
47255         return ret_conv;
47256 }
47257
47258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
47259         LDKPaymentParameters this_ptr_conv;
47260         this_ptr_conv.inner = untag_ptr(this_ptr);
47261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47263         this_ptr_conv.is_owned = false;
47264         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
47265 }
47266
47267 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr) {
47268         LDKPaymentParameters this_ptr_conv;
47269         this_ptr_conv.inner = untag_ptr(this_ptr);
47270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47272         this_ptr_conv.is_owned = false;
47273         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
47274         return ret_conv;
47275 }
47276
47277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
47278         LDKPaymentParameters this_ptr_conv;
47279         this_ptr_conv.inner = untag_ptr(this_ptr);
47280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47282         this_ptr_conv.is_owned = false;
47283         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
47284 }
47285
47286 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
47287         LDKPaymentParameters this_ptr_conv;
47288         this_ptr_conv.inner = untag_ptr(this_ptr);
47289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47291         this_ptr_conv.is_owned = false;
47292         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
47293         int64_tArray ret_arr = NULL;
47294         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47295         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47296         for (size_t g = 0; g < ret_var.datalen; g++) {
47297                 int64_t ret_conv_6_conv = ret_var.data[g];
47298                 ret_arr_ptr[g] = ret_conv_6_conv;
47299         }
47300         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47301         FREE(ret_var.data);
47302         return ret_arr;
47303 }
47304
47305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47306         LDKPaymentParameters this_ptr_conv;
47307         this_ptr_conv.inner = untag_ptr(this_ptr);
47308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47310         this_ptr_conv.is_owned = false;
47311         LDKCVec_u64Z val_constr;
47312         val_constr.datalen = (*env)->GetArrayLength(env, val);
47313         if (val_constr.datalen > 0)
47314                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47315         else
47316                 val_constr.data = NULL;
47317         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47318         for (size_t g = 0; g < val_constr.datalen; g++) {
47319                 int64_t val_conv_6 = val_vals[g];
47320                 val_constr.data[g] = val_conv_6;
47321         }
47322         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47323         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
47324 }
47325
47326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
47327         LDKPublicKey payee_pubkey_arg_ref;
47328         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
47329         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
47330         LDKInvoiceFeatures features_arg_conv;
47331         features_arg_conv.inner = untag_ptr(features_arg);
47332         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47333         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47334         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
47335         LDKCVec_RouteHintZ route_hints_arg_constr;
47336         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
47337         if (route_hints_arg_constr.datalen > 0)
47338                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
47339         else
47340                 route_hints_arg_constr.data = NULL;
47341         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
47342         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
47343                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
47344                 LDKRouteHint route_hints_arg_conv_11_conv;
47345                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
47346                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
47347                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
47348                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
47349                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
47350         }
47351         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
47352         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
47353         CHECK_ACCESS(expiry_time_arg_ptr);
47354         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
47355         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
47356         LDKCVec_u64Z previously_failed_channels_arg_constr;
47357         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
47358         if (previously_failed_channels_arg_constr.datalen > 0)
47359                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47360         else
47361                 previously_failed_channels_arg_constr.data = NULL;
47362         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
47363         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
47364                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
47365                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
47366         }
47367         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
47368         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
47369         int64_t ret_ref = 0;
47370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47372         return ret_ref;
47373 }
47374
47375 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
47376         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
47377         int64_t ret_ref = 0;
47378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47380         return ret_ref;
47381 }
47382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47383         LDKPaymentParameters arg_conv;
47384         arg_conv.inner = untag_ptr(arg);
47385         arg_conv.is_owned = ptr_is_owned(arg);
47386         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47387         arg_conv.is_owned = false;
47388         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
47389         return ret_conv;
47390 }
47391
47392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47393         LDKPaymentParameters orig_conv;
47394         orig_conv.inner = untag_ptr(orig);
47395         orig_conv.is_owned = ptr_is_owned(orig);
47396         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47397         orig_conv.is_owned = false;
47398         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
47399         int64_t ret_ref = 0;
47400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47402         return ret_ref;
47403 }
47404
47405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
47406         LDKPaymentParameters o_conv;
47407         o_conv.inner = untag_ptr(o);
47408         o_conv.is_owned = ptr_is_owned(o);
47409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47410         o_conv.is_owned = false;
47411         int64_t ret_conv = PaymentParameters_hash(&o_conv);
47412         return ret_conv;
47413 }
47414
47415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47416         LDKPaymentParameters a_conv;
47417         a_conv.inner = untag_ptr(a);
47418         a_conv.is_owned = ptr_is_owned(a);
47419         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47420         a_conv.is_owned = false;
47421         LDKPaymentParameters b_conv;
47422         b_conv.inner = untag_ptr(b);
47423         b_conv.is_owned = ptr_is_owned(b);
47424         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47425         b_conv.is_owned = false;
47426         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
47427         return ret_conv;
47428 }
47429
47430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
47431         LDKPaymentParameters obj_conv;
47432         obj_conv.inner = untag_ptr(obj);
47433         obj_conv.is_owned = ptr_is_owned(obj);
47434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47435         obj_conv.is_owned = false;
47436         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
47437         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47438         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47439         CVec_u8Z_free(ret_var);
47440         return ret_arr;
47441 }
47442
47443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47444         LDKu8slice ser_ref;
47445         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47446         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47447         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
47448         *ret_conv = PaymentParameters_read(ser_ref);
47449         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47450         return tag_ptr(ret_conv, true);
47451 }
47452
47453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
47454         LDKPublicKey payee_pubkey_ref;
47455         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
47456         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
47457         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
47458         int64_t ret_ref = 0;
47459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47461         return ret_ref;
47462 }
47463
47464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
47465         LDKPublicKey payee_pubkey_ref;
47466         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
47467         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
47468         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
47469         int64_t ret_ref = 0;
47470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47472         return ret_ref;
47473 }
47474
47475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47476         LDKRouteHint this_obj_conv;
47477         this_obj_conv.inner = untag_ptr(this_obj);
47478         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47480         RouteHint_free(this_obj_conv);
47481 }
47482
47483 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47484         LDKRouteHint this_ptr_conv;
47485         this_ptr_conv.inner = untag_ptr(this_ptr);
47486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47488         this_ptr_conv.is_owned = false;
47489         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
47490         int64_tArray ret_arr = NULL;
47491         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47492         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47493         for (size_t o = 0; o < ret_var.datalen; o++) {
47494                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
47495                 int64_t ret_conv_14_ref = 0;
47496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47497                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
47498                 ret_arr_ptr[o] = ret_conv_14_ref;
47499         }
47500         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47501         FREE(ret_var.data);
47502         return ret_arr;
47503 }
47504
47505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47506         LDKRouteHint this_ptr_conv;
47507         this_ptr_conv.inner = untag_ptr(this_ptr);
47508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47510         this_ptr_conv.is_owned = false;
47511         LDKCVec_RouteHintHopZ val_constr;
47512         val_constr.datalen = (*env)->GetArrayLength(env, val);
47513         if (val_constr.datalen > 0)
47514                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
47515         else
47516                 val_constr.data = NULL;
47517         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47518         for (size_t o = 0; o < val_constr.datalen; o++) {
47519                 int64_t val_conv_14 = val_vals[o];
47520                 LDKRouteHintHop val_conv_14_conv;
47521                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
47522                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
47523                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
47524                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
47525                 val_constr.data[o] = val_conv_14_conv;
47526         }
47527         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47528         RouteHint_set_a(&this_ptr_conv, val_constr);
47529 }
47530
47531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
47532         LDKCVec_RouteHintHopZ a_arg_constr;
47533         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
47534         if (a_arg_constr.datalen > 0)
47535                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
47536         else
47537                 a_arg_constr.data = NULL;
47538         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
47539         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
47540                 int64_t a_arg_conv_14 = a_arg_vals[o];
47541                 LDKRouteHintHop a_arg_conv_14_conv;
47542                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
47543                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
47544                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
47545                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
47546                 a_arg_constr.data[o] = a_arg_conv_14_conv;
47547         }
47548         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
47549         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
47550         int64_t ret_ref = 0;
47551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47553         return ret_ref;
47554 }
47555
47556 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
47557         LDKRouteHint ret_var = RouteHint_clone(arg);
47558         int64_t ret_ref = 0;
47559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47561         return ret_ref;
47562 }
47563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47564         LDKRouteHint arg_conv;
47565         arg_conv.inner = untag_ptr(arg);
47566         arg_conv.is_owned = ptr_is_owned(arg);
47567         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47568         arg_conv.is_owned = false;
47569         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
47570         return ret_conv;
47571 }
47572
47573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47574         LDKRouteHint orig_conv;
47575         orig_conv.inner = untag_ptr(orig);
47576         orig_conv.is_owned = ptr_is_owned(orig);
47577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47578         orig_conv.is_owned = false;
47579         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
47580         int64_t ret_ref = 0;
47581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47583         return ret_ref;
47584 }
47585
47586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
47587         LDKRouteHint o_conv;
47588         o_conv.inner = untag_ptr(o);
47589         o_conv.is_owned = ptr_is_owned(o);
47590         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47591         o_conv.is_owned = false;
47592         int64_t ret_conv = RouteHint_hash(&o_conv);
47593         return ret_conv;
47594 }
47595
47596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47597         LDKRouteHint a_conv;
47598         a_conv.inner = untag_ptr(a);
47599         a_conv.is_owned = ptr_is_owned(a);
47600         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47601         a_conv.is_owned = false;
47602         LDKRouteHint b_conv;
47603         b_conv.inner = untag_ptr(b);
47604         b_conv.is_owned = ptr_is_owned(b);
47605         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47606         b_conv.is_owned = false;
47607         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
47608         return ret_conv;
47609 }
47610
47611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
47612         LDKRouteHint obj_conv;
47613         obj_conv.inner = untag_ptr(obj);
47614         obj_conv.is_owned = ptr_is_owned(obj);
47615         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47616         obj_conv.is_owned = false;
47617         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
47618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47620         CVec_u8Z_free(ret_var);
47621         return ret_arr;
47622 }
47623
47624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47625         LDKu8slice ser_ref;
47626         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47627         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47628         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
47629         *ret_conv = RouteHint_read(ser_ref);
47630         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47631         return tag_ptr(ret_conv, true);
47632 }
47633
47634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47635         LDKRouteHintHop this_obj_conv;
47636         this_obj_conv.inner = untag_ptr(this_obj);
47637         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47639         RouteHintHop_free(this_obj_conv);
47640 }
47641
47642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
47643         LDKRouteHintHop this_ptr_conv;
47644         this_ptr_conv.inner = untag_ptr(this_ptr);
47645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47647         this_ptr_conv.is_owned = false;
47648         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
47650         return ret_arr;
47651 }
47652
47653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47654         LDKRouteHintHop this_ptr_conv;
47655         this_ptr_conv.inner = untag_ptr(this_ptr);
47656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47658         this_ptr_conv.is_owned = false;
47659         LDKPublicKey val_ref;
47660         CHECK((*env)->GetArrayLength(env, val) == 33);
47661         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47662         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
47663 }
47664
47665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
47666         LDKRouteHintHop this_ptr_conv;
47667         this_ptr_conv.inner = untag_ptr(this_ptr);
47668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47670         this_ptr_conv.is_owned = false;
47671         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
47672         return ret_conv;
47673 }
47674
47675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47676         LDKRouteHintHop this_ptr_conv;
47677         this_ptr_conv.inner = untag_ptr(this_ptr);
47678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47680         this_ptr_conv.is_owned = false;
47681         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
47682 }
47683
47684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
47685         LDKRouteHintHop this_ptr_conv;
47686         this_ptr_conv.inner = untag_ptr(this_ptr);
47687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47689         this_ptr_conv.is_owned = false;
47690         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
47691         int64_t ret_ref = 0;
47692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47694         return ret_ref;
47695 }
47696
47697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47698         LDKRouteHintHop this_ptr_conv;
47699         this_ptr_conv.inner = untag_ptr(this_ptr);
47700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47702         this_ptr_conv.is_owned = false;
47703         LDKRoutingFees val_conv;
47704         val_conv.inner = untag_ptr(val);
47705         val_conv.is_owned = ptr_is_owned(val);
47706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47707         val_conv = RoutingFees_clone(&val_conv);
47708         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
47709 }
47710
47711 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47712         LDKRouteHintHop this_ptr_conv;
47713         this_ptr_conv.inner = untag_ptr(this_ptr);
47714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47716         this_ptr_conv.is_owned = false;
47717         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
47718         return ret_conv;
47719 }
47720
47721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47722         LDKRouteHintHop this_ptr_conv;
47723         this_ptr_conv.inner = untag_ptr(this_ptr);
47724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47726         this_ptr_conv.is_owned = false;
47727         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
47728 }
47729
47730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47731         LDKRouteHintHop this_ptr_conv;
47732         this_ptr_conv.inner = untag_ptr(this_ptr);
47733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47735         this_ptr_conv.is_owned = false;
47736         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47737         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
47738         int64_t ret_ref = tag_ptr(ret_copy, true);
47739         return ret_ref;
47740 }
47741
47742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47743         LDKRouteHintHop this_ptr_conv;
47744         this_ptr_conv.inner = untag_ptr(this_ptr);
47745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47747         this_ptr_conv.is_owned = false;
47748         void* val_ptr = untag_ptr(val);
47749         CHECK_ACCESS(val_ptr);
47750         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47751         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47752         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
47753 }
47754
47755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47756         LDKRouteHintHop this_ptr_conv;
47757         this_ptr_conv.inner = untag_ptr(this_ptr);
47758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47760         this_ptr_conv.is_owned = false;
47761         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47762         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
47763         int64_t ret_ref = tag_ptr(ret_copy, true);
47764         return ret_ref;
47765 }
47766
47767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47768         LDKRouteHintHop this_ptr_conv;
47769         this_ptr_conv.inner = untag_ptr(this_ptr);
47770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47772         this_ptr_conv.is_owned = false;
47773         void* val_ptr = untag_ptr(val);
47774         CHECK_ACCESS(val_ptr);
47775         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47776         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47777         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
47778 }
47779
47780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *env, jclass clz, int8_tArray src_node_id_arg, int64_t short_channel_id_arg, int64_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg) {
47781         LDKPublicKey src_node_id_arg_ref;
47782         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
47783         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
47784         LDKRoutingFees fees_arg_conv;
47785         fees_arg_conv.inner = untag_ptr(fees_arg);
47786         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
47787         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
47788         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
47789         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
47790         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
47791         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
47792         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
47793         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
47794         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
47795         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
47796         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
47797         LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv);
47798         int64_t ret_ref = 0;
47799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47801         return ret_ref;
47802 }
47803
47804 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
47805         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
47806         int64_t ret_ref = 0;
47807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47809         return ret_ref;
47810 }
47811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47812         LDKRouteHintHop arg_conv;
47813         arg_conv.inner = untag_ptr(arg);
47814         arg_conv.is_owned = ptr_is_owned(arg);
47815         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47816         arg_conv.is_owned = false;
47817         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
47818         return ret_conv;
47819 }
47820
47821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47822         LDKRouteHintHop orig_conv;
47823         orig_conv.inner = untag_ptr(orig);
47824         orig_conv.is_owned = ptr_is_owned(orig);
47825         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47826         orig_conv.is_owned = false;
47827         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
47828         int64_t ret_ref = 0;
47829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47830         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47831         return ret_ref;
47832 }
47833
47834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
47835         LDKRouteHintHop o_conv;
47836         o_conv.inner = untag_ptr(o);
47837         o_conv.is_owned = ptr_is_owned(o);
47838         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47839         o_conv.is_owned = false;
47840         int64_t ret_conv = RouteHintHop_hash(&o_conv);
47841         return ret_conv;
47842 }
47843
47844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47845         LDKRouteHintHop a_conv;
47846         a_conv.inner = untag_ptr(a);
47847         a_conv.is_owned = ptr_is_owned(a);
47848         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47849         a_conv.is_owned = false;
47850         LDKRouteHintHop b_conv;
47851         b_conv.inner = untag_ptr(b);
47852         b_conv.is_owned = ptr_is_owned(b);
47853         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47854         b_conv.is_owned = false;
47855         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
47856         return ret_conv;
47857 }
47858
47859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
47860         LDKRouteHintHop obj_conv;
47861         obj_conv.inner = untag_ptr(obj);
47862         obj_conv.is_owned = ptr_is_owned(obj);
47863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47864         obj_conv.is_owned = false;
47865         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
47866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47868         CVec_u8Z_free(ret_var);
47869         return ret_arr;
47870 }
47871
47872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47873         LDKu8slice ser_ref;
47874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47876         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
47877         *ret_conv = RouteHintHop_read(ser_ref);
47878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47879         return tag_ptr(ret_conv, true);
47880 }
47881
47882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
47883         LDKPublicKey our_node_pubkey_ref;
47884         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
47885         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
47886         LDKRouteParameters route_params_conv;
47887         route_params_conv.inner = untag_ptr(route_params);
47888         route_params_conv.is_owned = ptr_is_owned(route_params);
47889         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
47890         route_params_conv.is_owned = false;
47891         LDKNetworkGraph network_graph_conv;
47892         network_graph_conv.inner = untag_ptr(network_graph);
47893         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47894         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47895         network_graph_conv.is_owned = false;
47896         LDKCVec_ChannelDetailsZ first_hops_constr;
47897         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
47898         if (first_hops != NULL) {
47899                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
47900                 if (first_hops_constr.datalen > 0)
47901                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
47902                 else
47903                         first_hops_constr.data = NULL;
47904                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
47905                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
47906                         int64_t first_hops_conv_16 = first_hops_vals[q];
47907                         LDKChannelDetails first_hops_conv_16_conv;
47908                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
47909                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
47910                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
47911                         first_hops_conv_16_conv.is_owned = false;
47912                         first_hops_constr.data[q] = first_hops_conv_16_conv;
47913                 }
47914                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
47915                 first_hops_ptr = &first_hops_constr;
47916         }
47917         void* logger_ptr = untag_ptr(logger);
47918         CHECK_ACCESS(logger_ptr);
47919         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47920         if (logger_conv.free == LDKLogger_JCalls_free) {
47921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47922                 LDKLogger_JCalls_cloned(&logger_conv);
47923         }
47924         void* scorer_ptr = untag_ptr(scorer);
47925         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
47926         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
47927         unsigned char random_seed_bytes_arr[32];
47928         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47929         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
47930         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
47931         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
47932         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
47933         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
47934         return tag_ptr(ret_conv, true);
47935 }
47936
47937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
47938         LDKPublicKey our_node_pubkey_ref;
47939         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
47940         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
47941         LDKCVec_PublicKeyZ hops_constr;
47942         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
47943         if (hops_constr.datalen > 0)
47944                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
47945         else
47946                 hops_constr.data = NULL;
47947         for (size_t i = 0; i < hops_constr.datalen; i++) {
47948                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
47949                 LDKPublicKey hops_conv_8_ref;
47950                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
47951                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
47952                 hops_constr.data[i] = hops_conv_8_ref;
47953         }
47954         LDKRouteParameters route_params_conv;
47955         route_params_conv.inner = untag_ptr(route_params);
47956         route_params_conv.is_owned = ptr_is_owned(route_params);
47957         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
47958         route_params_conv.is_owned = false;
47959         LDKNetworkGraph network_graph_conv;
47960         network_graph_conv.inner = untag_ptr(network_graph);
47961         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47962         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47963         network_graph_conv.is_owned = false;
47964         void* logger_ptr = untag_ptr(logger);
47965         CHECK_ACCESS(logger_ptr);
47966         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47967         if (logger_conv.free == LDKLogger_JCalls_free) {
47968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47969                 LDKLogger_JCalls_cloned(&logger_conv);
47970         }
47971         unsigned char random_seed_bytes_arr[32];
47972         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47973         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
47974         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
47975         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
47976         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
47977         return tag_ptr(ret_conv, true);
47978 }
47979
47980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47981         if (!ptr_is_owned(this_ptr)) return;
47982         void* this_ptr_ptr = untag_ptr(this_ptr);
47983         CHECK_ACCESS(this_ptr_ptr);
47984         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
47985         FREE(untag_ptr(this_ptr));
47986         Score_free(this_ptr_conv);
47987 }
47988
47989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47990         if (!ptr_is_owned(this_ptr)) return;
47991         void* this_ptr_ptr = untag_ptr(this_ptr);
47992         CHECK_ACCESS(this_ptr_ptr);
47993         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
47994         FREE(untag_ptr(this_ptr));
47995         LockableScore_free(this_ptr_conv);
47996 }
47997
47998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47999         if (!ptr_is_owned(this_ptr)) return;
48000         void* this_ptr_ptr = untag_ptr(this_ptr);
48001         CHECK_ACCESS(this_ptr_ptr);
48002         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
48003         FREE(untag_ptr(this_ptr));
48004         WriteableScore_free(this_ptr_conv);
48005 }
48006
48007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48008         LDKMultiThreadedLockableScore this_obj_conv;
48009         this_obj_conv.inner = untag_ptr(this_obj);
48010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48012         MultiThreadedLockableScore_free(this_obj_conv);
48013 }
48014
48015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48016         LDKMultiThreadedScoreLock this_obj_conv;
48017         this_obj_conv.inner = untag_ptr(this_obj);
48018         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48020         MultiThreadedScoreLock_free(this_obj_conv);
48021 }
48022
48023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48024         LDKMultiThreadedScoreLock this_arg_conv;
48025         this_arg_conv.inner = untag_ptr(this_arg);
48026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48028         this_arg_conv.is_owned = false;
48029         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48030         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
48031         return tag_ptr(ret_ret, true);
48032 }
48033
48034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
48035         LDKMultiThreadedScoreLock obj_conv;
48036         obj_conv.inner = untag_ptr(obj);
48037         obj_conv.is_owned = ptr_is_owned(obj);
48038         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48039         obj_conv.is_owned = false;
48040         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
48041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48043         CVec_u8Z_free(ret_var);
48044         return ret_arr;
48045 }
48046
48047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
48048         LDKMultiThreadedLockableScore this_arg_conv;
48049         this_arg_conv.inner = untag_ptr(this_arg);
48050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48052         this_arg_conv.is_owned = false;
48053         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
48054         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
48055         return tag_ptr(ret_ret, true);
48056 }
48057
48058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
48059         LDKMultiThreadedLockableScore obj_conv;
48060         obj_conv.inner = untag_ptr(obj);
48061         obj_conv.is_owned = ptr_is_owned(obj);
48062         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48063         obj_conv.is_owned = false;
48064         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
48065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48067         CVec_u8Z_free(ret_var);
48068         return ret_arr;
48069 }
48070
48071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
48072         LDKMultiThreadedLockableScore this_arg_conv;
48073         this_arg_conv.inner = untag_ptr(this_arg);
48074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48076         this_arg_conv.is_owned = false;
48077         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
48078         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
48079         return tag_ptr(ret_ret, true);
48080 }
48081
48082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
48083         void* score_ptr = untag_ptr(score);
48084         CHECK_ACCESS(score_ptr);
48085         LDKScore score_conv = *(LDKScore*)(score_ptr);
48086         if (score_conv.free == LDKScore_JCalls_free) {
48087                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48088                 LDKScore_JCalls_cloned(&score_conv);
48089         }
48090         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
48091         int64_t ret_ref = 0;
48092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48094         return ret_ref;
48095 }
48096
48097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48098         LDKChannelUsage this_obj_conv;
48099         this_obj_conv.inner = untag_ptr(this_obj);
48100         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48102         ChannelUsage_free(this_obj_conv);
48103 }
48104
48105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48106         LDKChannelUsage this_ptr_conv;
48107         this_ptr_conv.inner = untag_ptr(this_ptr);
48108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48110         this_ptr_conv.is_owned = false;
48111         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
48112         return ret_conv;
48113 }
48114
48115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48116         LDKChannelUsage this_ptr_conv;
48117         this_ptr_conv.inner = untag_ptr(this_ptr);
48118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48120         this_ptr_conv.is_owned = false;
48121         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
48122 }
48123
48124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48125         LDKChannelUsage this_ptr_conv;
48126         this_ptr_conv.inner = untag_ptr(this_ptr);
48127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48129         this_ptr_conv.is_owned = false;
48130         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
48131         return ret_conv;
48132 }
48133
48134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48135         LDKChannelUsage this_ptr_conv;
48136         this_ptr_conv.inner = untag_ptr(this_ptr);
48137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48139         this_ptr_conv.is_owned = false;
48140         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
48141 }
48142
48143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
48144         LDKChannelUsage this_ptr_conv;
48145         this_ptr_conv.inner = untag_ptr(this_ptr);
48146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48148         this_ptr_conv.is_owned = false;
48149         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48150         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
48151         int64_t ret_ref = tag_ptr(ret_copy, true);
48152         return ret_ref;
48153 }
48154
48155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48156         LDKChannelUsage this_ptr_conv;
48157         this_ptr_conv.inner = untag_ptr(this_ptr);
48158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48160         this_ptr_conv.is_owned = false;
48161         void* val_ptr = untag_ptr(val);
48162         CHECK_ACCESS(val_ptr);
48163         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
48164         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
48165         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
48166 }
48167
48168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
48169         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
48170         CHECK_ACCESS(effective_capacity_arg_ptr);
48171         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
48172         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
48173         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
48174         int64_t ret_ref = 0;
48175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48177         return ret_ref;
48178 }
48179
48180 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
48181         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
48182         int64_t ret_ref = 0;
48183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48185         return ret_ref;
48186 }
48187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48188         LDKChannelUsage arg_conv;
48189         arg_conv.inner = untag_ptr(arg);
48190         arg_conv.is_owned = ptr_is_owned(arg);
48191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48192         arg_conv.is_owned = false;
48193         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
48194         return ret_conv;
48195 }
48196
48197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48198         LDKChannelUsage orig_conv;
48199         orig_conv.inner = untag_ptr(orig);
48200         orig_conv.is_owned = ptr_is_owned(orig);
48201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48202         orig_conv.is_owned = false;
48203         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
48204         int64_t ret_ref = 0;
48205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48207         return ret_ref;
48208 }
48209
48210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48211         LDKFixedPenaltyScorer this_obj_conv;
48212         this_obj_conv.inner = untag_ptr(this_obj);
48213         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48215         FixedPenaltyScorer_free(this_obj_conv);
48216 }
48217
48218 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
48219         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
48220         int64_t ret_ref = 0;
48221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48223         return ret_ref;
48224 }
48225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48226         LDKFixedPenaltyScorer arg_conv;
48227         arg_conv.inner = untag_ptr(arg);
48228         arg_conv.is_owned = ptr_is_owned(arg);
48229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48230         arg_conv.is_owned = false;
48231         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
48232         return ret_conv;
48233 }
48234
48235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48236         LDKFixedPenaltyScorer orig_conv;
48237         orig_conv.inner = untag_ptr(orig);
48238         orig_conv.is_owned = ptr_is_owned(orig);
48239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48240         orig_conv.is_owned = false;
48241         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
48242         int64_t ret_ref = 0;
48243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48245         return ret_ref;
48246 }
48247
48248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
48249         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
48250         int64_t ret_ref = 0;
48251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48253         return ret_ref;
48254 }
48255
48256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48257         LDKFixedPenaltyScorer this_arg_conv;
48258         this_arg_conv.inner = untag_ptr(this_arg);
48259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48261         this_arg_conv.is_owned = false;
48262         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48263         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
48264         return tag_ptr(ret_ret, true);
48265 }
48266
48267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
48268         LDKFixedPenaltyScorer obj_conv;
48269         obj_conv.inner = untag_ptr(obj);
48270         obj_conv.is_owned = ptr_is_owned(obj);
48271         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48272         obj_conv.is_owned = false;
48273         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
48274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48276         CVec_u8Z_free(ret_var);
48277         return ret_arr;
48278 }
48279
48280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
48281         LDKu8slice ser_ref;
48282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48284         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
48285         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
48286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48287         return tag_ptr(ret_conv, true);
48288 }
48289
48290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48291         LDKProbabilisticScorer this_obj_conv;
48292         this_obj_conv.inner = untag_ptr(this_obj);
48293         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48295         ProbabilisticScorer_free(this_obj_conv);
48296 }
48297
48298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48299         LDKProbabilisticScoringParameters this_obj_conv;
48300         this_obj_conv.inner = untag_ptr(this_obj);
48301         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48303         ProbabilisticScoringParameters_free(this_obj_conv);
48304 }
48305
48306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48307         LDKProbabilisticScoringParameters this_ptr_conv;
48308         this_ptr_conv.inner = untag_ptr(this_ptr);
48309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48311         this_ptr_conv.is_owned = false;
48312         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
48313         return ret_conv;
48314 }
48315
48316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48317         LDKProbabilisticScoringParameters this_ptr_conv;
48318         this_ptr_conv.inner = untag_ptr(this_ptr);
48319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48321         this_ptr_conv.is_owned = false;
48322         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
48323 }
48324
48325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48326         LDKProbabilisticScoringParameters this_ptr_conv;
48327         this_ptr_conv.inner = untag_ptr(this_ptr);
48328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48330         this_ptr_conv.is_owned = false;
48331         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
48332         return ret_conv;
48333 }
48334
48335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48336         LDKProbabilisticScoringParameters this_ptr_conv;
48337         this_ptr_conv.inner = untag_ptr(this_ptr);
48338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48340         this_ptr_conv.is_owned = false;
48341         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48342 }
48343
48344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48345         LDKProbabilisticScoringParameters this_ptr_conv;
48346         this_ptr_conv.inner = untag_ptr(this_ptr);
48347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48349         this_ptr_conv.is_owned = false;
48350         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
48351         return ret_conv;
48352 }
48353
48354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48355         LDKProbabilisticScoringParameters this_ptr_conv;
48356         this_ptr_conv.inner = untag_ptr(this_ptr);
48357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48359         this_ptr_conv.is_owned = false;
48360         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
48361 }
48362
48363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
48364         LDKProbabilisticScoringParameters this_ptr_conv;
48365         this_ptr_conv.inner = untag_ptr(this_ptr);
48366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48368         this_ptr_conv.is_owned = false;
48369         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
48370         return ret_conv;
48371 }
48372
48373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48374         LDKProbabilisticScoringParameters this_ptr_conv;
48375         this_ptr_conv.inner = untag_ptr(this_ptr);
48376         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48378         this_ptr_conv.is_owned = false;
48379         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
48380 }
48381
48382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48383         LDKProbabilisticScoringParameters this_ptr_conv;
48384         this_ptr_conv.inner = untag_ptr(this_ptr);
48385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48387         this_ptr_conv.is_owned = false;
48388         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
48389         return ret_conv;
48390 }
48391
48392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48393         LDKProbabilisticScoringParameters this_ptr_conv;
48394         this_ptr_conv.inner = untag_ptr(this_ptr);
48395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48397         this_ptr_conv.is_owned = false;
48398         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48399 }
48400
48401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48402         LDKProbabilisticScoringParameters this_ptr_conv;
48403         this_ptr_conv.inner = untag_ptr(this_ptr);
48404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48406         this_ptr_conv.is_owned = false;
48407         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
48408         return ret_conv;
48409 }
48410
48411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48412         LDKProbabilisticScoringParameters this_ptr_conv;
48413         this_ptr_conv.inner = untag_ptr(this_ptr);
48414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48416         this_ptr_conv.is_owned = false;
48417         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
48418 }
48419
48420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48421         LDKProbabilisticScoringParameters this_ptr_conv;
48422         this_ptr_conv.inner = untag_ptr(this_ptr);
48423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48425         this_ptr_conv.is_owned = false;
48426         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
48427         return ret_conv;
48428 }
48429
48430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48431         LDKProbabilisticScoringParameters this_ptr_conv;
48432         this_ptr_conv.inner = untag_ptr(this_ptr);
48433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48435         this_ptr_conv.is_owned = false;
48436         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48437 }
48438
48439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
48440         LDKProbabilisticScoringParameters this_ptr_conv;
48441         this_ptr_conv.inner = untag_ptr(this_ptr);
48442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48444         this_ptr_conv.is_owned = false;
48445         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
48446         return ret_conv;
48447 }
48448
48449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48450         LDKProbabilisticScoringParameters this_ptr_conv;
48451         this_ptr_conv.inner = untag_ptr(this_ptr);
48452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48454         this_ptr_conv.is_owned = false;
48455         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
48456 }
48457
48458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48459         LDKProbabilisticScoringParameters this_ptr_conv;
48460         this_ptr_conv.inner = untag_ptr(this_ptr);
48461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48463         this_ptr_conv.is_owned = false;
48464         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
48465         return ret_conv;
48466 }
48467
48468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48469         LDKProbabilisticScoringParameters this_ptr_conv;
48470         this_ptr_conv.inner = untag_ptr(this_ptr);
48471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48473         this_ptr_conv.is_owned = false;
48474         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
48475 }
48476
48477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48478         LDKProbabilisticScoringParameters this_ptr_conv;
48479         this_ptr_conv.inner = untag_ptr(this_ptr);
48480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48482         this_ptr_conv.is_owned = false;
48483         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
48484         return ret_conv;
48485 }
48486
48487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48488         LDKProbabilisticScoringParameters this_ptr_conv;
48489         this_ptr_conv.inner = untag_ptr(this_ptr);
48490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48492         this_ptr_conv.is_owned = false;
48493         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
48494 }
48495
48496 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
48497         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
48498         int64_t ret_ref = 0;
48499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48500         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48501         return ret_ref;
48502 }
48503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48504         LDKProbabilisticScoringParameters arg_conv;
48505         arg_conv.inner = untag_ptr(arg);
48506         arg_conv.is_owned = ptr_is_owned(arg);
48507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48508         arg_conv.is_owned = false;
48509         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
48510         return ret_conv;
48511 }
48512
48513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48514         LDKProbabilisticScoringParameters orig_conv;
48515         orig_conv.inner = untag_ptr(orig);
48516         orig_conv.is_owned = ptr_is_owned(orig);
48517         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48518         orig_conv.is_owned = false;
48519         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
48520         int64_t ret_ref = 0;
48521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48523         return ret_ref;
48524 }
48525
48526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
48527         LDKProbabilisticScoringParameters params_conv;
48528         params_conv.inner = untag_ptr(params);
48529         params_conv.is_owned = ptr_is_owned(params);
48530         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
48531         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
48532         LDKNetworkGraph network_graph_conv;
48533         network_graph_conv.inner = untag_ptr(network_graph);
48534         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48535         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48536         network_graph_conv.is_owned = false;
48537         void* logger_ptr = untag_ptr(logger);
48538         CHECK_ACCESS(logger_ptr);
48539         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48540         if (logger_conv.free == LDKLogger_JCalls_free) {
48541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48542                 LDKLogger_JCalls_cloned(&logger_conv);
48543         }
48544         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
48545         int64_t ret_ref = 0;
48546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48548         return ret_ref;
48549 }
48550
48551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
48552         LDKProbabilisticScorer this_arg_conv;
48553         this_arg_conv.inner = untag_ptr(this_arg);
48554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48556         this_arg_conv.is_owned = false;
48557         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
48558 }
48559
48560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
48561         LDKProbabilisticScorer this_arg_conv;
48562         this_arg_conv.inner = untag_ptr(this_arg);
48563         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48565         this_arg_conv.is_owned = false;
48566         LDKNodeId target_conv;
48567         target_conv.inner = untag_ptr(target);
48568         target_conv.is_owned = ptr_is_owned(target);
48569         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
48570         target_conv.is_owned = false;
48571         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
48572         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
48573         int64_t ret_ref = tag_ptr(ret_copy, true);
48574         return ret_ref;
48575 }
48576
48577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48578         LDKProbabilisticScorer this_arg_conv;
48579         this_arg_conv.inner = untag_ptr(this_arg);
48580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48582         this_arg_conv.is_owned = false;
48583         LDKNodeId node_id_conv;
48584         node_id_conv.inner = untag_ptr(node_id);
48585         node_id_conv.is_owned = ptr_is_owned(node_id);
48586         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48587         node_id_conv.is_owned = false;
48588         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
48589 }
48590
48591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48592         LDKProbabilisticScorer this_arg_conv;
48593         this_arg_conv.inner = untag_ptr(this_arg);
48594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48596         this_arg_conv.is_owned = false;
48597         LDKNodeId node_id_conv;
48598         node_id_conv.inner = untag_ptr(node_id);
48599         node_id_conv.is_owned = ptr_is_owned(node_id);
48600         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48601         node_id_conv.is_owned = false;
48602         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
48603 }
48604
48605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1set_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id, int64_t penalty) {
48606         LDKProbabilisticScorer this_arg_conv;
48607         this_arg_conv.inner = untag_ptr(this_arg);
48608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48610         this_arg_conv.is_owned = false;
48611         LDKNodeId node_id_conv;
48612         node_id_conv.inner = untag_ptr(node_id);
48613         node_id_conv.is_owned = ptr_is_owned(node_id);
48614         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48615         node_id_conv.is_owned = false;
48616         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
48617 }
48618
48619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48620         LDKProbabilisticScorer this_arg_conv;
48621         this_arg_conv.inner = untag_ptr(this_arg);
48622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48624         this_arg_conv.is_owned = false;
48625         LDKNodeId node_id_conv;
48626         node_id_conv.inner = untag_ptr(node_id);
48627         node_id_conv.is_owned = ptr_is_owned(node_id);
48628         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48629         node_id_conv.is_owned = false;
48630         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
48631 }
48632
48633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
48634         LDKProbabilisticScorer this_arg_conv;
48635         this_arg_conv.inner = untag_ptr(this_arg);
48636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48638         this_arg_conv.is_owned = false;
48639         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
48640 }
48641
48642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
48643         LDKProbabilisticScoringParameters this_arg_conv;
48644         this_arg_conv.inner = untag_ptr(this_arg);
48645         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48647         this_arg_conv.is_owned = false;
48648         LDKCVec_NodeIdZ node_ids_constr;
48649         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
48650         if (node_ids_constr.datalen > 0)
48651                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
48652         else
48653                 node_ids_constr.data = NULL;
48654         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
48655         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
48656                 int64_t node_ids_conv_8 = node_ids_vals[i];
48657                 LDKNodeId node_ids_conv_8_conv;
48658                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
48659                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
48660                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
48661                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
48662                 node_ids_constr.data[i] = node_ids_conv_8_conv;
48663         }
48664         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
48665         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
48666 }
48667
48668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
48669         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
48670         int64_t ret_ref = 0;
48671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48673         return ret_ref;
48674 }
48675
48676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48677         LDKProbabilisticScorer this_arg_conv;
48678         this_arg_conv.inner = untag_ptr(this_arg);
48679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48681         this_arg_conv.is_owned = false;
48682         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48683         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
48684         return tag_ptr(ret_ret, true);
48685 }
48686
48687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
48688         LDKProbabilisticScorer obj_conv;
48689         obj_conv.inner = untag_ptr(obj);
48690         obj_conv.is_owned = ptr_is_owned(obj);
48691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48692         obj_conv.is_owned = false;
48693         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
48694         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48695         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48696         CVec_u8Z_free(ret_var);
48697         return ret_arr;
48698 }
48699
48700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
48701         LDKu8slice ser_ref;
48702         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48703         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48704         LDKProbabilisticScoringParameters arg_a_conv;
48705         arg_a_conv.inner = untag_ptr(arg_a);
48706         arg_a_conv.is_owned = ptr_is_owned(arg_a);
48707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
48708         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
48709         LDKNetworkGraph arg_b_conv;
48710         arg_b_conv.inner = untag_ptr(arg_b);
48711         arg_b_conv.is_owned = ptr_is_owned(arg_b);
48712         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
48713         arg_b_conv.is_owned = false;
48714         void* arg_c_ptr = untag_ptr(arg_c);
48715         CHECK_ACCESS(arg_c_ptr);
48716         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
48717         if (arg_c_conv.free == LDKLogger_JCalls_free) {
48718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48719                 LDKLogger_JCalls_cloned(&arg_c_conv);
48720         }
48721         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
48722         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
48723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48724         return tag_ptr(ret_conv, true);
48725 }
48726
48727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48728         LDKBlindedRoute this_obj_conv;
48729         this_obj_conv.inner = untag_ptr(this_obj);
48730         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48732         BlindedRoute_free(this_obj_conv);
48733 }
48734
48735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48736         LDKBlindedHop this_obj_conv;
48737         this_obj_conv.inner = untag_ptr(this_obj);
48738         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48740         BlindedHop_free(this_obj_conv);
48741 }
48742
48743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t keys_manager) {
48744         LDKCVec_PublicKeyZ node_pks_constr;
48745         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
48746         if (node_pks_constr.datalen > 0)
48747                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
48748         else
48749                 node_pks_constr.data = NULL;
48750         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
48751                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
48752                 LDKPublicKey node_pks_conv_8_ref;
48753                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
48754                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
48755                 node_pks_constr.data[i] = node_pks_conv_8_ref;
48756         }
48757         void* keys_manager_ptr = untag_ptr(keys_manager);
48758         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
48759         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
48760         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
48761         *ret_conv = BlindedRoute_new(node_pks_constr, keys_manager_conv);
48762         return tag_ptr(ret_conv, true);
48763 }
48764
48765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1write(JNIEnv *env, jclass clz, int64_t obj) {
48766         LDKBlindedRoute obj_conv;
48767         obj_conv.inner = untag_ptr(obj);
48768         obj_conv.is_owned = ptr_is_owned(obj);
48769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48770         obj_conv.is_owned = false;
48771         LDKCVec_u8Z ret_var = BlindedRoute_write(&obj_conv);
48772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48774         CVec_u8Z_free(ret_var);
48775         return ret_arr;
48776 }
48777
48778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48779         LDKu8slice ser_ref;
48780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48782         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
48783         *ret_conv = BlindedRoute_read(ser_ref);
48784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48785         return tag_ptr(ret_conv, true);
48786 }
48787
48788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
48789         LDKBlindedHop obj_conv;
48790         obj_conv.inner = untag_ptr(obj);
48791         obj_conv.is_owned = ptr_is_owned(obj);
48792         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48793         obj_conv.is_owned = false;
48794         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
48795         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48796         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48797         CVec_u8Z_free(ret_var);
48798         return ret_arr;
48799 }
48800
48801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48802         LDKu8slice ser_ref;
48803         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48804         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48805         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
48806         *ret_conv = BlindedHop_read(ser_ref);
48807         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48808         return tag_ptr(ret_conv, true);
48809 }
48810
48811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48812         LDKOnionMessenger this_obj_conv;
48813         this_obj_conv.inner = untag_ptr(this_obj);
48814         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48816         OnionMessenger_free(this_obj_conv);
48817 }
48818
48819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48820         if (!ptr_is_owned(this_ptr)) return;
48821         void* this_ptr_ptr = untag_ptr(this_ptr);
48822         CHECK_ACCESS(this_ptr_ptr);
48823         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
48824         FREE(untag_ptr(this_ptr));
48825         Destination_free(this_ptr_conv);
48826 }
48827
48828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
48829         LDKPublicKey a_ref;
48830         CHECK((*env)->GetArrayLength(env, a) == 33);
48831         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
48832         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
48833         *ret_copy = Destination_node(a_ref);
48834         int64_t ret_ref = tag_ptr(ret_copy, true);
48835         return ret_ref;
48836 }
48837
48838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1route(JNIEnv *env, jclass clz, int64_t a) {
48839         LDKBlindedRoute a_conv;
48840         a_conv.inner = untag_ptr(a);
48841         a_conv.is_owned = ptr_is_owned(a);
48842         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48843         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
48844         
48845         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
48846         *ret_copy = Destination_blinded_route(a_conv);
48847         int64_t ret_ref = tag_ptr(ret_copy, true);
48848         return ret_ref;
48849 }
48850
48851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48852         if (!ptr_is_owned(this_ptr)) return;
48853         void* this_ptr_ptr = untag_ptr(this_ptr);
48854         CHECK_ACCESS(this_ptr_ptr);
48855         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
48856         FREE(untag_ptr(this_ptr));
48857         SendError_free(this_ptr_conv);
48858 }
48859
48860 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
48861         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48862         *ret_copy = SendError_clone(arg);
48863         int64_t ret_ref = tag_ptr(ret_copy, true);
48864         return ret_ref;
48865 }
48866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48867         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
48868         int64_t ret_conv = SendError_clone_ptr(arg_conv);
48869         return ret_conv;
48870 }
48871
48872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48873         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
48874         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48875         *ret_copy = SendError_clone(orig_conv);
48876         int64_t ret_ref = tag_ptr(ret_copy, true);
48877         return ret_ref;
48878 }
48879
48880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
48881         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
48882         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48883         *ret_copy = SendError_secp256k1(a_conv);
48884         int64_t ret_ref = tag_ptr(ret_copy, true);
48885         return ret_ref;
48886 }
48887
48888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
48889         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48890         *ret_copy = SendError_too_big_packet();
48891         int64_t ret_ref = tag_ptr(ret_copy, true);
48892         return ret_ref;
48893 }
48894
48895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
48896         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48897         *ret_copy = SendError_too_few_blinded_hops();
48898         int64_t ret_ref = tag_ptr(ret_copy, true);
48899         return ret_ref;
48900 }
48901
48902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
48903         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48904         *ret_copy = SendError_invalid_first_hop();
48905         int64_t ret_ref = tag_ptr(ret_copy, true);
48906         return ret_ref;
48907 }
48908
48909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
48910         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48911         *ret_copy = SendError_invalid_message();
48912         int64_t ret_ref = tag_ptr(ret_copy, true);
48913         return ret_ref;
48914 }
48915
48916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
48917         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48918         *ret_copy = SendError_buffer_full();
48919         int64_t ret_ref = tag_ptr(ret_copy, true);
48920         return ret_ref;
48921 }
48922
48923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48924         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
48925         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
48926         jboolean ret_conv = SendError_eq(a_conv, b_conv);
48927         return ret_conv;
48928 }
48929
48930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48931         if (!ptr_is_owned(this_ptr)) return;
48932         void* this_ptr_ptr = untag_ptr(this_ptr);
48933         CHECK_ACCESS(this_ptr_ptr);
48934         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
48935         FREE(untag_ptr(this_ptr));
48936         CustomOnionMessageHandler_free(this_ptr_conv);
48937 }
48938
48939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t logger, int64_t custom_handler) {
48940         void* keys_manager_ptr = untag_ptr(keys_manager);
48941         CHECK_ACCESS(keys_manager_ptr);
48942         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48943         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48944                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48945                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48946         }
48947         void* logger_ptr = untag_ptr(logger);
48948         CHECK_ACCESS(logger_ptr);
48949         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48950         if (logger_conv.free == LDKLogger_JCalls_free) {
48951                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48952                 LDKLogger_JCalls_cloned(&logger_conv);
48953         }
48954         void* custom_handler_ptr = untag_ptr(custom_handler);
48955         CHECK_ACCESS(custom_handler_ptr);
48956         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
48957         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
48958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48959                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
48960         }
48961         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv, custom_handler_conv);
48962         int64_t ret_ref = 0;
48963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48965         return ret_ref;
48966 }
48967
48968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1send_1custom_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, jobjectArray intermediate_nodes, int64_t destination, int64_t msg, int64_t reply_path) {
48969         LDKOnionMessenger this_arg_conv;
48970         this_arg_conv.inner = untag_ptr(this_arg);
48971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48973         this_arg_conv.is_owned = false;
48974         LDKCVec_PublicKeyZ intermediate_nodes_constr;
48975         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
48976         if (intermediate_nodes_constr.datalen > 0)
48977                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
48978         else
48979                 intermediate_nodes_constr.data = NULL;
48980         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
48981                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
48982                 LDKPublicKey intermediate_nodes_conv_8_ref;
48983                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
48984                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
48985                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
48986         }
48987         void* destination_ptr = untag_ptr(destination);
48988         CHECK_ACCESS(destination_ptr);
48989         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
48990         // WARNING: we may need a move here but no clone is available for LDKDestination
48991         void* msg_ptr = untag_ptr(msg);
48992         CHECK_ACCESS(msg_ptr);
48993         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
48994         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
48995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48996                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
48997         }
48998         LDKBlindedRoute reply_path_conv;
48999         reply_path_conv.inner = untag_ptr(reply_path);
49000         reply_path_conv.is_owned = ptr_is_owned(reply_path);
49001         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
49002         reply_path_conv.is_owned = false;
49003         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
49004         *ret_conv = OnionMessenger_send_custom_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, msg_conv, reply_path_conv);
49005         return tag_ptr(ret_conv, true);
49006 }
49007
49008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49009         LDKOnionMessenger this_arg_conv;
49010         this_arg_conv.inner = untag_ptr(this_arg);
49011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49013         this_arg_conv.is_owned = false;
49014         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
49015         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
49016         return tag_ptr(ret_ret, true);
49017 }
49018
49019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
49020         LDKOnionMessenger this_arg_conv;
49021         this_arg_conv.inner = untag_ptr(this_arg);
49022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49024         this_arg_conv.is_owned = false;
49025         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
49026         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
49027         return tag_ptr(ret_ret, true);
49028 }
49029
49030 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
49031         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
49032         *ret_ret = CustomOnionMessageContents_clone(arg);
49033         return tag_ptr(ret_ret, true);
49034 }
49035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49036         void* arg_ptr = untag_ptr(arg);
49037         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
49038         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
49039         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
49040         return ret_conv;
49041 }
49042
49043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49044         void* orig_ptr = untag_ptr(orig);
49045         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
49046         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
49047         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
49048         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
49049         return tag_ptr(ret_ret, true);
49050 }
49051
49052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49053         if (!ptr_is_owned(this_ptr)) return;
49054         void* this_ptr_ptr = untag_ptr(this_ptr);
49055         CHECK_ACCESS(this_ptr_ptr);
49056         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
49057         FREE(untag_ptr(this_ptr));
49058         CustomOnionMessageContents_free(this_ptr_conv);
49059 }
49060
49061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49062         LDKFilesystemPersister this_obj_conv;
49063         this_obj_conv.inner = untag_ptr(this_obj);
49064         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49066         FilesystemPersister_free(this_obj_conv);
49067 }
49068
49069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
49070         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
49071         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
49072         int64_t ret_ref = 0;
49073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49075         return ret_ref;
49076 }
49077
49078 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
49079         LDKFilesystemPersister this_arg_conv;
49080         this_arg_conv.inner = untag_ptr(this_arg);
49081         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49083         this_arg_conv.is_owned = false;
49084         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
49085         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49086         Str_free(ret_str);
49087         return ret_conv;
49088 }
49089
49090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
49091         LDKFilesystemPersister this_arg_conv;
49092         this_arg_conv.inner = untag_ptr(this_arg);
49093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49095         this_arg_conv.is_owned = false;
49096         void* keys_manager_ptr = untag_ptr(keys_manager);
49097         CHECK_ACCESS(keys_manager_ptr);
49098         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49099         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49101                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49102         }
49103         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
49104         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
49105         return tag_ptr(ret_conv, true);
49106 }
49107
49108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49109         LDKBackgroundProcessor this_obj_conv;
49110         this_obj_conv.inner = untag_ptr(this_obj);
49111         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49113         BackgroundProcessor_free(this_obj_conv);
49114 }
49115
49116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49117         if (!ptr_is_owned(this_ptr)) return;
49118         void* this_ptr_ptr = untag_ptr(this_ptr);
49119         CHECK_ACCESS(this_ptr_ptr);
49120         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
49121         FREE(untag_ptr(this_ptr));
49122         GossipSync_free(this_ptr_conv);
49123 }
49124
49125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
49126         LDKP2PGossipSync a_conv;
49127         a_conv.inner = untag_ptr(a);
49128         a_conv.is_owned = ptr_is_owned(a);
49129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49130         a_conv.is_owned = false;
49131         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49132         *ret_copy = GossipSync_p2_p(&a_conv);
49133         int64_t ret_ref = tag_ptr(ret_copy, true);
49134         return ret_ref;
49135 }
49136
49137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
49138         LDKRapidGossipSync a_conv;
49139         a_conv.inner = untag_ptr(a);
49140         a_conv.is_owned = ptr_is_owned(a);
49141         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49142         a_conv.is_owned = false;
49143         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49144         *ret_copy = GossipSync_rapid(&a_conv);
49145         int64_t ret_ref = tag_ptr(ret_copy, true);
49146         return ret_ref;
49147 }
49148
49149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
49150         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49151         *ret_copy = GossipSync_none();
49152         int64_t ret_ref = tag_ptr(ret_copy, true);
49153         return ret_ref;
49154 }
49155
49156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
49157         void* persister_ptr = untag_ptr(persister);
49158         CHECK_ACCESS(persister_ptr);
49159         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
49160         if (persister_conv.free == LDKPersister_JCalls_free) {
49161                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49162                 LDKPersister_JCalls_cloned(&persister_conv);
49163         }
49164         void* event_handler_ptr = untag_ptr(event_handler);
49165         CHECK_ACCESS(event_handler_ptr);
49166         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49167         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49169                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49170         }
49171         LDKChainMonitor chain_monitor_conv;
49172         chain_monitor_conv.inner = untag_ptr(chain_monitor);
49173         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
49174         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
49175         chain_monitor_conv.is_owned = false;
49176         LDKChannelManager channel_manager_conv;
49177         channel_manager_conv.inner = untag_ptr(channel_manager);
49178         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
49179         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
49180         channel_manager_conv.is_owned = false;
49181         void* gossip_sync_ptr = untag_ptr(gossip_sync);
49182         CHECK_ACCESS(gossip_sync_ptr);
49183         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
49184         // WARNING: we may need a move here but no clone is available for LDKGossipSync
49185         LDKPeerManager peer_manager_conv;
49186         peer_manager_conv.inner = untag_ptr(peer_manager);
49187         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
49188         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
49189         peer_manager_conv.is_owned = false;
49190         void* logger_ptr = untag_ptr(logger);
49191         CHECK_ACCESS(logger_ptr);
49192         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49193         if (logger_conv.free == LDKLogger_JCalls_free) {
49194                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49195                 LDKLogger_JCalls_cloned(&logger_conv);
49196         }
49197         void* scorer_ptr = untag_ptr(scorer);
49198         CHECK_ACCESS(scorer_ptr);
49199         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
49200         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
49201         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
49202                 // Manually implement clone for Java trait instances
49203                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
49204                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49205                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
49206                 }
49207         }
49208         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
49209         int64_t ret_ref = 0;
49210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49212         return ret_ref;
49213 }
49214
49215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
49216         LDKBackgroundProcessor this_arg_conv;
49217         this_arg_conv.inner = untag_ptr(this_arg);
49218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49220         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
49221         
49222         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
49223         *ret_conv = BackgroundProcessor_join(this_arg_conv);
49224         return tag_ptr(ret_conv, true);
49225 }
49226
49227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
49228         LDKBackgroundProcessor this_arg_conv;
49229         this_arg_conv.inner = untag_ptr(this_arg);
49230         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49232         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
49233         
49234         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
49235         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
49236         return tag_ptr(ret_conv, true);
49237 }
49238
49239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49240         if (!ptr_is_owned(this_ptr)) return;
49241         void* this_ptr_ptr = untag_ptr(this_ptr);
49242         CHECK_ACCESS(this_ptr_ptr);
49243         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
49244         FREE(untag_ptr(this_ptr));
49245         ParseError_free(this_ptr_conv);
49246 }
49247
49248 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
49249         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49250         *ret_copy = ParseError_clone(arg);
49251         int64_t ret_ref = tag_ptr(ret_copy, true);
49252         return ret_ref;
49253 }
49254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49255         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
49256         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
49257         return ret_conv;
49258 }
49259
49260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49261         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
49262         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49263         *ret_copy = ParseError_clone(orig_conv);
49264         int64_t ret_ref = tag_ptr(ret_copy, true);
49265         return ret_ref;
49266 }
49267
49268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
49269         void* a_ptr = untag_ptr(a);
49270         CHECK_ACCESS(a_ptr);
49271         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
49272         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
49273         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49274         *ret_copy = ParseError_bech32_error(a_conv);
49275         int64_t ret_ref = tag_ptr(ret_copy, true);
49276         return ret_ref;
49277 }
49278
49279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
49280         
49281         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49282         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
49283         int64_t ret_ref = tag_ptr(ret_copy, true);
49284         return ret_ref;
49285 }
49286
49287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
49288         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
49289         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49290         *ret_copy = ParseError_malformed_signature(a_conv);
49291         int64_t ret_ref = tag_ptr(ret_copy, true);
49292         return ret_ref;
49293 }
49294
49295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
49296         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49297         *ret_copy = ParseError_bad_prefix();
49298         int64_t ret_ref = tag_ptr(ret_copy, true);
49299         return ret_ref;
49300 }
49301
49302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
49303         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49304         *ret_copy = ParseError_unknown_currency();
49305         int64_t ret_ref = tag_ptr(ret_copy, true);
49306         return ret_ref;
49307 }
49308
49309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
49310         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49311         *ret_copy = ParseError_unknown_si_prefix();
49312         int64_t ret_ref = tag_ptr(ret_copy, true);
49313         return ret_ref;
49314 }
49315
49316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
49317         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49318         *ret_copy = ParseError_malformed_hrp();
49319         int64_t ret_ref = tag_ptr(ret_copy, true);
49320         return ret_ref;
49321 }
49322
49323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
49324         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49325         *ret_copy = ParseError_too_short_data_part();
49326         int64_t ret_ref = tag_ptr(ret_copy, true);
49327         return ret_ref;
49328 }
49329
49330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
49331         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49332         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
49333         int64_t ret_ref = tag_ptr(ret_copy, true);
49334         return ret_ref;
49335 }
49336
49337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
49338         
49339         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49340         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
49341         int64_t ret_ref = tag_ptr(ret_copy, true);
49342         return ret_ref;
49343 }
49344
49345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
49346         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49347         *ret_copy = ParseError_padding_error();
49348         int64_t ret_ref = tag_ptr(ret_copy, true);
49349         return ret_ref;
49350 }
49351
49352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
49353         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49354         *ret_copy = ParseError_integer_overflow_error();
49355         int64_t ret_ref = tag_ptr(ret_copy, true);
49356         return ret_ref;
49357 }
49358
49359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
49360         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49361         *ret_copy = ParseError_invalid_seg_wit_program_length();
49362         int64_t ret_ref = tag_ptr(ret_copy, true);
49363         return ret_ref;
49364 }
49365
49366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
49367         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49368         *ret_copy = ParseError_invalid_pub_key_hash_length();
49369         int64_t ret_ref = tag_ptr(ret_copy, true);
49370         return ret_ref;
49371 }
49372
49373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
49374         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49375         *ret_copy = ParseError_invalid_script_hash_length();
49376         int64_t ret_ref = tag_ptr(ret_copy, true);
49377         return ret_ref;
49378 }
49379
49380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49381         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49382         *ret_copy = ParseError_invalid_recovery_id();
49383         int64_t ret_ref = tag_ptr(ret_copy, true);
49384         return ret_ref;
49385 }
49386
49387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
49388         LDKStr a_conv = java_to_owned_str(env, a);
49389         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49390         *ret_copy = ParseError_invalid_slice_length(a_conv);
49391         int64_t ret_ref = tag_ptr(ret_copy, true);
49392         return ret_ref;
49393 }
49394
49395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
49396         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49397         *ret_copy = ParseError_skip();
49398         int64_t ret_ref = tag_ptr(ret_copy, true);
49399         return ret_ref;
49400 }
49401
49402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49403         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
49404         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
49405         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
49406         return ret_conv;
49407 }
49408
49409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49410         if (!ptr_is_owned(this_ptr)) return;
49411         void* this_ptr_ptr = untag_ptr(this_ptr);
49412         CHECK_ACCESS(this_ptr_ptr);
49413         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
49414         FREE(untag_ptr(this_ptr));
49415         ParseOrSemanticError_free(this_ptr_conv);
49416 }
49417
49418 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
49419         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49420         *ret_copy = ParseOrSemanticError_clone(arg);
49421         int64_t ret_ref = tag_ptr(ret_copy, true);
49422         return ret_ref;
49423 }
49424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49425         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
49426         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
49427         return ret_conv;
49428 }
49429
49430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49431         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
49432         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49433         *ret_copy = ParseOrSemanticError_clone(orig_conv);
49434         int64_t ret_ref = tag_ptr(ret_copy, true);
49435         return ret_ref;
49436 }
49437
49438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
49439         void* a_ptr = untag_ptr(a);
49440         CHECK_ACCESS(a_ptr);
49441         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
49442         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
49443         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49444         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
49445         int64_t ret_ref = tag_ptr(ret_copy, true);
49446         return ret_ref;
49447 }
49448
49449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
49450         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
49451         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49452         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
49453         int64_t ret_ref = tag_ptr(ret_copy, true);
49454         return ret_ref;
49455 }
49456
49457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49458         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
49459         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
49460         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
49461         return ret_conv;
49462 }
49463
49464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49465         LDKInvoice this_obj_conv;
49466         this_obj_conv.inner = untag_ptr(this_obj);
49467         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49469         Invoice_free(this_obj_conv);
49470 }
49471
49472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49473         LDKInvoice a_conv;
49474         a_conv.inner = untag_ptr(a);
49475         a_conv.is_owned = ptr_is_owned(a);
49476         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49477         a_conv.is_owned = false;
49478         LDKInvoice b_conv;
49479         b_conv.inner = untag_ptr(b);
49480         b_conv.is_owned = ptr_is_owned(b);
49481         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49482         b_conv.is_owned = false;
49483         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
49484         return ret_conv;
49485 }
49486
49487 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
49488         LDKInvoice ret_var = Invoice_clone(arg);
49489         int64_t ret_ref = 0;
49490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49492         return ret_ref;
49493 }
49494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49495         LDKInvoice arg_conv;
49496         arg_conv.inner = untag_ptr(arg);
49497         arg_conv.is_owned = ptr_is_owned(arg);
49498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49499         arg_conv.is_owned = false;
49500         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
49501         return ret_conv;
49502 }
49503
49504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49505         LDKInvoice orig_conv;
49506         orig_conv.inner = untag_ptr(orig);
49507         orig_conv.is_owned = ptr_is_owned(orig);
49508         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49509         orig_conv.is_owned = false;
49510         LDKInvoice ret_var = Invoice_clone(&orig_conv);
49511         int64_t ret_ref = 0;
49512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49513         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49514         return ret_ref;
49515 }
49516
49517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49518         LDKInvoice o_conv;
49519         o_conv.inner = untag_ptr(o);
49520         o_conv.is_owned = ptr_is_owned(o);
49521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49522         o_conv.is_owned = false;
49523         int64_t ret_conv = Invoice_hash(&o_conv);
49524         return ret_conv;
49525 }
49526
49527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49528         LDKSignedRawInvoice this_obj_conv;
49529         this_obj_conv.inner = untag_ptr(this_obj);
49530         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49532         SignedRawInvoice_free(this_obj_conv);
49533 }
49534
49535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49536         LDKSignedRawInvoice a_conv;
49537         a_conv.inner = untag_ptr(a);
49538         a_conv.is_owned = ptr_is_owned(a);
49539         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49540         a_conv.is_owned = false;
49541         LDKSignedRawInvoice b_conv;
49542         b_conv.inner = untag_ptr(b);
49543         b_conv.is_owned = ptr_is_owned(b);
49544         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49545         b_conv.is_owned = false;
49546         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
49547         return ret_conv;
49548 }
49549
49550 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
49551         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
49552         int64_t ret_ref = 0;
49553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49555         return ret_ref;
49556 }
49557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49558         LDKSignedRawInvoice arg_conv;
49559         arg_conv.inner = untag_ptr(arg);
49560         arg_conv.is_owned = ptr_is_owned(arg);
49561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49562         arg_conv.is_owned = false;
49563         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
49564         return ret_conv;
49565 }
49566
49567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49568         LDKSignedRawInvoice orig_conv;
49569         orig_conv.inner = untag_ptr(orig);
49570         orig_conv.is_owned = ptr_is_owned(orig);
49571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49572         orig_conv.is_owned = false;
49573         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
49574         int64_t ret_ref = 0;
49575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49577         return ret_ref;
49578 }
49579
49580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49581         LDKSignedRawInvoice o_conv;
49582         o_conv.inner = untag_ptr(o);
49583         o_conv.is_owned = ptr_is_owned(o);
49584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49585         o_conv.is_owned = false;
49586         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
49587         return ret_conv;
49588 }
49589
49590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49591         LDKRawInvoice this_obj_conv;
49592         this_obj_conv.inner = untag_ptr(this_obj);
49593         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49595         RawInvoice_free(this_obj_conv);
49596 }
49597
49598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
49599         LDKRawInvoice this_ptr_conv;
49600         this_ptr_conv.inner = untag_ptr(this_ptr);
49601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49603         this_ptr_conv.is_owned = false;
49604         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
49605         int64_t ret_ref = 0;
49606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49608         return ret_ref;
49609 }
49610
49611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49612         LDKRawInvoice this_ptr_conv;
49613         this_ptr_conv.inner = untag_ptr(this_ptr);
49614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49616         this_ptr_conv.is_owned = false;
49617         LDKRawDataPart val_conv;
49618         val_conv.inner = untag_ptr(val);
49619         val_conv.is_owned = ptr_is_owned(val);
49620         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49621         val_conv = RawDataPart_clone(&val_conv);
49622         RawInvoice_set_data(&this_ptr_conv, val_conv);
49623 }
49624
49625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49626         LDKRawInvoice a_conv;
49627         a_conv.inner = untag_ptr(a);
49628         a_conv.is_owned = ptr_is_owned(a);
49629         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49630         a_conv.is_owned = false;
49631         LDKRawInvoice b_conv;
49632         b_conv.inner = untag_ptr(b);
49633         b_conv.is_owned = ptr_is_owned(b);
49634         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49635         b_conv.is_owned = false;
49636         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
49637         return ret_conv;
49638 }
49639
49640 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
49641         LDKRawInvoice ret_var = RawInvoice_clone(arg);
49642         int64_t ret_ref = 0;
49643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49645         return ret_ref;
49646 }
49647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49648         LDKRawInvoice arg_conv;
49649         arg_conv.inner = untag_ptr(arg);
49650         arg_conv.is_owned = ptr_is_owned(arg);
49651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49652         arg_conv.is_owned = false;
49653         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
49654         return ret_conv;
49655 }
49656
49657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49658         LDKRawInvoice orig_conv;
49659         orig_conv.inner = untag_ptr(orig);
49660         orig_conv.is_owned = ptr_is_owned(orig);
49661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49662         orig_conv.is_owned = false;
49663         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
49664         int64_t ret_ref = 0;
49665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49667         return ret_ref;
49668 }
49669
49670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49671         LDKRawInvoice o_conv;
49672         o_conv.inner = untag_ptr(o);
49673         o_conv.is_owned = ptr_is_owned(o);
49674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49675         o_conv.is_owned = false;
49676         int64_t ret_conv = RawInvoice_hash(&o_conv);
49677         return ret_conv;
49678 }
49679
49680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49681         LDKRawDataPart this_obj_conv;
49682         this_obj_conv.inner = untag_ptr(this_obj);
49683         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49685         RawDataPart_free(this_obj_conv);
49686 }
49687
49688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
49689         LDKRawDataPart this_ptr_conv;
49690         this_ptr_conv.inner = untag_ptr(this_ptr);
49691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49693         this_ptr_conv.is_owned = false;
49694         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
49695         int64_t ret_ref = 0;
49696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49698         return ret_ref;
49699 }
49700
49701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49702         LDKRawDataPart this_ptr_conv;
49703         this_ptr_conv.inner = untag_ptr(this_ptr);
49704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49706         this_ptr_conv.is_owned = false;
49707         LDKPositiveTimestamp val_conv;
49708         val_conv.inner = untag_ptr(val);
49709         val_conv.is_owned = ptr_is_owned(val);
49710         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49711         val_conv = PositiveTimestamp_clone(&val_conv);
49712         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
49713 }
49714
49715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49716         LDKRawDataPart a_conv;
49717         a_conv.inner = untag_ptr(a);
49718         a_conv.is_owned = ptr_is_owned(a);
49719         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49720         a_conv.is_owned = false;
49721         LDKRawDataPart b_conv;
49722         b_conv.inner = untag_ptr(b);
49723         b_conv.is_owned = ptr_is_owned(b);
49724         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49725         b_conv.is_owned = false;
49726         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
49727         return ret_conv;
49728 }
49729
49730 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
49731         LDKRawDataPart ret_var = RawDataPart_clone(arg);
49732         int64_t ret_ref = 0;
49733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49735         return ret_ref;
49736 }
49737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49738         LDKRawDataPart arg_conv;
49739         arg_conv.inner = untag_ptr(arg);
49740         arg_conv.is_owned = ptr_is_owned(arg);
49741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49742         arg_conv.is_owned = false;
49743         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
49744         return ret_conv;
49745 }
49746
49747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49748         LDKRawDataPart orig_conv;
49749         orig_conv.inner = untag_ptr(orig);
49750         orig_conv.is_owned = ptr_is_owned(orig);
49751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49752         orig_conv.is_owned = false;
49753         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
49754         int64_t ret_ref = 0;
49755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49757         return ret_ref;
49758 }
49759
49760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
49761         LDKRawDataPart o_conv;
49762         o_conv.inner = untag_ptr(o);
49763         o_conv.is_owned = ptr_is_owned(o);
49764         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49765         o_conv.is_owned = false;
49766         int64_t ret_conv = RawDataPart_hash(&o_conv);
49767         return ret_conv;
49768 }
49769
49770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49771         LDKPositiveTimestamp this_obj_conv;
49772         this_obj_conv.inner = untag_ptr(this_obj);
49773         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49775         PositiveTimestamp_free(this_obj_conv);
49776 }
49777
49778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49779         LDKPositiveTimestamp a_conv;
49780         a_conv.inner = untag_ptr(a);
49781         a_conv.is_owned = ptr_is_owned(a);
49782         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49783         a_conv.is_owned = false;
49784         LDKPositiveTimestamp b_conv;
49785         b_conv.inner = untag_ptr(b);
49786         b_conv.is_owned = ptr_is_owned(b);
49787         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49788         b_conv.is_owned = false;
49789         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
49790         return ret_conv;
49791 }
49792
49793 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
49794         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
49795         int64_t ret_ref = 0;
49796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49798         return ret_ref;
49799 }
49800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49801         LDKPositiveTimestamp arg_conv;
49802         arg_conv.inner = untag_ptr(arg);
49803         arg_conv.is_owned = ptr_is_owned(arg);
49804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49805         arg_conv.is_owned = false;
49806         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
49807         return ret_conv;
49808 }
49809
49810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49811         LDKPositiveTimestamp orig_conv;
49812         orig_conv.inner = untag_ptr(orig);
49813         orig_conv.is_owned = ptr_is_owned(orig);
49814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49815         orig_conv.is_owned = false;
49816         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
49817         int64_t ret_ref = 0;
49818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49820         return ret_ref;
49821 }
49822
49823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
49824         LDKPositiveTimestamp o_conv;
49825         o_conv.inner = untag_ptr(o);
49826         o_conv.is_owned = ptr_is_owned(o);
49827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49828         o_conv.is_owned = false;
49829         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
49830         return ret_conv;
49831 }
49832
49833 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49834         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
49835         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
49836         return ret_conv;
49837 }
49838
49839 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
49840         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
49841         return ret_conv;
49842 }
49843
49844 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
49845         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
49846         return ret_conv;
49847 }
49848
49849 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
49850         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
49851         return ret_conv;
49852 }
49853
49854 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
49855         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
49856         return ret_conv;
49857 }
49858
49859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49860         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
49861         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
49862         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
49863         return ret_conv;
49864 }
49865
49866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
49867         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
49868         int64_t ret_conv = SiPrefix_hash(o_conv);
49869         return ret_conv;
49870 }
49871
49872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
49873         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
49874         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
49875         return ret_conv;
49876 }
49877
49878 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49879         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
49880         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
49881         return ret_conv;
49882 }
49883
49884 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
49885         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
49886         return ret_conv;
49887 }
49888
49889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
49890         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
49891         return ret_conv;
49892 }
49893
49894 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
49895         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
49896         return ret_conv;
49897 }
49898
49899 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
49900         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
49901         return ret_conv;
49902 }
49903
49904 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
49905         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
49906         return ret_conv;
49907 }
49908
49909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
49910         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
49911         int64_t ret_conv = Currency_hash(o_conv);
49912         return ret_conv;
49913 }
49914
49915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49916         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
49917         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
49918         jboolean ret_conv = Currency_eq(a_conv, b_conv);
49919         return ret_conv;
49920 }
49921
49922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49923         LDKSha256 this_obj_conv;
49924         this_obj_conv.inner = untag_ptr(this_obj);
49925         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49927         Sha256_free(this_obj_conv);
49928 }
49929
49930 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
49931         LDKSha256 ret_var = Sha256_clone(arg);
49932         int64_t ret_ref = 0;
49933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49935         return ret_ref;
49936 }
49937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49938         LDKSha256 arg_conv;
49939         arg_conv.inner = untag_ptr(arg);
49940         arg_conv.is_owned = ptr_is_owned(arg);
49941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49942         arg_conv.is_owned = false;
49943         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
49944         return ret_conv;
49945 }
49946
49947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49948         LDKSha256 orig_conv;
49949         orig_conv.inner = untag_ptr(orig);
49950         orig_conv.is_owned = ptr_is_owned(orig);
49951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49952         orig_conv.is_owned = false;
49953         LDKSha256 ret_var = Sha256_clone(&orig_conv);
49954         int64_t ret_ref = 0;
49955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49957         return ret_ref;
49958 }
49959
49960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
49961         LDKSha256 o_conv;
49962         o_conv.inner = untag_ptr(o);
49963         o_conv.is_owned = ptr_is_owned(o);
49964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49965         o_conv.is_owned = false;
49966         int64_t ret_conv = Sha256_hash(&o_conv);
49967         return ret_conv;
49968 }
49969
49970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49971         LDKSha256 a_conv;
49972         a_conv.inner = untag_ptr(a);
49973         a_conv.is_owned = ptr_is_owned(a);
49974         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49975         a_conv.is_owned = false;
49976         LDKSha256 b_conv;
49977         b_conv.inner = untag_ptr(b);
49978         b_conv.is_owned = ptr_is_owned(b);
49979         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49980         b_conv.is_owned = false;
49981         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
49982         return ret_conv;
49983 }
49984
49985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49986         LDKDescription this_obj_conv;
49987         this_obj_conv.inner = untag_ptr(this_obj);
49988         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49990         Description_free(this_obj_conv);
49991 }
49992
49993 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
49994         LDKDescription ret_var = Description_clone(arg);
49995         int64_t ret_ref = 0;
49996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49997         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49998         return ret_ref;
49999 }
50000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50001         LDKDescription arg_conv;
50002         arg_conv.inner = untag_ptr(arg);
50003         arg_conv.is_owned = ptr_is_owned(arg);
50004         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50005         arg_conv.is_owned = false;
50006         int64_t ret_conv = Description_clone_ptr(&arg_conv);
50007         return ret_conv;
50008 }
50009
50010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50011         LDKDescription orig_conv;
50012         orig_conv.inner = untag_ptr(orig);
50013         orig_conv.is_owned = ptr_is_owned(orig);
50014         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50015         orig_conv.is_owned = false;
50016         LDKDescription ret_var = Description_clone(&orig_conv);
50017         int64_t ret_ref = 0;
50018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50020         return ret_ref;
50021 }
50022
50023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
50024         LDKDescription o_conv;
50025         o_conv.inner = untag_ptr(o);
50026         o_conv.is_owned = ptr_is_owned(o);
50027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50028         o_conv.is_owned = false;
50029         int64_t ret_conv = Description_hash(&o_conv);
50030         return ret_conv;
50031 }
50032
50033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50034         LDKDescription a_conv;
50035         a_conv.inner = untag_ptr(a);
50036         a_conv.is_owned = ptr_is_owned(a);
50037         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50038         a_conv.is_owned = false;
50039         LDKDescription b_conv;
50040         b_conv.inner = untag_ptr(b);
50041         b_conv.is_owned = ptr_is_owned(b);
50042         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50043         b_conv.is_owned = false;
50044         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
50045         return ret_conv;
50046 }
50047
50048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50049         LDKPayeePubKey this_obj_conv;
50050         this_obj_conv.inner = untag_ptr(this_obj);
50051         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50053         PayeePubKey_free(this_obj_conv);
50054 }
50055
50056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
50057         LDKPayeePubKey this_ptr_conv;
50058         this_ptr_conv.inner = untag_ptr(this_ptr);
50059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50061         this_ptr_conv.is_owned = false;
50062         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
50064         return ret_arr;
50065 }
50066
50067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50068         LDKPayeePubKey this_ptr_conv;
50069         this_ptr_conv.inner = untag_ptr(this_ptr);
50070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50072         this_ptr_conv.is_owned = false;
50073         LDKPublicKey val_ref;
50074         CHECK((*env)->GetArrayLength(env, val) == 33);
50075         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50076         PayeePubKey_set_a(&this_ptr_conv, val_ref);
50077 }
50078
50079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
50080         LDKPublicKey a_arg_ref;
50081         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
50082         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
50083         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
50084         int64_t ret_ref = 0;
50085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50087         return ret_ref;
50088 }
50089
50090 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
50091         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
50092         int64_t ret_ref = 0;
50093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50095         return ret_ref;
50096 }
50097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50098         LDKPayeePubKey arg_conv;
50099         arg_conv.inner = untag_ptr(arg);
50100         arg_conv.is_owned = ptr_is_owned(arg);
50101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50102         arg_conv.is_owned = false;
50103         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
50104         return ret_conv;
50105 }
50106
50107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50108         LDKPayeePubKey orig_conv;
50109         orig_conv.inner = untag_ptr(orig);
50110         orig_conv.is_owned = ptr_is_owned(orig);
50111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50112         orig_conv.is_owned = false;
50113         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
50114         int64_t ret_ref = 0;
50115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50117         return ret_ref;
50118 }
50119
50120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
50121         LDKPayeePubKey o_conv;
50122         o_conv.inner = untag_ptr(o);
50123         o_conv.is_owned = ptr_is_owned(o);
50124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50125         o_conv.is_owned = false;
50126         int64_t ret_conv = PayeePubKey_hash(&o_conv);
50127         return ret_conv;
50128 }
50129
50130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50131         LDKPayeePubKey a_conv;
50132         a_conv.inner = untag_ptr(a);
50133         a_conv.is_owned = ptr_is_owned(a);
50134         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50135         a_conv.is_owned = false;
50136         LDKPayeePubKey b_conv;
50137         b_conv.inner = untag_ptr(b);
50138         b_conv.is_owned = ptr_is_owned(b);
50139         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50140         b_conv.is_owned = false;
50141         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
50142         return ret_conv;
50143 }
50144
50145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50146         LDKExpiryTime this_obj_conv;
50147         this_obj_conv.inner = untag_ptr(this_obj);
50148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50150         ExpiryTime_free(this_obj_conv);
50151 }
50152
50153 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
50154         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
50155         int64_t ret_ref = 0;
50156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50158         return ret_ref;
50159 }
50160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50161         LDKExpiryTime arg_conv;
50162         arg_conv.inner = untag_ptr(arg);
50163         arg_conv.is_owned = ptr_is_owned(arg);
50164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50165         arg_conv.is_owned = false;
50166         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
50167         return ret_conv;
50168 }
50169
50170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50171         LDKExpiryTime orig_conv;
50172         orig_conv.inner = untag_ptr(orig);
50173         orig_conv.is_owned = ptr_is_owned(orig);
50174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50175         orig_conv.is_owned = false;
50176         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
50177         int64_t ret_ref = 0;
50178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50180         return ret_ref;
50181 }
50182
50183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
50184         LDKExpiryTime o_conv;
50185         o_conv.inner = untag_ptr(o);
50186         o_conv.is_owned = ptr_is_owned(o);
50187         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50188         o_conv.is_owned = false;
50189         int64_t ret_conv = ExpiryTime_hash(&o_conv);
50190         return ret_conv;
50191 }
50192
50193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50194         LDKExpiryTime a_conv;
50195         a_conv.inner = untag_ptr(a);
50196         a_conv.is_owned = ptr_is_owned(a);
50197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50198         a_conv.is_owned = false;
50199         LDKExpiryTime b_conv;
50200         b_conv.inner = untag_ptr(b);
50201         b_conv.is_owned = ptr_is_owned(b);
50202         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50203         b_conv.is_owned = false;
50204         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
50205         return ret_conv;
50206 }
50207
50208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50209         LDKMinFinalCltvExpiry this_obj_conv;
50210         this_obj_conv.inner = untag_ptr(this_obj);
50211         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50213         MinFinalCltvExpiry_free(this_obj_conv);
50214 }
50215
50216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
50217         LDKMinFinalCltvExpiry this_ptr_conv;
50218         this_ptr_conv.inner = untag_ptr(this_ptr);
50219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50221         this_ptr_conv.is_owned = false;
50222         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
50223         return ret_conv;
50224 }
50225
50226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50227         LDKMinFinalCltvExpiry this_ptr_conv;
50228         this_ptr_conv.inner = untag_ptr(this_ptr);
50229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50231         this_ptr_conv.is_owned = false;
50232         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
50233 }
50234
50235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
50236         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
50237         int64_t ret_ref = 0;
50238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50240         return ret_ref;
50241 }
50242
50243 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
50244         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
50245         int64_t ret_ref = 0;
50246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50248         return ret_ref;
50249 }
50250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50251         LDKMinFinalCltvExpiry arg_conv;
50252         arg_conv.inner = untag_ptr(arg);
50253         arg_conv.is_owned = ptr_is_owned(arg);
50254         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50255         arg_conv.is_owned = false;
50256         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
50257         return ret_conv;
50258 }
50259
50260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50261         LDKMinFinalCltvExpiry orig_conv;
50262         orig_conv.inner = untag_ptr(orig);
50263         orig_conv.is_owned = ptr_is_owned(orig);
50264         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50265         orig_conv.is_owned = false;
50266         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
50267         int64_t ret_ref = 0;
50268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50270         return ret_ref;
50271 }
50272
50273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
50274         LDKMinFinalCltvExpiry o_conv;
50275         o_conv.inner = untag_ptr(o);
50276         o_conv.is_owned = ptr_is_owned(o);
50277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50278         o_conv.is_owned = false;
50279         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
50280         return ret_conv;
50281 }
50282
50283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50284         LDKMinFinalCltvExpiry a_conv;
50285         a_conv.inner = untag_ptr(a);
50286         a_conv.is_owned = ptr_is_owned(a);
50287         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50288         a_conv.is_owned = false;
50289         LDKMinFinalCltvExpiry b_conv;
50290         b_conv.inner = untag_ptr(b);
50291         b_conv.is_owned = ptr_is_owned(b);
50292         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50293         b_conv.is_owned = false;
50294         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
50295         return ret_conv;
50296 }
50297
50298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50299         if (!ptr_is_owned(this_ptr)) return;
50300         void* this_ptr_ptr = untag_ptr(this_ptr);
50301         CHECK_ACCESS(this_ptr_ptr);
50302         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
50303         FREE(untag_ptr(this_ptr));
50304         Fallback_free(this_ptr_conv);
50305 }
50306
50307 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
50308         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50309         *ret_copy = Fallback_clone(arg);
50310         int64_t ret_ref = tag_ptr(ret_copy, true);
50311         return ret_ref;
50312 }
50313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50314         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
50315         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
50316         return ret_conv;
50317 }
50318
50319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50320         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
50321         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50322         *ret_copy = Fallback_clone(orig_conv);
50323         int64_t ret_ref = tag_ptr(ret_copy, true);
50324         return ret_ref;
50325 }
50326
50327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
50328         
50329         LDKCVec_u8Z program_ref;
50330         program_ref.datalen = (*env)->GetArrayLength(env, program);
50331         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
50332         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
50333         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50334         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
50335         int64_t ret_ref = tag_ptr(ret_copy, true);
50336         return ret_ref;
50337 }
50338
50339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
50340         LDKTwentyBytes a_ref;
50341         CHECK((*env)->GetArrayLength(env, a) == 20);
50342         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
50343         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50344         *ret_copy = Fallback_pub_key_hash(a_ref);
50345         int64_t ret_ref = tag_ptr(ret_copy, true);
50346         return ret_ref;
50347 }
50348
50349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
50350         LDKTwentyBytes a_ref;
50351         CHECK((*env)->GetArrayLength(env, a) == 20);
50352         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
50353         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50354         *ret_copy = Fallback_script_hash(a_ref);
50355         int64_t ret_ref = tag_ptr(ret_copy, true);
50356         return ret_ref;
50357 }
50358
50359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
50360         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
50361         int64_t ret_conv = Fallback_hash(o_conv);
50362         return ret_conv;
50363 }
50364
50365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50366         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
50367         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
50368         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
50369         return ret_conv;
50370 }
50371
50372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50373         LDKInvoiceSignature this_obj_conv;
50374         this_obj_conv.inner = untag_ptr(this_obj);
50375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50377         InvoiceSignature_free(this_obj_conv);
50378 }
50379
50380 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
50381         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
50382         int64_t ret_ref = 0;
50383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50385         return ret_ref;
50386 }
50387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50388         LDKInvoiceSignature arg_conv;
50389         arg_conv.inner = untag_ptr(arg);
50390         arg_conv.is_owned = ptr_is_owned(arg);
50391         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50392         arg_conv.is_owned = false;
50393         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
50394         return ret_conv;
50395 }
50396
50397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50398         LDKInvoiceSignature orig_conv;
50399         orig_conv.inner = untag_ptr(orig);
50400         orig_conv.is_owned = ptr_is_owned(orig);
50401         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50402         orig_conv.is_owned = false;
50403         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
50404         int64_t ret_ref = 0;
50405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50407         return ret_ref;
50408 }
50409
50410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
50411         LDKInvoiceSignature o_conv;
50412         o_conv.inner = untag_ptr(o);
50413         o_conv.is_owned = ptr_is_owned(o);
50414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50415         o_conv.is_owned = false;
50416         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
50417         return ret_conv;
50418 }
50419
50420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50421         LDKInvoiceSignature a_conv;
50422         a_conv.inner = untag_ptr(a);
50423         a_conv.is_owned = ptr_is_owned(a);
50424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50425         a_conv.is_owned = false;
50426         LDKInvoiceSignature b_conv;
50427         b_conv.inner = untag_ptr(b);
50428         b_conv.is_owned = ptr_is_owned(b);
50429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50430         b_conv.is_owned = false;
50431         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
50432         return ret_conv;
50433 }
50434
50435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50436         LDKPrivateRoute this_obj_conv;
50437         this_obj_conv.inner = untag_ptr(this_obj);
50438         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50440         PrivateRoute_free(this_obj_conv);
50441 }
50442
50443 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
50444         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
50445         int64_t ret_ref = 0;
50446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50448         return ret_ref;
50449 }
50450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50451         LDKPrivateRoute arg_conv;
50452         arg_conv.inner = untag_ptr(arg);
50453         arg_conv.is_owned = ptr_is_owned(arg);
50454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50455         arg_conv.is_owned = false;
50456         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
50457         return ret_conv;
50458 }
50459
50460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50461         LDKPrivateRoute orig_conv;
50462         orig_conv.inner = untag_ptr(orig);
50463         orig_conv.is_owned = ptr_is_owned(orig);
50464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50465         orig_conv.is_owned = false;
50466         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
50467         int64_t ret_ref = 0;
50468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50470         return ret_ref;
50471 }
50472
50473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
50474         LDKPrivateRoute o_conv;
50475         o_conv.inner = untag_ptr(o);
50476         o_conv.is_owned = ptr_is_owned(o);
50477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50478         o_conv.is_owned = false;
50479         int64_t ret_conv = PrivateRoute_hash(&o_conv);
50480         return ret_conv;
50481 }
50482
50483 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50484         LDKPrivateRoute a_conv;
50485         a_conv.inner = untag_ptr(a);
50486         a_conv.is_owned = ptr_is_owned(a);
50487         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50488         a_conv.is_owned = false;
50489         LDKPrivateRoute b_conv;
50490         b_conv.inner = untag_ptr(b);
50491         b_conv.is_owned = ptr_is_owned(b);
50492         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50493         b_conv.is_owned = false;
50494         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
50495         return ret_conv;
50496 }
50497
50498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
50499         LDKSignedRawInvoice this_arg_conv;
50500         this_arg_conv.inner = untag_ptr(this_arg);
50501         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50503         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
50504         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
50505         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
50506         return tag_ptr(ret_conv, true);
50507 }
50508
50509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
50510         LDKSignedRawInvoice this_arg_conv;
50511         this_arg_conv.inner = untag_ptr(this_arg);
50512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50514         this_arg_conv.is_owned = false;
50515         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
50516         int64_t ret_ref = 0;
50517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50519         return ret_ref;
50520 }
50521
50522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50523         LDKSignedRawInvoice this_arg_conv;
50524         this_arg_conv.inner = untag_ptr(this_arg);
50525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50527         this_arg_conv.is_owned = false;
50528         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
50530         return ret_arr;
50531 }
50532
50533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50534         LDKSignedRawInvoice this_arg_conv;
50535         this_arg_conv.inner = untag_ptr(this_arg);
50536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50538         this_arg_conv.is_owned = false;
50539         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
50540         int64_t ret_ref = 0;
50541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50543         return ret_ref;
50544 }
50545
50546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50547         LDKSignedRawInvoice this_arg_conv;
50548         this_arg_conv.inner = untag_ptr(this_arg);
50549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50551         this_arg_conv.is_owned = false;
50552         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
50553         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
50554         return tag_ptr(ret_conv, true);
50555 }
50556
50557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50558         LDKSignedRawInvoice this_arg_conv;
50559         this_arg_conv.inner = untag_ptr(this_arg);
50560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50562         this_arg_conv.is_owned = false;
50563         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
50564         return ret_conv;
50565 }
50566
50567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50568         LDKRawInvoice this_arg_conv;
50569         this_arg_conv.inner = untag_ptr(this_arg);
50570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50572         this_arg_conv.is_owned = false;
50573         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
50575         return ret_arr;
50576 }
50577
50578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50579         LDKRawInvoice this_arg_conv;
50580         this_arg_conv.inner = untag_ptr(this_arg);
50581         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50583         this_arg_conv.is_owned = false;
50584         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
50585         int64_t ret_ref = 0;
50586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50588         return ret_ref;
50589 }
50590
50591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
50592         LDKRawInvoice this_arg_conv;
50593         this_arg_conv.inner = untag_ptr(this_arg);
50594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50596         this_arg_conv.is_owned = false;
50597         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
50598         int64_t ret_ref = 0;
50599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50601         return ret_ref;
50602 }
50603
50604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50605         LDKRawInvoice this_arg_conv;
50606         this_arg_conv.inner = untag_ptr(this_arg);
50607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50609         this_arg_conv.is_owned = false;
50610         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
50611         int64_t ret_ref = 0;
50612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50614         return ret_ref;
50615 }
50616
50617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50618         LDKRawInvoice this_arg_conv;
50619         this_arg_conv.inner = untag_ptr(this_arg);
50620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50622         this_arg_conv.is_owned = false;
50623         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
50624         int64_t ret_ref = 0;
50625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50627         return ret_ref;
50628 }
50629
50630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50631         LDKRawInvoice this_arg_conv;
50632         this_arg_conv.inner = untag_ptr(this_arg);
50633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50635         this_arg_conv.is_owned = false;
50636         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
50637         int64_t ret_ref = 0;
50638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50640         return ret_ref;
50641 }
50642
50643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
50644         LDKRawInvoice this_arg_conv;
50645         this_arg_conv.inner = untag_ptr(this_arg);
50646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50648         this_arg_conv.is_owned = false;
50649         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
50650         int64_t ret_ref = 0;
50651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50653         return ret_ref;
50654 }
50655
50656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
50657         LDKRawInvoice this_arg_conv;
50658         this_arg_conv.inner = untag_ptr(this_arg);
50659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50661         this_arg_conv.is_owned = false;
50662         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
50664         return ret_arr;
50665 }
50666
50667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
50668         LDKRawInvoice this_arg_conv;
50669         this_arg_conv.inner = untag_ptr(this_arg);
50670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50672         this_arg_conv.is_owned = false;
50673         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
50674         int64_t ret_ref = 0;
50675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50677         return ret_ref;
50678 }
50679
50680 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
50681         LDKRawInvoice this_arg_conv;
50682         this_arg_conv.inner = untag_ptr(this_arg);
50683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50685         this_arg_conv.is_owned = false;
50686         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
50687         int64_tArray ret_arr = NULL;
50688         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50689         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50690         for (size_t o = 0; o < ret_var.datalen; o++) {
50691                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
50692                 int64_t ret_conv_14_ref = 0;
50693                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
50694                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
50695                 ret_arr_ptr[o] = ret_conv_14_ref;
50696         }
50697         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50698         FREE(ret_var.data);
50699         return ret_arr;
50700 }
50701
50702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
50703         LDKRawInvoice this_arg_conv;
50704         this_arg_conv.inner = untag_ptr(this_arg);
50705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50707         this_arg_conv.is_owned = false;
50708         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50709         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
50710         int64_t ret_ref = tag_ptr(ret_copy, true);
50711         return ret_ref;
50712 }
50713
50714 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
50715         LDKRawInvoice this_arg_conv;
50716         this_arg_conv.inner = untag_ptr(this_arg);
50717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50719         this_arg_conv.is_owned = false;
50720         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
50721         return ret_conv;
50722 }
50723
50724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
50725         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50726         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
50727         return tag_ptr(ret_conv, true);
50728 }
50729
50730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
50731         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50732         *ret_conv = PositiveTimestamp_from_system_time(time);
50733         return tag_ptr(ret_conv, true);
50734 }
50735
50736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
50737         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50738         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
50739         return tag_ptr(ret_conv, true);
50740 }
50741
50742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50743         LDKPositiveTimestamp this_arg_conv;
50744         this_arg_conv.inner = untag_ptr(this_arg);
50745         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50747         this_arg_conv.is_owned = false;
50748         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
50749         return ret_conv;
50750 }
50751
50752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
50753         LDKPositiveTimestamp this_arg_conv;
50754         this_arg_conv.inner = untag_ptr(this_arg);
50755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50757         this_arg_conv.is_owned = false;
50758         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
50759         return ret_conv;
50760 }
50761
50762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50763         LDKPositiveTimestamp this_arg_conv;
50764         this_arg_conv.inner = untag_ptr(this_arg);
50765         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50767         this_arg_conv.is_owned = false;
50768         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
50769         return ret_conv;
50770 }
50771
50772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
50773         LDKInvoice this_arg_conv;
50774         this_arg_conv.inner = untag_ptr(this_arg);
50775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50777         this_arg_conv = Invoice_clone(&this_arg_conv);
50778         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
50779         int64_t ret_ref = 0;
50780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50782         return ret_ref;
50783 }
50784
50785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50786         LDKInvoice this_arg_conv;
50787         this_arg_conv.inner = untag_ptr(this_arg);
50788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50790         this_arg_conv.is_owned = false;
50791         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
50792         *ret_conv = Invoice_check_signature(&this_arg_conv);
50793         return tag_ptr(ret_conv, true);
50794 }
50795
50796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
50797         LDKSignedRawInvoice signed_invoice_conv;
50798         signed_invoice_conv.inner = untag_ptr(signed_invoice);
50799         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
50800         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
50801         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
50802         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
50803         *ret_conv = Invoice_from_signed(signed_invoice_conv);
50804         return tag_ptr(ret_conv, true);
50805 }
50806
50807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50808         LDKInvoice this_arg_conv;
50809         this_arg_conv.inner = untag_ptr(this_arg);
50810         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50812         this_arg_conv.is_owned = false;
50813         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
50814         return ret_conv;
50815 }
50816
50817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
50818         LDKInvoice this_arg_conv;
50819         this_arg_conv.inner = untag_ptr(this_arg);
50820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50822         this_arg_conv.is_owned = false;
50823         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
50824         return ret_conv;
50825 }
50826
50827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50828         LDKInvoice this_arg_conv;
50829         this_arg_conv.inner = untag_ptr(this_arg);
50830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50832         this_arg_conv.is_owned = false;
50833         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50834         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
50835         return ret_arr;
50836 }
50837
50838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50839         LDKInvoice this_arg_conv;
50840         this_arg_conv.inner = untag_ptr(this_arg);
50841         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50843         this_arg_conv.is_owned = false;
50844         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50845         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
50846         return ret_arr;
50847 }
50848
50849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
50850         LDKInvoice this_arg_conv;
50851         this_arg_conv.inner = untag_ptr(this_arg);
50852         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50854         this_arg_conv.is_owned = false;
50855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
50857         return ret_arr;
50858 }
50859
50860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
50861         LDKInvoice this_arg_conv;
50862         this_arg_conv.inner = untag_ptr(this_arg);
50863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50865         this_arg_conv.is_owned = false;
50866         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
50867         int64_t ret_ref = 0;
50868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50870         return ret_ref;
50871 }
50872
50873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50874         LDKInvoice this_arg_conv;
50875         this_arg_conv.inner = untag_ptr(this_arg);
50876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50878         this_arg_conv.is_owned = false;
50879         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
50881         return ret_arr;
50882 }
50883
50884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50885         LDKInvoice this_arg_conv;
50886         this_arg_conv.inner = untag_ptr(this_arg);
50887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50889         this_arg_conv.is_owned = false;
50890         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
50891         return ret_conv;
50892 }
50893
50894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
50895         LDKInvoice this_arg_conv;
50896         this_arg_conv.inner = untag_ptr(this_arg);
50897         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50899         this_arg_conv.is_owned = false;
50900         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
50901         return ret_conv;
50902 }
50903
50904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
50905         LDKInvoice this_arg_conv;
50906         this_arg_conv.inner = untag_ptr(this_arg);
50907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50909         this_arg_conv.is_owned = false;
50910         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
50911         return ret_conv;
50912 }
50913
50914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
50915         LDKInvoice this_arg_conv;
50916         this_arg_conv.inner = untag_ptr(this_arg);
50917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50919         this_arg_conv.is_owned = false;
50920         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
50921         return ret_conv;
50922 }
50923
50924 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
50925         LDKInvoice this_arg_conv;
50926         this_arg_conv.inner = untag_ptr(this_arg);
50927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50929         this_arg_conv.is_owned = false;
50930         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
50931         int64_tArray ret_arr = NULL;
50932         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50933         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50934         for (size_t o = 0; o < ret_var.datalen; o++) {
50935                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
50936                 int64_t ret_conv_14_ref = 0;
50937                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
50938                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
50939                 ret_arr_ptr[o] = ret_conv_14_ref;
50940         }
50941         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50942         FREE(ret_var.data);
50943         return ret_arr;
50944 }
50945
50946 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
50947         LDKInvoice this_arg_conv;
50948         this_arg_conv.inner = untag_ptr(this_arg);
50949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50951         this_arg_conv.is_owned = false;
50952         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
50953         int64_tArray ret_arr = NULL;
50954         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50955         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50956         for (size_t l = 0; l < ret_var.datalen; l++) {
50957                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
50958                 int64_t ret_conv_11_ref = 0;
50959                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
50960                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
50961                 ret_arr_ptr[l] = ret_conv_11_ref;
50962         }
50963         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50964         FREE(ret_var.data);
50965         return ret_arr;
50966 }
50967
50968 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
50969         LDKInvoice this_arg_conv;
50970         this_arg_conv.inner = untag_ptr(this_arg);
50971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50973         this_arg_conv.is_owned = false;
50974         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
50975         return ret_conv;
50976 }
50977
50978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
50979         LDKInvoice this_arg_conv;
50980         this_arg_conv.inner = untag_ptr(this_arg);
50981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50983         this_arg_conv.is_owned = false;
50984         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50985         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
50986         int64_t ret_ref = tag_ptr(ret_copy, true);
50987         return ret_ref;
50988 }
50989
50990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
50991         LDKStr description_conv = java_to_owned_str(env, description);
50992         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
50993         *ret_conv = Description_new(description_conv);
50994         return tag_ptr(ret_conv, true);
50995 }
50996
50997 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
50998         LDKDescription this_arg_conv;
50999         this_arg_conv.inner = untag_ptr(this_arg);
51000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51002         this_arg_conv = Description_clone(&this_arg_conv);
51003         LDKStr ret_str = Description_into_inner(this_arg_conv);
51004         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51005         Str_free(ret_str);
51006         return ret_conv;
51007 }
51008
51009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
51010         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
51011         int64_t ret_ref = 0;
51012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51014         return ret_ref;
51015 }
51016
51017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
51018         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
51019         int64_t ret_ref = 0;
51020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51022         return ret_ref;
51023 }
51024
51025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
51026         LDKExpiryTime this_arg_conv;
51027         this_arg_conv.inner = untag_ptr(this_arg);
51028         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51030         this_arg_conv.is_owned = false;
51031         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
51032         return ret_conv;
51033 }
51034
51035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
51036         LDKExpiryTime this_arg_conv;
51037         this_arg_conv.inner = untag_ptr(this_arg);
51038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51040         this_arg_conv.is_owned = false;
51041         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
51042         return ret_conv;
51043 }
51044
51045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
51046         LDKRouteHint hops_conv;
51047         hops_conv.inner = untag_ptr(hops);
51048         hops_conv.is_owned = ptr_is_owned(hops);
51049         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
51050         hops_conv = RouteHint_clone(&hops_conv);
51051         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
51052         *ret_conv = PrivateRoute_new(hops_conv);
51053         return tag_ptr(ret_conv, true);
51054 }
51055
51056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
51057         LDKPrivateRoute this_arg_conv;
51058         this_arg_conv.inner = untag_ptr(this_arg);
51059         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51061         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
51062         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
51063         int64_t ret_ref = 0;
51064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51066         return ret_ref;
51067 }
51068
51069 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51070         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
51071         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
51072         return ret_conv;
51073 }
51074
51075 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
51076         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
51077         return ret_conv;
51078 }
51079
51080 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
51081         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
51082         return ret_conv;
51083 }
51084
51085 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
51086         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
51087         return ret_conv;
51088 }
51089
51090 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
51091         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
51092         return ret_conv;
51093 }
51094
51095 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
51096         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
51097         return ret_conv;
51098 }
51099
51100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51101         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
51102         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
51103         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
51104         return ret_conv;
51105 }
51106
51107 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51108         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
51109         LDKStr ret_str = CreationError_to_str(o_conv);
51110         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51111         Str_free(ret_str);
51112         return ret_conv;
51113 }
51114
51115 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51116         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
51117         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
51118         return ret_conv;
51119 }
51120
51121 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
51122         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
51123         return ret_conv;
51124 }
51125
51126 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
51127         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
51128         return ret_conv;
51129 }
51130
51131 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
51132         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
51133         return ret_conv;
51134 }
51135
51136 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
51137         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
51138         return ret_conv;
51139 }
51140
51141 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
51142         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
51143         return ret_conv;
51144 }
51145
51146 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
51147         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
51148         return ret_conv;
51149 }
51150
51151 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
51152         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
51153         return ret_conv;
51154 }
51155
51156 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
51157         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
51158         return ret_conv;
51159 }
51160
51161 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
51162         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
51163         return ret_conv;
51164 }
51165
51166 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
51167         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
51168         return ret_conv;
51169 }
51170
51171 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51172         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
51173         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
51174         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
51175         return ret_conv;
51176 }
51177
51178 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51179         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
51180         LDKStr ret_str = SemanticError_to_str(o_conv);
51181         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51182         Str_free(ret_str);
51183         return ret_conv;
51184 }
51185
51186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51187         if (!ptr_is_owned(this_ptr)) return;
51188         void* this_ptr_ptr = untag_ptr(this_ptr);
51189         CHECK_ACCESS(this_ptr_ptr);
51190         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
51191         FREE(untag_ptr(this_ptr));
51192         SignOrCreationError_free(this_ptr_conv);
51193 }
51194
51195 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
51196         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51197         *ret_copy = SignOrCreationError_clone(arg);
51198         int64_t ret_ref = tag_ptr(ret_copy, true);
51199         return ret_ref;
51200 }
51201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51202         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
51203         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
51204         return ret_conv;
51205 }
51206
51207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51208         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
51209         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51210         *ret_copy = SignOrCreationError_clone(orig_conv);
51211         int64_t ret_ref = tag_ptr(ret_copy, true);
51212         return ret_ref;
51213 }
51214
51215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
51216         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51217         *ret_copy = SignOrCreationError_sign_error();
51218         int64_t ret_ref = tag_ptr(ret_copy, true);
51219         return ret_ref;
51220 }
51221
51222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
51223         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
51224         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51225         *ret_copy = SignOrCreationError_creation_error(a_conv);
51226         int64_t ret_ref = tag_ptr(ret_copy, true);
51227         return ret_ref;
51228 }
51229
51230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51231         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
51232         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
51233         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
51234         return ret_conv;
51235 }
51236
51237 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51238         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
51239         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
51240         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51241         Str_free(ret_str);
51242         return ret_conv;
51243 }
51244
51245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51246         LDKInvoicePayer this_obj_conv;
51247         this_obj_conv.inner = untag_ptr(this_obj);
51248         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51250         InvoicePayer_free(this_obj_conv);
51251 }
51252
51253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51254         if (!ptr_is_owned(this_ptr)) return;
51255         void* this_ptr_ptr = untag_ptr(this_ptr);
51256         CHECK_ACCESS(this_ptr_ptr);
51257         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
51258         FREE(untag_ptr(this_ptr));
51259         Payer_free(this_ptr_conv);
51260 }
51261
51262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51263         if (!ptr_is_owned(this_ptr)) return;
51264         void* this_ptr_ptr = untag_ptr(this_ptr);
51265         CHECK_ACCESS(this_ptr_ptr);
51266         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
51267         FREE(untag_ptr(this_ptr));
51268         Router_free(this_ptr_conv);
51269 }
51270
51271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51272         if (!ptr_is_owned(this_ptr)) return;
51273         void* this_ptr_ptr = untag_ptr(this_ptr);
51274         CHECK_ACCESS(this_ptr_ptr);
51275         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
51276         FREE(untag_ptr(this_ptr));
51277         Retry_free(this_ptr_conv);
51278 }
51279
51280 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
51281         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51282         *ret_copy = Retry_clone(arg);
51283         int64_t ret_ref = tag_ptr(ret_copy, true);
51284         return ret_ref;
51285 }
51286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51287         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
51288         int64_t ret_conv = Retry_clone_ptr(arg_conv);
51289         return ret_conv;
51290 }
51291
51292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51293         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
51294         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51295         *ret_copy = Retry_clone(orig_conv);
51296         int64_t ret_ref = tag_ptr(ret_copy, true);
51297         return ret_ref;
51298 }
51299
51300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
51301         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51302         *ret_copy = Retry_attempts(a);
51303         int64_t ret_ref = tag_ptr(ret_copy, true);
51304         return ret_ref;
51305 }
51306
51307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
51308         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51309         *ret_copy = Retry_timeout(a);
51310         int64_t ret_ref = tag_ptr(ret_copy, true);
51311         return ret_ref;
51312 }
51313
51314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51315         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
51316         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
51317         jboolean ret_conv = Retry_eq(a_conv, b_conv);
51318         return ret_conv;
51319 }
51320
51321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
51322         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
51323         int64_t ret_conv = Retry_hash(o_conv);
51324         return ret_conv;
51325 }
51326
51327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51328         if (!ptr_is_owned(this_ptr)) return;
51329         void* this_ptr_ptr = untag_ptr(this_ptr);
51330         CHECK_ACCESS(this_ptr_ptr);
51331         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
51332         FREE(untag_ptr(this_ptr));
51333         PaymentError_free(this_ptr_conv);
51334 }
51335
51336 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
51337         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51338         *ret_copy = PaymentError_clone(arg);
51339         int64_t ret_ref = tag_ptr(ret_copy, true);
51340         return ret_ref;
51341 }
51342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51343         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
51344         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
51345         return ret_conv;
51346 }
51347
51348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51349         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
51350         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51351         *ret_copy = PaymentError_clone(orig_conv);
51352         int64_t ret_ref = tag_ptr(ret_copy, true);
51353         return ret_ref;
51354 }
51355
51356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
51357         LDKStr a_conv = java_to_owned_str(env, a);
51358         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51359         *ret_copy = PaymentError_invoice(a_conv);
51360         int64_t ret_ref = tag_ptr(ret_copy, true);
51361         return ret_ref;
51362 }
51363
51364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
51365         LDKLightningError a_conv;
51366         a_conv.inner = untag_ptr(a);
51367         a_conv.is_owned = ptr_is_owned(a);
51368         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51369         a_conv = LightningError_clone(&a_conv);
51370         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51371         *ret_copy = PaymentError_routing(a_conv);
51372         int64_t ret_ref = tag_ptr(ret_copy, true);
51373         return ret_ref;
51374 }
51375
51376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
51377         void* a_ptr = untag_ptr(a);
51378         CHECK_ACCESS(a_ptr);
51379         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
51380         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
51381         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51382         *ret_copy = PaymentError_sending(a_conv);
51383         int64_t ret_ref = tag_ptr(ret_copy, true);
51384         return ret_ref;
51385 }
51386
51387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t logger, int64_t event_handler, int64_t retry) {
51388         void* payer_ptr = untag_ptr(payer);
51389         CHECK_ACCESS(payer_ptr);
51390         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
51391         if (payer_conv.free == LDKPayer_JCalls_free) {
51392                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51393                 LDKPayer_JCalls_cloned(&payer_conv);
51394         }
51395         void* router_ptr = untag_ptr(router);
51396         CHECK_ACCESS(router_ptr);
51397         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
51398         if (router_conv.free == LDKRouter_JCalls_free) {
51399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51400                 LDKRouter_JCalls_cloned(&router_conv);
51401         }
51402         void* logger_ptr = untag_ptr(logger);
51403         CHECK_ACCESS(logger_ptr);
51404         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51405         if (logger_conv.free == LDKLogger_JCalls_free) {
51406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51407                 LDKLogger_JCalls_cloned(&logger_conv);
51408         }
51409         void* event_handler_ptr = untag_ptr(event_handler);
51410         CHECK_ACCESS(event_handler_ptr);
51411         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
51412         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
51413                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51414                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
51415         }
51416         void* retry_ptr = untag_ptr(retry);
51417         CHECK_ACCESS(retry_ptr);
51418         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
51419         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
51420         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
51421         int64_t ret_ref = 0;
51422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51424         return ret_ref;
51425 }
51426
51427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
51428         LDKInvoicePayer this_arg_conv;
51429         this_arg_conv.inner = untag_ptr(this_arg);
51430         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51432         this_arg_conv.is_owned = false;
51433         LDKInvoice invoice_conv;
51434         invoice_conv.inner = untag_ptr(invoice);
51435         invoice_conv.is_owned = ptr_is_owned(invoice);
51436         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
51437         invoice_conv.is_owned = false;
51438         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51439         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
51440         return tag_ptr(ret_conv, true);
51441 }
51442
51443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
51444         LDKInvoicePayer this_arg_conv;
51445         this_arg_conv.inner = untag_ptr(this_arg);
51446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51448         this_arg_conv.is_owned = false;
51449         LDKInvoice invoice_conv;
51450         invoice_conv.inner = untag_ptr(invoice);
51451         invoice_conv.is_owned = ptr_is_owned(invoice);
51452         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
51453         invoice_conv.is_owned = false;
51454         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51455         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
51456         return tag_ptr(ret_conv, true);
51457 }
51458
51459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
51460         LDKInvoicePayer this_arg_conv;
51461         this_arg_conv.inner = untag_ptr(this_arg);
51462         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51464         this_arg_conv.is_owned = false;
51465         LDKPublicKey pubkey_ref;
51466         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
51467         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
51468         LDKThirtyTwoBytes payment_preimage_ref;
51469         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
51470         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
51471         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51472         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
51473         return tag_ptr(ret_conv, true);
51474 }
51475
51476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
51477         LDKInvoicePayer this_arg_conv;
51478         this_arg_conv.inner = untag_ptr(this_arg);
51479         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51481         this_arg_conv.is_owned = false;
51482         unsigned char payment_hash_arr[32];
51483         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51484         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
51485         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
51486         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
51487 }
51488
51489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
51490         LDKInvoicePayer this_arg_conv;
51491         this_arg_conv.inner = untag_ptr(this_arg);
51492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51494         this_arg_conv.is_owned = false;
51495         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
51496         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
51497         return tag_ptr(ret_ret, true);
51498 }
51499
51500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51501         LDKInFlightHtlcs this_obj_conv;
51502         this_obj_conv.inner = untag_ptr(this_obj);
51503         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51505         InFlightHtlcs_free(this_obj_conv);
51506 }
51507
51508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1used_1liquidity_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid) {
51509         LDKInFlightHtlcs this_arg_conv;
51510         this_arg_conv.inner = untag_ptr(this_arg);
51511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51513         this_arg_conv.is_owned = false;
51514         LDKNodeId source_conv;
51515         source_conv.inner = untag_ptr(source);
51516         source_conv.is_owned = ptr_is_owned(source);
51517         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
51518         source_conv.is_owned = false;
51519         LDKNodeId target_conv;
51520         target_conv.inner = untag_ptr(target);
51521         target_conv.is_owned = ptr_is_owned(target);
51522         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
51523         target_conv.is_owned = false;
51524         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51525         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
51526         int64_t ret_ref = tag_ptr(ret_copy, true);
51527         return ret_ref;
51528 }
51529
51530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
51531         LDKInFlightHtlcs obj_conv;
51532         obj_conv.inner = untag_ptr(obj);
51533         obj_conv.is_owned = ptr_is_owned(obj);
51534         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51535         obj_conv.is_owned = false;
51536         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
51537         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51538         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51539         CVec_u8Z_free(ret_var);
51540         return ret_arr;
51541 }
51542
51543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51544         LDKu8slice ser_ref;
51545         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51546         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51547         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
51548         *ret_conv = InFlightHtlcs_read(ser_ref);
51549         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51550         return tag_ptr(ret_conv, true);
51551 }
51552
51553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, int64_t logger, jclass network) {
51554         void* amt_msat_ptr = untag_ptr(amt_msat);
51555         CHECK_ACCESS(amt_msat_ptr);
51556         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51557         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51558         LDKThirtyTwoBytes payment_hash_ref;
51559         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51560         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
51561         LDKStr description_conv = java_to_owned_str(env, description);
51562         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
51563         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
51564         if (phantom_route_hints_constr.datalen > 0)
51565                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
51566         else
51567                 phantom_route_hints_constr.data = NULL;
51568         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
51569         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
51570                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
51571                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
51572                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
51573                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
51574                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
51575                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
51576                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
51577         }
51578         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
51579         void* keys_manager_ptr = untag_ptr(keys_manager);
51580         CHECK_ACCESS(keys_manager_ptr);
51581         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51582         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51583                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51584                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51585         }
51586         void* logger_ptr = untag_ptr(logger);
51587         CHECK_ACCESS(logger_ptr);
51588         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51589         if (logger_conv.free == LDKLogger_JCalls_free) {
51590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51591                 LDKLogger_JCalls_cloned(&logger_conv);
51592         }
51593         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51594         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51595         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, logger_conv, network_conv);
51596         return tag_ptr(ret_conv, true);
51597 }
51598
51599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, int64_t logger, jclass network) {
51600         void* amt_msat_ptr = untag_ptr(amt_msat);
51601         CHECK_ACCESS(amt_msat_ptr);
51602         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51603         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51604         LDKThirtyTwoBytes payment_hash_ref;
51605         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51606         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
51607         LDKSha256 description_hash_conv;
51608         description_hash_conv.inner = untag_ptr(description_hash);
51609         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51610         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51611         description_hash_conv = Sha256_clone(&description_hash_conv);
51612         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
51613         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
51614         if (phantom_route_hints_constr.datalen > 0)
51615                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
51616         else
51617                 phantom_route_hints_constr.data = NULL;
51618         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
51619         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
51620                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
51621                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
51622                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
51623                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
51624                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
51625                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
51626                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
51627         }
51628         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
51629         void* keys_manager_ptr = untag_ptr(keys_manager);
51630         CHECK_ACCESS(keys_manager_ptr);
51631         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51632         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51633                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51634                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51635         }
51636         void* logger_ptr = untag_ptr(logger);
51637         CHECK_ACCESS(logger_ptr);
51638         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51639         if (logger_conv.free == LDKLogger_JCalls_free) {
51640                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51641                 LDKLogger_JCalls_cloned(&logger_conv);
51642         }
51643         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51644         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51645         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, logger_conv, network_conv);
51646         return tag_ptr(ret_conv, true);
51647 }
51648
51649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, int64_t logger, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
51650         LDKChannelManager channelmanager_conv;
51651         channelmanager_conv.inner = untag_ptr(channelmanager);
51652         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51653         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51654         channelmanager_conv.is_owned = false;
51655         void* keys_manager_ptr = untag_ptr(keys_manager);
51656         CHECK_ACCESS(keys_manager_ptr);
51657         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51658         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51660                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51661         }
51662         void* logger_ptr = untag_ptr(logger);
51663         CHECK_ACCESS(logger_ptr);
51664         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51665         if (logger_conv.free == LDKLogger_JCalls_free) {
51666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51667                 LDKLogger_JCalls_cloned(&logger_conv);
51668         }
51669         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51670         void* amt_msat_ptr = untag_ptr(amt_msat);
51671         CHECK_ACCESS(amt_msat_ptr);
51672         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51673         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51674         LDKStr description_conv = java_to_owned_str(env, description);
51675         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51676         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
51677         return tag_ptr(ret_conv, true);
51678 }
51679
51680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
51681         LDKChannelManager channelmanager_conv;
51682         channelmanager_conv.inner = untag_ptr(channelmanager);
51683         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51684         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51685         channelmanager_conv.is_owned = false;
51686         void* keys_manager_ptr = untag_ptr(keys_manager);
51687         CHECK_ACCESS(keys_manager_ptr);
51688         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51689         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51690                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51691                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51692         }
51693         void* logger_ptr = untag_ptr(logger);
51694         CHECK_ACCESS(logger_ptr);
51695         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51696         if (logger_conv.free == LDKLogger_JCalls_free) {
51697                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51698                 LDKLogger_JCalls_cloned(&logger_conv);
51699         }
51700         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51701         void* amt_msat_ptr = untag_ptr(amt_msat);
51702         CHECK_ACCESS(amt_msat_ptr);
51703         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51704         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51705         LDKSha256 description_hash_conv;
51706         description_hash_conv.inner = untag_ptr(description_hash);
51707         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51708         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51709         description_hash_conv = Sha256_clone(&description_hash_conv);
51710         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51711         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
51712         return tag_ptr(ret_conv, true);
51713 }
51714
51715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
51716         LDKChannelManager channelmanager_conv;
51717         channelmanager_conv.inner = untag_ptr(channelmanager);
51718         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51719         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51720         channelmanager_conv.is_owned = false;
51721         void* keys_manager_ptr = untag_ptr(keys_manager);
51722         CHECK_ACCESS(keys_manager_ptr);
51723         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51724         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51726                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51727         }
51728         void* logger_ptr = untag_ptr(logger);
51729         CHECK_ACCESS(logger_ptr);
51730         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51731         if (logger_conv.free == LDKLogger_JCalls_free) {
51732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51733                 LDKLogger_JCalls_cloned(&logger_conv);
51734         }
51735         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51736         void* amt_msat_ptr = untag_ptr(amt_msat);
51737         CHECK_ACCESS(amt_msat_ptr);
51738         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51739         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51740         LDKSha256 description_hash_conv;
51741         description_hash_conv.inner = untag_ptr(description_hash);
51742         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51743         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51744         description_hash_conv = Sha256_clone(&description_hash_conv);
51745         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51746         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
51747         return tag_ptr(ret_conv, true);
51748 }
51749
51750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, int64_t logger, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
51751         LDKChannelManager channelmanager_conv;
51752         channelmanager_conv.inner = untag_ptr(channelmanager);
51753         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51754         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51755         channelmanager_conv.is_owned = false;
51756         void* keys_manager_ptr = untag_ptr(keys_manager);
51757         CHECK_ACCESS(keys_manager_ptr);
51758         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51759         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51760                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51761                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51762         }
51763         void* logger_ptr = untag_ptr(logger);
51764         CHECK_ACCESS(logger_ptr);
51765         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51766         if (logger_conv.free == LDKLogger_JCalls_free) {
51767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51768                 LDKLogger_JCalls_cloned(&logger_conv);
51769         }
51770         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51771         void* amt_msat_ptr = untag_ptr(amt_msat);
51772         CHECK_ACCESS(amt_msat_ptr);
51773         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51774         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51775         LDKStr description_conv = java_to_owned_str(env, description);
51776         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51777         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
51778         return tag_ptr(ret_conv, true);
51779 }
51780
51781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51782         LDKDefaultRouter this_obj_conv;
51783         this_obj_conv.inner = untag_ptr(this_obj);
51784         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51786         DefaultRouter_free(this_obj_conv);
51787 }
51788
51789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes, int64_t scorer) {
51790         LDKNetworkGraph network_graph_conv;
51791         network_graph_conv.inner = untag_ptr(network_graph);
51792         network_graph_conv.is_owned = ptr_is_owned(network_graph);
51793         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
51794         network_graph_conv.is_owned = false;
51795         void* logger_ptr = untag_ptr(logger);
51796         CHECK_ACCESS(logger_ptr);
51797         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51798         if (logger_conv.free == LDKLogger_JCalls_free) {
51799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51800                 LDKLogger_JCalls_cloned(&logger_conv);
51801         }
51802         LDKThirtyTwoBytes random_seed_bytes_ref;
51803         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
51804         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
51805         void* scorer_ptr = untag_ptr(scorer);
51806         CHECK_ACCESS(scorer_ptr);
51807         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
51808         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
51809                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51810                 LDKLockableScore_JCalls_cloned(&scorer_conv);
51811         }
51812         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
51813         int64_t ret_ref = 0;
51814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51816         return ret_ref;
51817 }
51818
51819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
51820         LDKDefaultRouter this_arg_conv;
51821         this_arg_conv.inner = untag_ptr(this_arg);
51822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51824         this_arg_conv.is_owned = false;
51825         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
51826         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
51827         return tag_ptr(ret_ret, true);
51828 }
51829
51830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
51831         LDKChannelManager this_arg_conv;
51832         this_arg_conv.inner = untag_ptr(this_arg);
51833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51835         this_arg_conv.is_owned = false;
51836         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
51837         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
51838         return tag_ptr(ret_ret, true);
51839 }
51840
51841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51842         LDKStr s_conv = java_to_owned_str(env, s);
51843         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
51844         *ret_conv = SiPrefix_from_str(s_conv);
51845         return tag_ptr(ret_conv, true);
51846 }
51847
51848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51849         LDKStr s_conv = java_to_owned_str(env, s);
51850         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
51851         *ret_conv = Invoice_from_str(s_conv);
51852         return tag_ptr(ret_conv, true);
51853 }
51854
51855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51856         LDKStr s_conv = java_to_owned_str(env, s);
51857         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
51858         *ret_conv = SignedRawInvoice_from_str(s_conv);
51859         return tag_ptr(ret_conv, true);
51860 }
51861
51862 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51863         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
51864         LDKStr ret_str = ParseError_to_str(o_conv);
51865         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51866         Str_free(ret_str);
51867         return ret_conv;
51868 }
51869
51870 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51871         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
51872         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
51873         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51874         Str_free(ret_str);
51875         return ret_conv;
51876 }
51877
51878 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51879         LDKInvoice o_conv;
51880         o_conv.inner = untag_ptr(o);
51881         o_conv.is_owned = ptr_is_owned(o);
51882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51883         o_conv.is_owned = false;
51884         LDKStr ret_str = Invoice_to_str(&o_conv);
51885         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51886         Str_free(ret_str);
51887         return ret_conv;
51888 }
51889
51890 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51891         LDKSignedRawInvoice o_conv;
51892         o_conv.inner = untag_ptr(o);
51893         o_conv.is_owned = ptr_is_owned(o);
51894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51895         o_conv.is_owned = false;
51896         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
51897         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51898         Str_free(ret_str);
51899         return ret_conv;
51900 }
51901
51902 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51903         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
51904         LDKStr ret_str = Currency_to_str(o_conv);
51905         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51906         Str_free(ret_str);
51907         return ret_conv;
51908 }
51909
51910 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51911         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
51912         LDKStr ret_str = SiPrefix_to_str(o_conv);
51913         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51914         Str_free(ret_str);
51915         return ret_conv;
51916 }
51917
51918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51919         LDKRapidGossipSync this_obj_conv;
51920         this_obj_conv.inner = untag_ptr(this_obj);
51921         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51923         RapidGossipSync_free(this_obj_conv);
51924 }
51925
51926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
51927         LDKNetworkGraph network_graph_conv;
51928         network_graph_conv.inner = untag_ptr(network_graph);
51929         network_graph_conv.is_owned = ptr_is_owned(network_graph);
51930         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
51931         network_graph_conv.is_owned = false;
51932         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
51933         int64_t ret_ref = 0;
51934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51936         return ret_ref;
51937 }
51938
51939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
51940         LDKRapidGossipSync this_arg_conv;
51941         this_arg_conv.inner = untag_ptr(this_arg);
51942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51944         this_arg_conv.is_owned = false;
51945         LDKu8slice update_data_ref;
51946         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
51947         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
51948         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
51949         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
51950         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
51951         return tag_ptr(ret_conv, true);
51952 }
51953
51954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
51955         LDKRapidGossipSync this_arg_conv;
51956         this_arg_conv.inner = untag_ptr(this_arg);
51957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51959         this_arg_conv.is_owned = false;
51960         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
51961         return ret_conv;
51962 }
51963
51964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51965         if (!ptr_is_owned(this_ptr)) return;
51966         void* this_ptr_ptr = untag_ptr(this_ptr);
51967         CHECK_ACCESS(this_ptr_ptr);
51968         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
51969         FREE(untag_ptr(this_ptr));
51970         GraphSyncError_free(this_ptr_conv);
51971 }
51972
51973 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
51974         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
51975         *ret_copy = GraphSyncError_clone(arg);
51976         int64_t ret_ref = tag_ptr(ret_copy, true);
51977         return ret_ref;
51978 }
51979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51980         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
51981         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
51982         return ret_conv;
51983 }
51984
51985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51986         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
51987         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
51988         *ret_copy = GraphSyncError_clone(orig_conv);
51989         int64_t ret_ref = tag_ptr(ret_copy, true);
51990         return ret_ref;
51991 }
51992
51993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
51994         void* a_ptr = untag_ptr(a);
51995         CHECK_ACCESS(a_ptr);
51996         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
51997         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
51998         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
51999         *ret_copy = GraphSyncError_decode_error(a_conv);
52000         int64_t ret_ref = tag_ptr(ret_copy, true);
52001         return ret_ref;
52002 }
52003
52004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
52005         LDKLightningError a_conv;
52006         a_conv.inner = untag_ptr(a);
52007         a_conv.is_owned = ptr_is_owned(a);
52008         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52009         a_conv = LightningError_clone(&a_conv);
52010         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
52011         *ret_copy = GraphSyncError_lightning_error(a_conv);
52012         int64_t ret_ref = tag_ptr(ret_copy, true);
52013         return ret_ref;
52014 }
52015